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

Unified Diff: base/profiler/stack_sampling_profiler.h

Issue 2438073002: Use movable types for CallStackProfile(s) to remove copying of data. (Closed)
Patch Set: added some comments about std::move Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cf1daf7e16d4b1846fa1b20a3c79f0f2578ce100 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,13 @@ class BASE_EXPORT StackSamplingProfiler {
// Time between samples.
TimeDelta sampling_period;
+
+ private:
+ // Copying is possible but expensive so disallow it except for internal use
+ // (i.e. CopyForTesting); use std::move instead.
+ CallStackProfile(const CallStackProfile& other);
+
+ DISALLOW_ASSIGN(CallStackProfile);
};
using CallStackProfiles = std::vector<CallStackProfile>;
@@ -151,7 +162,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 +171,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.
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698