summaryrefslogtreecommitdiffstats
path: root/base/tracked_objects.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/tracked_objects.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/tracked_objects.h')
-rw-r--r--base/tracked_objects.h103
1 files changed, 9 insertions, 94 deletions
diff --git a/base/tracked_objects.h b/base/tracked_objects.h
index e89bcf9..94766ea 100644
--- a/base/tracked_objects.h
+++ b/base/tracked_objects.h
@@ -13,16 +13,13 @@
#include "base/base_export.h"
#include "base/location.h"
+#include "base/profiler/tracked_time.h"
#include "base/time.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_local_storage.h"
#include "base/tracking_info.h"
#include "base/values.h"
-#if defined(OS_WIN)
-#include <mmsystem.h> // Declare timeGetTime();
-#endif
-
// TrackedObjects provides a database of stats about objects (generally Tasks)
// that are tracked. Tracking means their birth, death, duration, birth thread,
// death thread, and birth place are recorded. This data is carefully spread
@@ -173,96 +170,6 @@ class MessageLoop;
namespace tracked_objects {
//------------------------------------------------------------------------------
-
-#define USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS
-
-#if defined(USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS)
-
-// TimeTicks maintains a wasteful 64 bits of data (we need less than 32), and on
-// windows, a 64 bit timer is expensive to even obtain. We use a simple
-// millisecond counter for most of our time values, as well as millisecond units
-// of duration between those values. This means we can only handle durations
-// up to 49 days (range), or 24 days (non-negative time durations).
-// We only define enough methods to service the needs of the tracking classes,
-// and our interfaces are modeled after what TimeTicks and TimeDelta use (so we
-// can swap them into place if we want to use the "real" classes).
-
-class BASE_EXPORT Duration { // Similar to base::TimeDelta.
- public:
- Duration() : ms_(0) {}
-
- Duration& operator+=(const Duration& other) {
- ms_ += other.ms_;
- return *this;
- }
-
- Duration operator+(const Duration& other) const {
- return Duration(ms_ + other.ms_);
- }
-
- bool operator==(const Duration& other) const { return ms_ == other.ms_; }
- bool operator!=(const Duration& other) const { return ms_ != other.ms_; }
- bool operator>(const Duration& other) const { return ms_ > other.ms_; }
-
- static Duration FromMilliseconds(int ms) { return Duration(ms); }
-
- int32 InMilliseconds() const { return ms_; }
-
- private:
- friend class TrackedTime;
- explicit Duration(int32 duration) : ms_(duration) {}
-
- // Internal time is stored directly in milliseconds.
- int32 ms_;
-};
-
-class BASE_EXPORT TrackedTime { // Similar to base::TimeTicks.
- public:
- TrackedTime() : ms_(0) {}
- explicit TrackedTime(const base::TimeTicks& time)
- : ms_((time - base::TimeTicks()).InMilliseconds()) {
- }
-
- static TrackedTime Now() {
-#if defined(OS_WIN)
- // Use lock-free accessor to 32 bit time.
- // Note that TimeTicks::Now() is built on this, so we have "compatible"
- // times when we down-convert a TimeTicks sample.
- // TODO(jar): Surface this interface via something in base/time.h.
- return TrackedTime(static_cast<int32>(::timeGetTime()));
-#else
- // Posix has nice cheap 64 bit times, so we just down-convert it.
- return TrackedTime(base::TimeTicks::Now());
-#endif // OS_WIN
- }
-
- Duration operator-(const TrackedTime& other) const {
- return Duration(ms_ - other.ms_);
- }
-
- TrackedTime operator+(const Duration& other) const {
- return TrackedTime(ms_ + other.ms_);
- }
-
- bool is_null() const { return ms_ == 0; }
-
- private:
- friend class Duration;
- explicit TrackedTime(int32 ms) : ms_(ms) {}
-
- // Internal duration is stored directly in milliseconds.
- uint32 ms_;
-};
-
-#else
-
-// Just use full 64 bit time calculations, and the slower TimeTicks::Now().
-typedef base::TimeTicks TrackedTime;
-typedef base::TimeDelta Duration;
-
-#endif // USE_FAST_TIME_CLASS_FOR_DURATION_CALCULATIONS
-
-//------------------------------------------------------------------------------
// For a specific thread, and a specific birth place, the collection of all
// death info (with tallies for each death thread, to prevent access conflicts).
class ThreadData;
@@ -713,9 +620,17 @@ class BASE_EXPORT ThreadData {
const TrackedTime& start_of_run,
const TrackedTime& end_of_run);
+ // Record the end of execution in region, generally corresponding to a scope
+ // being exited.
+ static void TallyRunInAScopedRegionIfTracking(
+ const Births* birth,
+ const TrackedTime& start_of_run,
+ const TrackedTime& end_of_run);
+
const std::string thread_name() const { return thread_name_; }
// ---------------------
+ // TODO(jar):
// The following functions should all be private, and are only public because
// the collection is done externally. We need to relocate that code from the
// collection class into this class, and then all these methods can be made