Chromium Code Reviews| Index: base/profiler/stack_sampling_profiler.h |
| diff --git a/base/profiler/stack_sampling_profiler.h b/base/profiler/stack_sampling_profiler.h |
| index bf5a4f337219f76b782189fde2c5aa2f9646c640..228cc5bae3c0b14bb376d79ec45d7a768d29b25c 100644 |
| --- a/base/profiler/stack_sampling_profiler.h |
| +++ b/base/profiler/stack_sampling_profiler.h |
| @@ -113,9 +113,13 @@ class BASE_EXPORT StackSamplingProfiler { |
| // CallStackProfile represents a set of samples. |
| struct BASE_EXPORT CallStackProfile { |
| CallStackProfile(); |
| - CallStackProfile(const CallStackProfile& other); |
| + CallStackProfile(CallStackProfile&& other); |
| ~CallStackProfile(); |
| + CallStackProfile& operator=(CallStackProfile&& other); |
| + |
| + CallStackProfile CopyForTesting() const; |
| + |
| std::vector<Module> modules; |
| std::vector<Sample> samples; |
| @@ -124,6 +128,10 @@ class BASE_EXPORT StackSamplingProfiler { |
| // Time between samples. |
| TimeDelta sampling_period; |
| + |
| + private: |
| + // Copying is possible but expensive so disallow it; use std::move instead. |
|
Mike Wittman
2016/10/21 18:05:29
nit: ... disallow it _from outside the class_ ...
bcwhite
2016/10/24 13:17:45
Done.
|
| + CallStackProfile(const CallStackProfile& other); |
|
Mike Wittman
2016/10/21 18:05:29
should we have DISALLOW_ASSIGN here?
bcwhite
2016/10/24 13:17:45
Done, though I don't think it's necessary because
|
| }; |
| using CallStackProfiles = std::vector<CallStackProfile>; |
| @@ -151,7 +159,8 @@ class BASE_EXPORT StackSamplingProfiler { |
| TimeDelta sampling_interval; |
| }; |
| - // The callback type used to collect completed profiles. |
| + // The callback type used to collect completed profiles. The passed |profiles| |
| + // are move-only. |
| // |
| // IMPORTANT NOTE: the callback is invoked on a thread the profiler |
| // constructs, rather than on the thread used to construct the profiler and |
| @@ -159,7 +168,7 @@ class BASE_EXPORT StackSamplingProfiler { |
| // threads with message loops that create StackSamplingProfilers, posting a |
| // task to the message loop with a copy of the profiles is the recommended |
| // thread-safe callback implementation. |
| - using CompletedCallback = Callback<void(const CallStackProfiles&)>; |
| + using CompletedCallback = Callback<void(CallStackProfiles)>; |
| // Creates a profiler that sends completed profiles to |callback|. The second |
| // constructor is for test purposes. |