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

Unified Diff: base/tracked_objects.cc

Issue 1128653002: Cleanup base profiler initialization code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update thread_local_android.cc Created 5 years, 7 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
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/tracked_objects.cc
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 9029f4febda79c9206494fc19219994e4d455a15..9c39ab0fea244d69225b7e53b2a4b5b896948d0f 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -388,8 +388,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)
@@ -718,9 +717,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.
@@ -729,7 +728,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
@@ -743,8 +742,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);
@@ -759,21 +757,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
@@ -827,8 +822,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());
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698