bug 1249622 - make ThreadData::list_lock_ a StaticMutex r=froydnj

We probably want to convert all of ipc/ to use mozilla mutexs, but this is
 enough to stop creating a static constructor for tracked_object.cc
This commit is contained in:
Trevor Saunders 2016-02-19 09:35:52 -05:00
parent 5e4330caab
commit ad51b7d620
2 changed files with 9 additions and 7 deletions

View File

@ -12,6 +12,7 @@
#include "base/string_util.h"
using base::TimeDelta;
using mozilla::StaticMutexAutoLock;
namespace tracked_objects {
@ -79,7 +80,7 @@ Births::Births(const Location& location)
// static
ThreadData* ThreadData::first_ = NULL;
// static
Lock ThreadData::list_lock_;
mozilla::StaticMutex ThreadData::list_lock_;
// static
ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED;
@ -97,7 +98,7 @@ ThreadData* ThreadData::current() {
bool too_late_to_create = false;
{
registry = new ThreadData;
AutoLock lock(list_lock_);
StaticMutexAutoLock lock(list_lock_);
// Use lock to insure we have most recent status.
if (!IsActive()) {
too_late_to_create = true;
@ -150,7 +151,7 @@ void ThreadData::TallyADeath(const Births& lifetimes,
// static
ThreadData* ThreadData::first() {
AutoLock lock(list_lock_);
StaticMutexAutoLock lock(list_lock_);
return first_;
}
@ -211,12 +212,12 @@ bool ThreadData::StartTracking(bool status) {
return false; // Not compiled in.
#else
if (!status) {
AutoLock lock(list_lock_);
StaticMutexAutoLock lock(list_lock_);
DCHECK(status_ == ACTIVE || status_ == SHUTDOWN);
status_ = SHUTDOWN;
return true;
}
AutoLock lock(list_lock_);
StaticMutexAutoLock lock(list_lock_);
DCHECK(status_ == UNINITIALIZED);
CHECK(tls_index_.Initialize(NULL));
status_ = ACTIVE;
@ -255,7 +256,7 @@ void ThreadData::ShutdownSingleThreadedCleanup() {
return;
ThreadData* thread_data_list;
{
AutoLock lock(list_lock_);
StaticMutexAutoLock lock(list_lock_);
thread_data_list = first_;
first_ = NULL;
}

View File

@ -11,6 +11,7 @@
#include <vector>
#include "base/lock.h"
#include "mozilla/StaticMutex.h"
#include "base/message_loop.h"
#include "base/thread_local_storage.h"
#include "base/tracked.h"
@ -428,7 +429,7 @@ class ThreadData {
// Link to the most recently created instance (starts a null terminated list).
static ThreadData* first_;
// Protection for access to first_.
static Lock list_lock_;
static mozilla::StaticMutex list_lock_;
// We set status_ to SHUTDOWN when we shut down the tracking service. This