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

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

Issue 1539863002: Convert Pass()→std::move() in mojo/services/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing forward declare that was masked by pre-existing incorrect #include ordering. Created 5 years 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 | « mojo/services/tracing/trace_recorder_impl.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 "mojo/services/tracing/tracing_app.h" 5 #include "mojo/services/tracing/tracing_app.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
10 #include "mojo/application/public/cpp/application_connection.h" 12 #include "mojo/application/public/cpp/application_connection.h"
11 13
12 namespace tracing { 14 namespace tracing {
13 15
14 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) { 16 TracingApp::TracingApp() : collector_binding_(this), tracing_active_(false) {
15 } 17 }
16 18
17 TracingApp::~TracingApp() { 19 TracingApp::~TracingApp() {
18 } 20 }
19 21
20 bool TracingApp::ConfigureIncomingConnection( 22 bool TracingApp::ConfigureIncomingConnection(
21 mojo::ApplicationConnection* connection) { 23 mojo::ApplicationConnection* connection) {
22 connection->AddService<TraceCollector>(this); 24 connection->AddService<TraceCollector>(this);
23 connection->AddService<StartupPerformanceDataCollector>(this); 25 connection->AddService<StartupPerformanceDataCollector>(this);
24 26
25 // If someone connects to us they may want to use the TraceCollector 27 // If someone connects to us they may want to use the TraceCollector
26 // interface and/or they may want to expose themselves to be traced. Attempt 28 // interface and/or they may want to expose themselves to be traced. Attempt
27 // to connect to the TraceProvider interface to see if the application 29 // to connect to the TraceProvider interface to see if the application
28 // connecting to us wants to be traced. They can refuse the connection or 30 // connecting to us wants to be traced. They can refuse the connection or
29 // close the pipe if not. 31 // close the pipe if not.
30 TraceProviderPtr provider_ptr; 32 TraceProviderPtr provider_ptr;
31 connection->ConnectToService(&provider_ptr); 33 connection->ConnectToService(&provider_ptr);
32 if (tracing_active_) { 34 if (tracing_active_) {
33 TraceRecorderPtr recorder_ptr; 35 TraceRecorderPtr recorder_ptr;
34 recorder_impls_.push_back( 36 recorder_impls_.push_back(
35 new TraceRecorderImpl(GetProxy(&recorder_ptr), sink_.get())); 37 new TraceRecorderImpl(GetProxy(&recorder_ptr), sink_.get()));
36 provider_ptr->StartTracing(tracing_categories_, recorder_ptr.Pass()); 38 provider_ptr->StartTracing(tracing_categories_, std::move(recorder_ptr));
37 } 39 }
38 provider_ptrs_.AddInterfacePtr(provider_ptr.Pass()); 40 provider_ptrs_.AddInterfacePtr(std::move(provider_ptr));
39 return true; 41 return true;
40 } 42 }
41 43
42 void TracingApp::Create(mojo::ApplicationConnection* connection, 44 void TracingApp::Create(mojo::ApplicationConnection* connection,
43 mojo::InterfaceRequest<TraceCollector> request) { 45 mojo::InterfaceRequest<TraceCollector> request) {
44 collector_binding_.Bind(request.Pass()); 46 collector_binding_.Bind(std::move(request));
45 } 47 }
46 48
47 void TracingApp::Create( 49 void TracingApp::Create(
48 mojo::ApplicationConnection* connection, 50 mojo::ApplicationConnection* connection,
49 mojo::InterfaceRequest<StartupPerformanceDataCollector> request) { 51 mojo::InterfaceRequest<StartupPerformanceDataCollector> request) {
50 startup_performance_data_collector_bindings_.AddBinding(this, request.Pass()); 52 startup_performance_data_collector_bindings_.AddBinding(this,
53 std::move(request));
51 } 54 }
52 55
53 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream, 56 void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream,
54 const mojo::String& categories) { 57 const mojo::String& categories) {
55 tracing_categories_ = categories; 58 tracing_categories_ = categories;
56 sink_.reset(new TraceDataSink(stream.Pass())); 59 sink_.reset(new TraceDataSink(std::move(stream)));
57 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) { 60 provider_ptrs_.ForAllPtrs([categories, this](TraceProvider* controller) {
58 TraceRecorderPtr ptr; 61 TraceRecorderPtr ptr;
59 recorder_impls_.push_back( 62 recorder_impls_.push_back(
60 new TraceRecorderImpl(GetProxy(&ptr), sink_.get())); 63 new TraceRecorderImpl(GetProxy(&ptr), sink_.get()));
61 controller->StartTracing(categories, ptr.Pass()); 64 controller->StartTracing(categories, std::move(ptr));
62 }); 65 });
63 tracing_active_ = true; 66 tracing_active_ = true;
64 } 67 }
65 68
66 void TracingApp::StopAndFlush() { 69 void TracingApp::StopAndFlush() {
67 // Remove any collectors that closed their message pipes before we called 70 // Remove any collectors that closed their message pipes before we called
68 // StopTracing(). 71 // StopTracing().
69 for (int i = static_cast<int>(recorder_impls_.size()) - 1; i >= 0; --i) { 72 for (int i = static_cast<int>(recorder_impls_.size()) - 1; i >= 0; --i) {
70 if (!recorder_impls_[i]->TraceRecorderHandle().is_valid()) { 73 if (!recorder_impls_[i]->TraceRecorderHandle().is_valid()) {
71 recorder_impls_.erase(recorder_impls_.begin() + i); 74 recorder_impls_.erase(recorder_impls_.begin() + i);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 const GetStartupPerformanceTimesCallback& callback) { 168 const GetStartupPerformanceTimesCallback& callback) {
166 callback.Run(startup_performance_times_.Clone()); 169 callback.Run(startup_performance_times_.Clone());
167 } 170 }
168 171
169 void TracingApp::AllDataCollected() { 172 void TracingApp::AllDataCollected() {
170 recorder_impls_.clear(); 173 recorder_impls_.clear();
171 sink_.reset(); 174 sink_.reset();
172 } 175 }
173 176
174 } // namespace tracing 177 } // namespace tracing
OLDNEW
« no previous file with comments | « mojo/services/tracing/trace_recorder_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698