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

Side by Side Diff: services/tracing/tracing_app.cc

Issue 1532893003: Tidy up the debugger. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-2
Patch Set: rebase Created 4 years, 11 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
« no previous file with comments | « services/debugger/debugger.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/tracing/tracing_app.h" 5 #include "services/tracing/tracing_app.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 10
11 namespace tracing { 11 namespace tracing {
12 12
13 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) { 13 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) {}
14 }
15 14
16 TracingApp::~TracingApp() { 15 TracingApp::~TracingApp() {}
17 }
18 16
19 bool TracingApp::ConfigureIncomingConnection( 17 bool TracingApp::ConfigureIncomingConnection(
20 mojo::ApplicationConnection* connection) { 18 mojo::ApplicationConnection* connection) {
21 connection->AddService<TraceCollector>(this); 19 connection->AddService<TraceCollector>(this);
22 20
23 // If someone connects to us they may want to use the TraceCollector 21 // If someone connects to us they may want to use the TraceCollector
24 // interface and/or they may want to expose themselves to be traced. Attempt 22 // interface and/or they may want to expose themselves to be traced. Attempt
25 // to connect to the TraceProvider interface to see if the application 23 // to connect to the TraceProvider interface to see if the application
26 // connecting to us wants to be traced. They can refuse the connection or 24 // connecting to us wants to be traced. They can refuse the connection or
27 // close the pipe if not. 25 // close the pipe if not.
28 TraceProviderPtr provider_ptr; 26 TraceProviderPtr provider_ptr;
29 connection->ConnectToService(&provider_ptr); 27 connection->ConnectToService(&provider_ptr);
30 if (tracing_active_) { 28 if (tracing_active_) {
31 TraceRecorderPtr recorder_ptr; 29 TraceRecorderPtr recorder_ptr;
32 recorder_impls_.push_back( 30 recorder_impls_.push_back(
33 new TraceRecorderImpl(GetProxy(&recorder_ptr), sink_.get())); 31 new TraceRecorderImpl(GetProxy(&recorder_ptr), sink_.get()));
34 provider_ptr->StartTracing(tracing_categories_, recorder_ptr.Pass()); 32 provider_ptr->StartTracing(tracing_categories_, recorder_ptr.Pass());
35 } 33 }
36 provider_ptrs_.AddInterfacePtr(provider_ptr.Pass()); 34 provider_ptrs_.AddInterfacePtr(provider_ptr.Pass());
37 return true; 35 return true;
38 } 36 }
39 37
40 // mojo::InterfaceFactory<TraceCollector> implementation. 38 // mojo::InterfaceFactory<TraceCollector> implementation.
41 void TracingApp::Create(mojo::ApplicationConnection* connection, 39 void TracingApp::Create(mojo::ApplicationConnection* connection,
42 mojo::InterfaceRequest<TraceCollector> request) { 40 mojo::InterfaceRequest<TraceCollector> request) {
41 if (collector_binding_.is_bound()) {
42 LOG(ERROR) << "Another application is already connected to tracing.";
43 return;
44 }
45
43 collector_binding_.Bind(request.Pass()); 46 collector_binding_.Bind(request.Pass());
44 } 47 }
45 48
46 // tracing::TraceCollector implementation. 49 // tracing::TraceCollector implementation.
47 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream, 50 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream,
48 const mojo::String& categories) { 51 const mojo::String& categories) {
49 tracing_categories_ = categories; 52 tracing_categories_ = categories;
50 sink_.reset(new TraceDataSink(stream.Pass())); 53 sink_.reset(new TraceDataSink(stream.Pass()));
51 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) { 54 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) {
52 TraceRecorderPtr ptr; 55 TraceRecorderPtr ptr;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 124 }
122 AllDataCollected(); 125 AllDataCollected();
123 } 126 }
124 127
125 void TracingApp::AllDataCollected() { 128 void TracingApp::AllDataCollected() {
126 recorder_impls_.clear(); 129 recorder_impls_.clear();
127 sink_.reset(); 130 sink_.reset();
128 } 131 }
129 132
130 } // namespace tracing 133 } // namespace tracing
OLDNEW
« no previous file with comments | « services/debugger/debugger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698