diff options
author | asvitkine <asvitkine@chromium.org> | 2015-05-07 09:27:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-07 16:27:50 +0000 |
commit | d0abaa302dc62c1d10c7a934f23da0d4f5dc7f35 (patch) | |
tree | e330c82849ab6455a3ac8852ee2588d2c41a4162 /base/tracked_objects.cc | |
parent | 0e2478e3ed2649c07e6f244dce921dbb95fca51a (diff) | |
download | chromium_src-d0abaa302dc62c1d10c7a934f23da0d4f5dc7f35.zip chromium_src-d0abaa302dc62c1d10c7a934f23da0d4f5dc7f35.tar.gz chromium_src-d0abaa302dc62c1d10c7a934f23da0d4f5dc7f35.tar.bz2 |
Cleanup base profiler initialization code.
Given that TLS slot can't fail to initialize, remove bool return values
from initialization functions that actually can't fail.
Based off of vadimt@'s CL here:
https://codereview.chromium.org/1124493002/
BUG=456354
Review URL: https://codereview.chromium.org/1128653002
Cr-Commit-Position: refs/heads/master@{#328774}
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r-- | base/tracked_objects.cc | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index f6ea4df..9db05c0 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -362,8 +362,7 @@ ThreadData* ThreadData::next() const { return next_; } // static void ThreadData::InitializeThreadContext(const std::string& suggested_name) { - if (!Initialize()) // Always initialize if needed. - return; + Initialize(); ThreadData* current_thread_data = reinterpret_cast<ThreadData*>(tls_index_.Get()); if (current_thread_data) @@ -692,9 +691,9 @@ static void OptionallyInitializeAlternateTimer() { ThreadData::SetAlternateTimeSource(alternate_time_source); } -bool ThreadData::Initialize() { +void ThreadData::Initialize() { if (status_ >= DEACTIVATED) - return true; // Someone else did the initialization. + return; // Someone else did the initialization. // Due to racy lazy initialization in tests, we'll need to recheck status_ // after we acquire the lock. @@ -703,7 +702,7 @@ bool ThreadData::Initialize() { // initialization. base::AutoLock lock(*list_lock_.Pointer()); if (status_ >= DEACTIVATED) - return true; // Someone raced in here and beat us. + return; // Someone raced in here and beat us. // Put an alternate timer in place if the environment calls for it, such as // for tracking TCMalloc allocations. This insertion is idempotent, so we @@ -717,8 +716,7 @@ bool ThreadData::Initialize() { if (!tls_index_.initialized()) { // Testing may have initialized this. DCHECK_EQ(status_, UNINITIALIZED); tls_index_.Initialize(&ThreadData::OnThreadTermination); - if (!tls_index_.initialized()) - return false; + DCHECK(tls_index_.initialized()); } else { // TLS was initialzed for us earlier. DCHECK_EQ(status_, DORMANT_DURING_TESTS); @@ -733,21 +731,18 @@ bool ThreadData::Initialize() { // we get the lock earlier in this method. status_ = kInitialStartupState; DCHECK(status_ != UNINITIALIZED); - return true; } // static -bool ThreadData::InitializeAndSetTrackingStatus(Status status) { +void ThreadData::InitializeAndSetTrackingStatus(Status status) { DCHECK_GE(status, DEACTIVATED); DCHECK_LE(status, PROFILING_ACTIVE); - if (!Initialize()) // No-op if already initialized. - return false; // Not compiled in. + Initialize(); // No-op if already initialized. if (status > DEACTIVATED) status = PROFILING_ACTIVE; status_ = status; - return true; } // static @@ -801,8 +796,8 @@ void ThreadData::ShutdownSingleThreadedCleanup(bool leak) { // This is only called from test code, where we need to cleanup so that // additional tests can be run. // We must be single threaded... but be careful anyway. - if (!InitializeAndSetTrackingStatus(DEACTIVATED)) - return; + InitializeAndSetTrackingStatus(DEACTIVATED); + ThreadData* thread_data_list; { base::AutoLock lock(*list_lock_.Pointer()); |