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

Unified Diff: base/tracked_objects.cc

Issue 1845753006: Don't create redundant ThreadData for Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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') | no next file » | 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 d24cedf159241d58a92909650de374f187dd85ae..675c9b89e6747ff288902e78ca280f006045281b 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -16,6 +16,7 @@
#include "base/process/process_handle.h"
#include "base/strings/stringprintf.h"
#include "base/third_party/valgrind/memcheck.h"
+#include "base/threading/worker_pool.h"
#include "base/tracking_info.h"
#include "build/build_config.h"
@@ -355,7 +356,9 @@ ThreadData* ThreadData::next() const { return next_; }
// static
void ThreadData::InitializeThreadContext(const std::string& suggested_name) {
- Initialize();
+ if (base::WorkerPool::RunsTasksOnCurrentThread())
+ return;
+ EnsureTlsInitialization();
ThreadData* current_thread_data =
reinterpret_cast<ThreadData*>(tls_index_.Get());
if (current_thread_data)
@@ -669,7 +672,7 @@ void ThreadData::OnProfilingPhaseCompletedOnThread(int profiling_phase) {
}
}
-void ThreadData::Initialize() {
+void ThreadData::EnsureTlsInitialization() {
if (base::subtle::Acquire_Load(&status_) >= DEACTIVATED)
return; // Someone else did the initialization.
// Due to racy lazy initialization in tests, we'll need to recheck status_
@@ -709,7 +712,7 @@ void ThreadData::InitializeAndSetTrackingStatus(Status status) {
DCHECK_GE(status, DEACTIVATED);
DCHECK_LE(status, PROFILING_ACTIVE);
- Initialize(); // No-op if already initialized.
+ EnsureTlsInitialization(); // No-op if already initialized.
if (status > DEACTIVATED)
status = PROFILING_ACTIVE;
« no previous file with comments | « base/tracked_objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698