| OLD | NEW |
| 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 #include "mojo/public/cpp/system/wait.h" | 10 #include "mojo/public/cpp/system/wait.h" |
| 11 | 11 |
| 12 namespace tracing { | 12 namespace tracing { |
| 13 | 13 |
| 14 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) {} | 14 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) {} |
| 15 | 15 |
| 16 TracingApp::~TracingApp() {} | 16 TracingApp::~TracingApp() {} |
| 17 | 17 |
| 18 bool TracingApp::ConfigureIncomingConnection( | 18 bool TracingApp::ConfigureIncomingConnection( |
| 19 mojo::ApplicationConnection* connection) { | 19 mojo::ApplicationConnection* connection) { |
| 20 connection->AddService<TraceCollector>(this); | 20 connection->AddService<TraceCollector>(this); |
| 21 return true; | 21 return true; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void TracingApp::Create(mojo::ApplicationConnection* connection, | 24 void TracingApp::Create(const mojo::ConnectionContext& connection_context, |
| 25 mojo::InterfaceRequest<TraceCollector> request) { | 25 mojo::InterfaceRequest<TraceCollector> request) { |
| 26 if (collector_binding_.is_bound()) { | 26 if (collector_binding_.is_bound()) { |
| 27 LOG(ERROR) << "Another application is already connected to tracing."; | 27 LOG(ERROR) << "Another application is already connected to tracing."; |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 | 30 |
| 31 collector_binding_.Bind(request.Pass()); | 31 collector_binding_.Bind(request.Pass()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void TracingApp::Create(mojo::ApplicationConnection* connection, | 34 void TracingApp::Create(const mojo::ConnectionContext& connection_context, |
| 35 mojo::InterfaceRequest<TraceProviderRegistry> request) { | 35 mojo::InterfaceRequest<TraceProviderRegistry> request) { |
| 36 provider_registry_bindings_.AddBinding(this, request.Pass()); | 36 provider_registry_bindings_.AddBinding(this, request.Pass()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream, | 39 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream, |
| 40 const mojo::String& categories) { | 40 const mojo::String& categories) { |
| 41 tracing_categories_ = categories; | 41 tracing_categories_ = categories; |
| 42 sink_.reset(new TraceDataSink(stream.Pass())); | 42 sink_.reset(new TraceDataSink(stream.Pass())); |
| 43 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) { | 43 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) { |
| 44 TraceRecorderPtr ptr; | 44 TraceRecorderPtr ptr; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 provider_ptrs_.AddInterfacePtr(provider_ptr.Pass()); | 126 provider_ptrs_.AddInterfacePtr(provider_ptr.Pass()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TracingApp::AllDataCollected() { | 129 void TracingApp::AllDataCollected() { |
| 130 recorder_impls_.clear(); | 130 recorder_impls_.clear(); |
| 131 sink_.reset(); | 131 sink_.reset(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace tracing | 134 } // namespace tracing |
| OLD | NEW |