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

Unified Diff: base/tracked_objects.h

Issue 17023: Provide and use auto startup/teardown for tracked objects... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.h
===================================================================
--- base/tracked_objects.h (revision 7482)
+++ base/tracked_objects.h (working copy)
@@ -39,7 +39,7 @@
// allowed to access birth_count_ (which changes over time).
const ThreadData* birth_thread_; // The thread this birth took place on.
- DISALLOW_EVIL_CONSTRUCTORS(BirthOnThread);
+ DISALLOW_COPY_AND_ASSIGN(BirthOnThread);
};
//------------------------------------------------------------------------------
@@ -62,7 +62,7 @@
// The number of births on this thread for our location_.
int birth_count_;
- DISALLOW_EVIL_CONSTRUCTORS(Births);
+ DISALLOW_COPY_AND_ASSIGN(Births);
};
//------------------------------------------------------------------------------
@@ -183,7 +183,7 @@
Lock accumulation_lock_; // Protects access during accumulation phase.
- DISALLOW_EVIL_CONSTRUCTORS(DataCollector);
+ DISALLOW_COPY_AND_ASSIGN(DataCollector);
};
//------------------------------------------------------------------------------
@@ -209,7 +209,7 @@
DeathData death_data_;
std::map<const ThreadData*, int> death_threads_;
- DISALLOW_EVIL_CONSTRUCTORS(Aggregation);
+ DISALLOW_COPY_AND_ASSIGN(Aggregation);
};
//------------------------------------------------------------------------------
@@ -428,7 +428,7 @@
// Make sure enough tasks are called before completion is signaled.
ThreadSafeDownCounter* counter_;
- DISALLOW_EVIL_CONSTRUCTORS(RunTheStatic);
+ DISALLOW_COPY_AND_ASSIGN(RunTheStatic);
};
#endif
@@ -480,9 +480,35 @@
// data, but that is considered acceptable errors (mis-information).
Lock lock_;
- DISALLOW_EVIL_CONSTRUCTORS(ThreadData);
+ DISALLOW_COPY_AND_ASSIGN(ThreadData);
};
+
+//------------------------------------------------------------------------------
+// Provide simple way to to start global tracking, and to tear down tracking
+// when done. Note that construction and destruction of this object must be
+// done when running in single threaded mode (before spawning a lot of threads
+// for construction, and after shutting down all the threads for destruction).
+
+class AutoTracking {
+ public:
+ AutoTracking() { ThreadData::StartTracking(true); }
+
+ ~AutoTracking() {
+#ifndef NDEBUG // Don't call these in a Release build: they just waste time.
+ // The following should ONLY be called when in single threaded mode. It is
+ // unsafe to do this cleanup if other threads are still active.
+ // It is also very unnecessary, so I'm only doing this in debug to satisfy
+ // purify (if we need to!).
+ ThreadData::ShutdownSingleThreadedCleanup();
+#endif
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutoTracking);
+};
+
+
} // namespace tracked_objects
#endif // BASE_TRACKED_OBJECTS_H_
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698