blob: fa48a23b629c0033580e9a6d123c0614dd3b8897 [file] [log] [blame]
Adam Barth06caa3d2014-10-23 11:15:41 -07001// 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 Robinson0aa2bfb2014-11-25 16:23:42 -08005#include "mojo/common/tracing_impl.h"
Adam Barth06caa3d2014-10-23 11:15:41 -07006
James Robinson6997fa22015-05-01 11:03:09 -07007#include "base/trace_event/trace_event_impl.h"
James Robinson85ccf052014-12-01 16:31:03 -08008#include "mojo/public/cpp/application/application_connection.h"
9#include "mojo/public/cpp/application/application_impl.h"
Adam Barth06caa3d2014-10-23 11:15:41 -070010
James Robinson0aa2bfb2014-11-25 16:23:42 -080011namespace mojo {
Adam Barth06caa3d2014-10-23 11:15:41 -070012
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020013TracingImpl::TracingImpl() {}
Adam Barth06caa3d2014-10-23 11:15:41 -070014
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020015TracingImpl::~TracingImpl() {}
Adam Barth06caa3d2014-10-23 11:15:41 -070016
James Robinson47225cb2015-02-02 16:56:34 -080017void TracingImpl::Initialize(ApplicationImpl* app) {
Viet-Trung Luu7c97b4f2016-04-25 16:55:27 -070018 ApplicationConnection* connection =
19 app->ConnectToApplicationDeprecated("mojo:tracing");
James Robinson47225cb2015-02-02 16:56:34 -080020 connection->AddService(this);
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020021
22#ifdef NDEBUG
23 if (app->HasArg("--early-tracing")) {
Etienne Membrives9b83d632015-09-14 15:56:51 +020024 provider_impl_.ForceEnableTracing();
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020025 }
26#else
Etienne Membrives9b83d632015-09-14 15:56:51 +020027 provider_impl_.ForceEnableTracing();
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020028#endif
Adam Barth06caa3d2014-10-23 11:15:41 -070029}
30
James Robinson47225cb2015-02-02 16:56:34 -080031void TracingImpl::Create(ApplicationConnection* connection,
Przemyslaw Pietrzkiewicz4825af92015-08-13 10:27:45 +020032 InterfaceRequest<tracing::TraceProvider> request) {
Etienne Membrives8b4e8fe2015-09-11 17:21:12 +020033 provider_impl_.Bind(request.Pass());
Adam Barth06caa3d2014-10-23 11:15:41 -070034}
35
James Robinson0aa2bfb2014-11-25 16:23:42 -080036} // namespace mojo