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

Side by Side Diff: base/profiler/stack_sampling_profiler.cc

Issue 1479473002: base: Use std::move() instead of Pass() for real movable types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: basepass: missing-include 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 | « base/process/process_metrics_linux.cc ('k') | base/profiler/win32_stack_frame_unwinder.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 "base/profiler/stack_sampling_profiler.h" 5 #include "base/profiler/stack_sampling_profiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "base/location.h" 14 #include "base/location.h"
14 #include "base/profiler/native_stack_sampler.h" 15 #include "base/profiler/native_stack_sampler.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "base/timer/elapsed_timer.h" 18 #include "base/timer/elapsed_timer.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 StackSamplingProfiler::CallStackProfile::CallStackProfile() {} 107 StackSamplingProfiler::CallStackProfile::CallStackProfile() {}
107 108
108 StackSamplingProfiler::CallStackProfile::~CallStackProfile() {} 109 StackSamplingProfiler::CallStackProfile::~CallStackProfile() {}
109 110
110 // StackSamplingProfiler::SamplingThread -------------------------------------- 111 // StackSamplingProfiler::SamplingThread --------------------------------------
111 112
112 StackSamplingProfiler::SamplingThread::SamplingThread( 113 StackSamplingProfiler::SamplingThread::SamplingThread(
113 scoped_ptr<NativeStackSampler> native_sampler, 114 scoped_ptr<NativeStackSampler> native_sampler,
114 const SamplingParams& params, 115 const SamplingParams& params,
115 const CompletedCallback& completed_callback) 116 const CompletedCallback& completed_callback)
116 : native_sampler_(native_sampler.Pass()), 117 : native_sampler_(std::move(native_sampler)),
117 params_(params), 118 params_(params),
118 stop_event_(false, false), 119 stop_event_(false, false),
119 completed_callback_(completed_callback) { 120 completed_callback_(completed_callback) {}
120 }
121 121
122 StackSamplingProfiler::SamplingThread::~SamplingThread() {} 122 StackSamplingProfiler::SamplingThread::~SamplingThread() {}
123 123
124 void StackSamplingProfiler::SamplingThread::ThreadMain() { 124 void StackSamplingProfiler::SamplingThread::ThreadMain() {
125 PlatformThread::SetName("Chrome_SamplingProfilerThread"); 125 PlatformThread::SetName("Chrome_SamplingProfilerThread");
126 126
127 // For now, just ignore any requests to profile while another profiler is 127 // For now, just ignore any requests to profile while another profiler is
128 // working. 128 // working.
129 if (!concurrent_profiling_lock.Get().Try()) 129 if (!concurrent_profiling_lock.Get().Try())
130 return; 130 return;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 void StackSamplingProfiler::Start() { 250 void StackSamplingProfiler::Start() {
251 if (completed_callback_.is_null()) 251 if (completed_callback_.is_null())
252 return; 252 return;
253 253
254 scoped_ptr<NativeStackSampler> native_sampler = 254 scoped_ptr<NativeStackSampler> native_sampler =
255 NativeStackSampler::Create(thread_id_, test_delegate_); 255 NativeStackSampler::Create(thread_id_, test_delegate_);
256 if (!native_sampler) 256 if (!native_sampler)
257 return; 257 return;
258 258
259 sampling_thread_.reset( 259 sampling_thread_.reset(new SamplingThread(std::move(native_sampler), params_,
260 new SamplingThread(native_sampler.Pass(), params_, completed_callback_)); 260 completed_callback_));
261 if (!PlatformThread::Create(0, sampling_thread_.get(), 261 if (!PlatformThread::Create(0, sampling_thread_.get(),
262 &sampling_thread_handle_)) 262 &sampling_thread_handle_))
263 sampling_thread_.reset(); 263 sampling_thread_.reset();
264 } 264 }
265 265
266 void StackSamplingProfiler::Stop() { 266 void StackSamplingProfiler::Stop() {
267 if (sampling_thread_) 267 if (sampling_thread_)
268 sampling_thread_->Stop(); 268 sampling_thread_->Stop();
269 } 269 }
270 270
271 // StackSamplingProfiler::Frame global functions ------------------------------ 271 // StackSamplingProfiler::Frame global functions ------------------------------
272 272
273 bool operator==(const StackSamplingProfiler::Frame &a, 273 bool operator==(const StackSamplingProfiler::Frame &a,
274 const StackSamplingProfiler::Frame &b) { 274 const StackSamplingProfiler::Frame &b) {
275 return a.instruction_pointer == b.instruction_pointer && 275 return a.instruction_pointer == b.instruction_pointer &&
276 a.module_index == b.module_index; 276 a.module_index == b.module_index;
277 } 277 }
278 278
279 bool operator<(const StackSamplingProfiler::Frame &a, 279 bool operator<(const StackSamplingProfiler::Frame &a,
280 const StackSamplingProfiler::Frame &b) { 280 const StackSamplingProfiler::Frame &b) {
281 return (a.module_index < b.module_index) || 281 return (a.module_index < b.module_index) ||
282 (a.module_index == b.module_index && 282 (a.module_index == b.module_index &&
283 a.instruction_pointer < b.instruction_pointer); 283 a.instruction_pointer < b.instruction_pointer);
284 } 284 }
285 285
286 } // namespace base 286 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/profiler/win32_stack_frame_unwinder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698