| 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> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void Service::Create(const service_manager::Identity& remote_identity, | 48 void Service::Create(const service_manager::Identity& remote_identity, |
| 49 mojom::StartupPerformanceDataCollectorRequest request) { | 49 mojom::StartupPerformanceDataCollectorRequest request) { |
| 50 startup_performance_data_collector_bindings_.AddBinding(this, | 50 startup_performance_data_collector_bindings_.AddBinding(this, |
| 51 std::move(request)); | 51 std::move(request)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void Service::CreateRecorder(mojom::ProviderPtr provider) { | 54 void Service::CreateRecorder(mojom::ProviderPtr provider) { |
| 55 if (tracing_active_) { | 55 if (tracing_active_) { |
| 56 mojom::RecorderPtr recorder_ptr; | 56 mojom::RecorderPtr recorder_ptr; |
| 57 recorder_impls_.push_back( | 57 recorder_impls_.push_back( |
| 58 new Recorder(GetProxy(&recorder_ptr), sink_.get())); | 58 new Recorder(MakeRequest(&recorder_ptr), sink_.get())); |
| 59 provider->StartTracing(tracing_categories_, std::move(recorder_ptr)); | 59 provider->StartTracing(tracing_categories_, std::move(recorder_ptr)); |
| 60 } | 60 } |
| 61 provider_ptrs_.AddPtr(std::move(provider)); | 61 provider_ptrs_.AddPtr(std::move(provider)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void Service::Start(mojo::ScopedDataPipeProducerHandle stream, | 64 void Service::Start(mojo::ScopedDataPipeProducerHandle stream, |
| 65 const std::string& categories) { | 65 const std::string& categories) { |
| 66 tracing_categories_ = categories; | 66 tracing_categories_ = categories; |
| 67 sink_.reset(new DataSink(std::move(stream))); | 67 sink_.reset(new DataSink(std::move(stream))); |
| 68 provider_ptrs_.ForAllPtrs( | 68 provider_ptrs_.ForAllPtrs( |
| 69 [categories, this](mojom::Provider* controller) { | 69 [categories, this](mojom::Provider* controller) { |
| 70 mojom::RecorderPtr ptr; | 70 mojom::RecorderPtr ptr; |
| 71 recorder_impls_.push_back( | 71 recorder_impls_.push_back(new Recorder(MakeRequest(&ptr), sink_.get())); |
| 72 new Recorder(GetProxy(&ptr), sink_.get())); | |
| 73 controller->StartTracing(categories, std::move(ptr)); | 72 controller->StartTracing(categories, std::move(ptr)); |
| 74 }); | 73 }); |
| 75 tracing_active_ = true; | 74 tracing_active_ = true; |
| 76 } | 75 } |
| 77 | 76 |
| 78 void Service::StopAndFlush() { | 77 void Service::StopAndFlush() { |
| 79 // Remove any collectors that closed their message pipes before we called | 78 // Remove any collectors that closed their message pipes before we called |
| 80 // StopTracing(). | 79 // StopTracing(). |
| 81 for (int i = static_cast<int>(recorder_impls_.size()) - 1; i >= 0; --i) { | 80 for (int i = static_cast<int>(recorder_impls_.size()) - 1; i >= 0; --i) { |
| 82 if (!recorder_impls_[i]->RecorderHandle().is_valid()) { | 81 if (!recorder_impls_[i]->RecorderHandle().is_valid()) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const GetStartupPerformanceTimesCallback& callback) { | 176 const GetStartupPerformanceTimesCallback& callback) { |
| 178 callback.Run(startup_performance_times_.Clone()); | 177 callback.Run(startup_performance_times_.Clone()); |
| 179 } | 178 } |
| 180 | 179 |
| 181 void Service::AllDataCollected() { | 180 void Service::AllDataCollected() { |
| 182 recorder_impls_.clear(); | 181 recorder_impls_.clear(); |
| 183 sink_.reset(); | 182 sink_.reset(); |
| 184 } | 183 } |
| 185 | 184 |
| 186 } // namespace tracing | 185 } // namespace tracing |
| OLD | NEW |