Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: mojo/common/tracing_impl.cc

Issue 791493006: De-client tracing.TraceController interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/common/tracing_impl.h" 5 #include "mojo/common/tracing_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "mojo/common/trace_controller_impl.h"
8 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
13 // static 14 TracingImpl::TracingImpl() {
14 void TracingImpl::Create(ApplicationImpl* app) {
15 new TracingImpl(app);
16 }
17
18 // static
19 void TracingImpl::Create(tracing::TraceDataCollectorPtr ptr) {
20 new TracingImpl(ptr.Pass());
21 }
22
23 TracingImpl::TracingImpl(ApplicationImpl* app) : binding_(this) {
24 ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing");
25 tracing::TraceDataCollectorPtr trace_data_collector_ptr;
26 connection->ConnectToService(&trace_data_collector_ptr);
27 binding_.Bind(trace_data_collector_ptr.PassMessagePipe());
28 }
29
30 TracingImpl::TracingImpl(tracing::TraceDataCollectorPtr ptr)
31 : binding_(this, ptr.PassMessagePipe()) {
32 } 15 }
33 16
34 TracingImpl::~TracingImpl() { 17 TracingImpl::~TracingImpl() {
35 } 18 }
36 19
37 void TracingImpl::StartTracing(const String& categories) { 20 void TracingImpl::Initialize(ApplicationImpl* app) {
38 std::string categories_str = categories.To<std::string>(); 21 ApplicationConnection* connection = app->ConnectToApplication("mojo:tracing");
39 base::debug::TraceLog::GetInstance()->SetEnabled( 22 connection->AddService(this);
viettrungluu 2015/02/02 21:22:44 As discussed in person and not applying to this CL
40 base::debug::CategoryFilter(categories_str),
41 base::debug::TraceLog::RECORDING_MODE,
42 base::debug::TraceOptions(base::debug::RECORD_UNTIL_FULL));
43 } 23 }
44 24
45 void TracingImpl::StopTracing() { 25 void TracingImpl::Create(ApplicationConnection* connection,
46 base::debug::TraceLog::GetInstance()->SetDisabled(); 26 InterfaceRequest<tracing::TraceController> request) {
47 27 new TraceControllerImpl(request.Pass());
48 base::debug::TraceLog::GetInstance()->Flush(
49 base::Bind(&TracingImpl::SendChunk, base::Unretained(this)));
50 }
51
52 void TracingImpl::SendChunk(
53 const scoped_refptr<base::RefCountedString>& events_str,
54 bool has_more_events) {
55 binding_.client()->DataCollected(mojo::String(events_str->data()));
56 if (!has_more_events) {
57 binding_.client()->EndTracing();
58 }
59 } 28 }
60 29
61 } // namespace mojo 30 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698