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

Unified Diff: base/tracked_objects.h

Issue 2667513003: Remove some LazyInstance use in base/ (Closed)
Patch Set: . Created 3 years, 11 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
Index: base/tracked_objects.h
diff --git a/base/tracked_objects.h b/base/tracked_objects.h
index 36caec3c6e45ea0984cba1bfa8551c4c7f1af565..8cb771e83ff857c755a785051081ec6f2f32d248 100644
--- a/base/tracked_objects.h
+++ b/base/tracked_objects.h
@@ -21,7 +21,6 @@
#include "base/debug/debugging_flags.h"
#include "base/debug/thread_heap_usage_tracker.h"
#include "base/gtest_prod_util.h"
-#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/process/process_handle.h"
@@ -126,7 +125,7 @@ struct TrackingInfo;
// ThreadData instance has a pointer to the next one. A static member of
// ThreadData provides a pointer to the first item on this global list, and
// access via that all_thread_data_list_head_ item requires the use of the
-// list_lock_.
+// ListLock().
//
// When new ThreadData instances are added to the global list, they are pre-
// pended, which ensures that any prior acquisition of the list is valid (i.e.,
@@ -716,28 +715,31 @@ class BASE_EXPORT ThreadData {
// Linked list of ThreadData instances that were associated with threads that
// have been terminated and that have not been associated with a new thread
- // since then. This is only accessed while |list_lock_| is held.
+ // since then. This is only accessed while |ListLock()| is held.
static ThreadData* first_retired_thread_data_;
// Link to the most recently created instance (starts a null terminated list).
// The list is traversed by about:profiler when it needs to snapshot data.
- // This is only accessed while list_lock_ is held.
+ // This is only accessed while ListLock() is held.
static ThreadData* all_thread_data_list_head_;
// The number of times TLS has called us back to cleanup a ThreadData
- // instance. This is only accessed while list_lock_ is held.
+ // instance. This is only accessed while ListLock() is held.
static int cleanup_count_;
// Incarnation sequence number, indicating how many times (during unittests)
// we've either transitioned out of UNINITIALIZED, or into that state. This
- // value is only accessed while the list_lock_ is held.
+ // value is only accessed while the ListLock() is held.
static int incarnation_counter_;
// Protection for access to all_thread_data_list_head_, and to
// unregistered_thread_data_pool_. This lock is leaked at shutdown.
// The lock is very infrequently used, so we can afford to just make a lazy
// instance and be safe.
- static base::LazyInstance<base::Lock>::Leaky list_lock_;
+ static base::Lock* ListLock() {
+ static auto lock = new base::Lock();
+ return lock;
+ }
// We set status_ to SHUTDOWN when we shut down the tracking service.
static base::subtle::Atomic32 status_;
« base/cpu.cc ('K') | « base/trace_event/trace_log.cc ('k') | base/tracked_objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698