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

Side by Side Diff: mojo/runner/tracer.cc

Issue 1538823002: Convert Pass()→std::move() in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/runner/task_runners.cc ('k') | mojo/shell/application_instance.cc » ('j') | 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/runner/tracer.h" 5 #include "mojo/runner/tracer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 #include <utility>
9 10
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
14 #include "base/trace_event/trace_config.h" 15 #include "base/trace_event/trace_config.h"
15 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace runner { 19 namespace runner {
(...skipping 23 matching lines...) Expand all
42 << duration_seconds_str; 43 << duration_seconds_str;
43 } 44 }
44 base::MessageLoop::current()->PostDelayedTask( 45 base::MessageLoop::current()->PostDelayedTask(
45 FROM_HERE, 46 FROM_HERE,
46 base::Bind(&Tracer::StopAndFlushToFile, base::Unretained(this)), 47 base::Bind(&Tracer::StopAndFlushToFile, base::Unretained(this)),
47 base::TimeDelta::FromSeconds(trace_duration_secs)); 48 base::TimeDelta::FromSeconds(trace_duration_secs));
48 } 49 }
49 50
50 void Tracer::StartCollectingFromTracingService( 51 void Tracer::StartCollectingFromTracingService(
51 tracing::TraceCollectorPtr coordinator) { 52 tracing::TraceCollectorPtr coordinator) {
52 coordinator_ = coordinator.Pass(); 53 coordinator_ = std::move(coordinator);
53 mojo::DataPipe data_pipe; 54 mojo::DataPipe data_pipe;
54 coordinator_->Start(data_pipe.producer_handle.Pass(), categories_); 55 coordinator_->Start(std::move(data_pipe.producer_handle), categories_);
55 drainer_.reset(new mojo::common::DataPipeDrainer( 56 drainer_.reset(new mojo::common::DataPipeDrainer(
56 this, data_pipe.consumer_handle.Pass())); 57 this, std::move(data_pipe.consumer_handle)));
57 } 58 }
58 59
59 void Tracer::StopAndFlushToFile() { 60 void Tracer::StopAndFlushToFile() {
60 if (tracing_) 61 if (tracing_)
61 StopTracingAndFlushToDisk(); 62 StopTracingAndFlushToDisk();
62 } 63 }
63 64
64 void Tracer::ConnectToProvider( 65 void Tracer::ConnectToProvider(
65 mojo::InterfaceRequest<tracing::TraceProvider> request) { 66 mojo::InterfaceRequest<tracing::TraceProvider> request) {
66 trace_provider_impl_.Bind(request.Pass()); 67 trace_provider_impl_.Bind(std::move(request));
67 } 68 }
68 69
69 void Tracer::StopTracingAndFlushToDisk() { 70 void Tracer::StopTracingAndFlushToDisk() {
70 tracing_ = false; 71 tracing_ = false;
71 trace_file_ = fopen(trace_filename_.c_str(), "w+"); 72 trace_file_ = fopen(trace_filename_.c_str(), "w+");
72 PCHECK(trace_file_); 73 PCHECK(trace_file_);
73 static const char kStart[] = "{\"traceEvents\":["; 74 static const char kStart[] = "{\"traceEvents\":[";
74 PCHECK(fwrite(kStart, 1, strlen(kStart), trace_file_) == strlen(kStart)); 75 PCHECK(fwrite(kStart, 1, strlen(kStart), trace_file_) == strlen(kStart));
75 76
76 // At this point we might be connected to the tracing service, in which case 77 // At this point we might be connected to the tracing service, in which case
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 154 }
154 155
155 void Tracer::WriteCommaIfNeeded() { 156 void Tracer::WriteCommaIfNeeded() {
156 if (first_chunk_written_) 157 if (first_chunk_written_)
157 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); 158 PCHECK(fwrite(",", 1, 1, trace_file_) == 1);
158 first_chunk_written_ = true; 159 first_chunk_written_ = true;
159 } 160 }
160 161
161 } // namespace runner 162 } // namespace runner
162 } // namespace mojo 163 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/task_runners.cc ('k') | mojo/shell/application_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698