Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
James Robinson | 0aa2bfb | 2014-11-25 16:23:42 -0800 | [diff] [blame] | 5 | #include "mojo/common/tracing_impl.h" |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 6 | |
James Robinson | 6997fa2 | 2015-05-01 11:03:09 -0700 | [diff] [blame] | 7 | #include "base/trace_event/trace_event_impl.h" |
James Robinson | 85ccf05 | 2014-12-01 16:31:03 -0800 | [diff] [blame] | 8 | #include "mojo/public/cpp/application/application_connection.h" |
| 9 | #include "mojo/public/cpp/application/application_impl.h" |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 10 | |
James Robinson | 0aa2bfb | 2014-11-25 16:23:42 -0800 | [diff] [blame] | 11 | namespace mojo { |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 12 | |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 13 | TracingImpl::TracingImpl() {} |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 14 | |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 15 | TracingImpl::~TracingImpl() {} |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 16 | |
James Robinson | 47225cb | 2015-02-02 16:56:34 -0800 | [diff] [blame] | 17 | void TracingImpl::Initialize(ApplicationImpl* app) { |
Viet-Trung Luu | 7c97b4f | 2016-04-25 16:55:27 -0700 | [diff] [blame^] | 18 | ApplicationConnection* connection = |
| 19 | app->ConnectToApplicationDeprecated("mojo:tracing"); |
James Robinson | 47225cb | 2015-02-02 16:56:34 -0800 | [diff] [blame] | 20 | connection->AddService(this); |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 21 | |
| 22 | #ifdef NDEBUG |
| 23 | if (app->HasArg("--early-tracing")) { |
Etienne Membrives | 9b83d63 | 2015-09-14 15:56:51 +0200 | [diff] [blame] | 24 | provider_impl_.ForceEnableTracing(); |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 25 | } |
| 26 | #else |
Etienne Membrives | 9b83d63 | 2015-09-14 15:56:51 +0200 | [diff] [blame] | 27 | provider_impl_.ForceEnableTracing(); |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 28 | #endif |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 29 | } |
| 30 | |
James Robinson | 47225cb | 2015-02-02 16:56:34 -0800 | [diff] [blame] | 31 | void TracingImpl::Create(ApplicationConnection* connection, |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 32 | InterfaceRequest<tracing::TraceProvider> request) { |
Etienne Membrives | 8b4e8fe | 2015-09-11 17:21:12 +0200 | [diff] [blame] | 33 | provider_impl_.Bind(request.Pass()); |
Adam Barth | 06caa3d | 2014-10-23 11:15:41 -0700 | [diff] [blame] | 34 | } |
| 35 | |
James Robinson | 0aa2bfb | 2014-11-25 16:23:42 -0800 | [diff] [blame] | 36 | } // namespace mojo |