| 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/service.h" | 5 #include "services/tracing/service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "services/service_manager/public/cpp/interface_registry.h" | 15 #include "services/service_manager/public/cpp/interface_registry.h" |
| 16 | 16 |
| 17 namespace tracing { | 17 namespace tracing { |
| 18 | 18 |
| 19 Service::Service() : collector_binding_(this), tracing_active_(false) {} | 19 Service::Service() : collector_binding_(this), tracing_active_(false) {} |
| 20 Service::~Service() {} | 20 Service::~Service() {} |
| 21 | 21 |
| 22 bool Service::OnConnect(const shell::Identity& remote_identity, | 22 bool Service::OnConnect(const service_manager::Identity& remote_identity, |
| 23 shell::InterfaceRegistry* registry) { | 23 service_manager::InterfaceRegistry* registry) { |
| 24 registry->AddInterface<mojom::Factory>(this); | 24 registry->AddInterface<mojom::Factory>(this); |
| 25 registry->AddInterface<mojom::Collector>(this); | 25 registry->AddInterface<mojom::Collector>(this); |
| 26 registry->AddInterface<mojom::StartupPerformanceDataCollector>(this); | 26 registry->AddInterface<mojom::StartupPerformanceDataCollector>(this); |
| 27 return true; | 27 return true; |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool Service::OnStop() { | 30 bool Service::OnStop() { |
| 31 // TODO(beng): This is only required because Service isn't run by | 31 // TODO(beng): This is only required because Service isn't run by |
| 32 // ServiceRunner - instead it's launched automatically by the standalone | 32 // ServiceRunner - instead it's launched automatically by the standalone |
| 33 // shell. It shouldn't be. | 33 // shell. It shouldn't be. |
| 34 base::MessageLoop::current()->QuitWhenIdle(); | 34 base::MessageLoop::current()->QuitWhenIdle(); |
| 35 return false; | 35 return false; |
| 36 } | 36 } |
| 37 | 37 |
| 38 void Service::Create(const shell::Identity& remote_identity, | 38 void Service::Create(const service_manager::Identity& remote_identity, |
| 39 mojom::FactoryRequest request) { | 39 mojom::FactoryRequest request) { |
| 40 bindings_.AddBinding(this, std::move(request)); | 40 bindings_.AddBinding(this, std::move(request)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void Service::Create(const shell::Identity& remote_identity, | 43 void Service::Create(const service_manager::Identity& remote_identity, |
| 44 mojom::CollectorRequest request) { | 44 mojom::CollectorRequest request) { |
| 45 collector_binding_.Bind(std::move(request)); | 45 collector_binding_.Bind(std::move(request)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void Service::Create( | 48 void Service::Create(const service_manager::Identity& remote_identity, |
| 49 const shell::Identity& remote_identity, | 49 mojom::StartupPerformanceDataCollectorRequest request) { |
| 50 mojom::StartupPerformanceDataCollectorRequest request) { | |
| 51 startup_performance_data_collector_bindings_.AddBinding(this, | 50 startup_performance_data_collector_bindings_.AddBinding(this, |
| 52 std::move(request)); | 51 std::move(request)); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void Service::CreateRecorder(mojom::ProviderPtr provider) { | 54 void Service::CreateRecorder(mojom::ProviderPtr provider) { |
| 56 if (tracing_active_) { | 55 if (tracing_active_) { |
| 57 mojom::RecorderPtr recorder_ptr; | 56 mojom::RecorderPtr recorder_ptr; |
| 58 recorder_impls_.push_back( | 57 recorder_impls_.push_back( |
| 59 new Recorder(GetProxy(&recorder_ptr), sink_.get())); | 58 new Recorder(GetProxy(&recorder_ptr), sink_.get())); |
| 60 provider->StartTracing(tracing_categories_, std::move(recorder_ptr)); | 59 provider->StartTracing(tracing_categories_, std::move(recorder_ptr)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 const GetStartupPerformanceTimesCallback& callback) { | 177 const GetStartupPerformanceTimesCallback& callback) { |
| 179 callback.Run(startup_performance_times_.Clone()); | 178 callback.Run(startup_performance_times_.Clone()); |
| 180 } | 179 } |
| 181 | 180 |
| 182 void Service::AllDataCollected() { | 181 void Service::AllDataCollected() { |
| 183 recorder_impls_.clear(); | 182 recorder_impls_.clear(); |
| 184 sink_.reset(); | 183 sink_.reset(); |
| 185 } | 184 } |
| 186 | 185 |
| 187 } // namespace tracing | 186 } // namespace tracing |
| OLD | NEW |