summaryrefslogtreecommitdiffstats
path: root/base/profiler/scoped_profile.h
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 17:09:21 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 17:09:21 +0000
commitdbe5d207423cafcd99684cef2f119a7e197798d3 (patch)
tree2e19e0b01436955084b24f5ad701d3bf6abda538 /base/profiler/scoped_profile.h
parent1fd253983318446dcaebb317d7767ba0c403bd58 (diff)
downloadchromium_src-dbe5d207423cafcd99684cef2f119a7e197798d3.zip
chromium_src-dbe5d207423cafcd99684cef2f119a7e197798d3.tar.gz
chromium_src-dbe5d207423cafcd99684cef2f119a7e197798d3.tar.bz2
Revert of Revert 108752 - Support tracking of IPC messages as tasks in profiler
This is a relanding of all the cleanup found in the original CL, without the hooks to actually monitor the IPC calls. I'm trying to find out what caused the ASAN bot failures by landing piecemeal (per discussion with Joi). The original CL was: Support tracking of IPC messages as tasks in profiler Also started to do more cleanup, including creating a base/profiler directory, and moving parts of the over-sized tracked_objects.* into that directory. r=rtenneti Review URL: http://codereview.chromium.org/8480014 But this CL is: TBR=joi Review URL: http://codereview.chromium.org/8499022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/profiler/scoped_profile.h')
-rw-r--r--base/profiler/scoped_profile.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/base/profiler/scoped_profile.h b/base/profiler/scoped_profile.h
new file mode 100644
index 0000000..2754f5e
--- /dev/null
+++ b/base/profiler/scoped_profile.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+#ifndef BASE_PROFILER_SCOPED_PROFILE_H_
+#define BASE_PROFILER_SCOPED_PROFILE_H_
+
+//------------------------------------------------------------------------------
+// ScopedProfile provides basic helper functions for profiling a short
+// region of code within a scope. It is separate from the related ThreadData
+// class so that it can be included without much other cruft, and provide the
+// macros listed below.
+
+#include "base/base_export.h"
+#include "base/location.h"
+#include "base/profiler/tracked_time.h"
+
+#define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_OFFICIAL_BUILDS(variable_name) \
+ ::tracked_objects::ScopedProfile variable_name(FROM_HERE)
+
+#define TRACK_RUN_IN_IPC_HANDLER(dispatch_function_name) \
+ ::tracked_objects::ScopedProfile some_tracking_variable_name( \
+ FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name))
+
+
+namespace tracked_objects {
+class Births;
+
+class BASE_EXPORT ScopedProfile {
+ public:
+ explicit ScopedProfile(const Location& location);
+ ~ScopedProfile();
+
+ // Stop tracing prior to the end destruction of the instance.
+ void StopClockAndTally();
+
+ private:
+ Births* birth_; // Place in code where tracking started.
+ const TrackedTime start_of_run_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedProfile);
+};
+
+} // namespace tracked_objects
+
+#endif // BASE_PROFILER_SCOPED_PROFILE_H_