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

Side by Side 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: Early return in InitializeThreadContext Created 4 years, 8 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 unified diff | Download patch
« base/tracked_objects.h ('K') | « base/tracked_objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/tracked_objects.h" 5 #include "base/tracked_objects.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 347
348 // static 348 // static
349 ThreadData* ThreadData::first() { 349 ThreadData* ThreadData::first() {
350 base::AutoLock lock(*list_lock_.Pointer()); 350 base::AutoLock lock(*list_lock_.Pointer());
351 return all_thread_data_list_head_; 351 return all_thread_data_list_head_;
352 } 352 }
353 353
354 ThreadData* ThreadData::next() const { return next_; } 354 ThreadData* ThreadData::next() const { return next_; }
355 355
356 // static 356 // static
357 void ThreadData::InitializeThreadContext(const std::string& suggested_name) { 357 void ThreadData::InitializeThreadContext(const std::string& suggested_name,
358 bool is_worker_thread) {
358 Initialize(); 359 Initialize();
359 ThreadData* current_thread_data = 360 ThreadData* current_thread_data =
360 reinterpret_cast<ThreadData*>(tls_index_.Get()); 361 reinterpret_cast<ThreadData*>(tls_index_.Get());
361 if (current_thread_data) 362 if (current_thread_data or is_worker_thread)
jar (doing other things) 2016/04/20 04:34:51 The test for is_worker_thread should be done betwe
Zhenyu Shan 2016/05/04 23:33:03 Done.
362 return; // Browser tests instigate this. 363 return; // Browser tests instigate this.
363 current_thread_data = new ThreadData(suggested_name); 364 current_thread_data = new ThreadData(suggested_name);
364 tls_index_.Set(current_thread_data); 365 tls_index_.Set(current_thread_data);
365 } 366 }
366 367
367 // static 368 // static
368 ThreadData* ThreadData::Get() { 369 ThreadData* ThreadData::Get() {
369 if (!tls_index_.initialized()) 370 if (!tls_index_.initialized())
370 return NULL; // For unittests only. 371 return NULL; // For unittests only.
371 ThreadData* registered = reinterpret_cast<ThreadData*>(tls_index_.Get()); 372 ThreadData* registered = reinterpret_cast<ThreadData*>(tls_index_.Get());
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 #endif 969 #endif
969 } 970 }
970 971
971 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) = 972 ProcessDataSnapshot::ProcessDataSnapshot(const ProcessDataSnapshot& other) =
972 default; 973 default;
973 974
974 ProcessDataSnapshot::~ProcessDataSnapshot() { 975 ProcessDataSnapshot::~ProcessDataSnapshot() {
975 } 976 }
976 977
977 } // namespace tracked_objects 978 } // namespace tracked_objects
OLDNEW
« base/tracked_objects.h ('K') | « base/tracked_objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698