| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/third_party/valgrind/memcheck.h" |
| 12 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "base/port.h" | 15 #include "base/port.h" |
| 15 | 16 |
| 16 using base::TimeDelta; | 17 using base::TimeDelta; |
| 17 | 18 |
| 18 namespace tracked_objects { | 19 namespace tracked_objects { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 // Flag to compile out almost all of the task tracking code. | 22 // Flag to compile out almost all of the task tracking code. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 next_retired_worker_(NULL), | 212 next_retired_worker_(NULL), |
| 212 worker_thread_number_(thread_number) { | 213 worker_thread_number_(thread_number) { |
| 213 CHECK_GT(thread_number, 0); | 214 CHECK_GT(thread_number, 0); |
| 214 base::StringAppendF(&thread_name_, "WorkerThread-%d", thread_number); | 215 base::StringAppendF(&thread_name_, "WorkerThread-%d", thread_number); |
| 215 PushToHeadOfList(); // Which sets real incarnation_count_for_pool_. | 216 PushToHeadOfList(); // Which sets real incarnation_count_for_pool_. |
| 216 } | 217 } |
| 217 | 218 |
| 218 ThreadData::~ThreadData() {} | 219 ThreadData::~ThreadData() {} |
| 219 | 220 |
| 220 void ThreadData::PushToHeadOfList() { | 221 void ThreadData::PushToHeadOfList() { |
| 222 VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(&random_number_, |
| 223 sizeof(random_number_)); |
| 221 // Toss in a hint of randomness (atop the uniniitalized value). | 224 // Toss in a hint of randomness (atop the uniniitalized value). |
| 222 random_number_ += static_cast<int32>(this - static_cast<ThreadData*>(0)); | 225 random_number_ += static_cast<int32>(this - static_cast<ThreadData*>(0)); |
| 223 random_number_ ^= (Now() - TrackedTime()).InMilliseconds(); | 226 random_number_ ^= (Now() - TrackedTime()).InMilliseconds(); |
| 224 | 227 |
| 225 DCHECK(!next_); | 228 DCHECK(!next_); |
| 226 base::AutoLock lock(*list_lock_.Pointer()); | 229 base::AutoLock lock(*list_lock_.Pointer()); |
| 227 incarnation_count_for_pool_ = incarnation_counter_; | 230 incarnation_count_for_pool_ = incarnation_counter_; |
| 228 next_ = all_thread_data_list_head_; | 231 next_ = all_thread_data_list_head_; |
| 229 all_thread_data_list_head_ = this; | 232 all_thread_data_list_head_ = this; |
| 230 } | 233 } |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 | 742 |
| 740 base::ListValue* DataCollector::ToValue() const { | 743 base::ListValue* DataCollector::ToValue() const { |
| 741 base::ListValue* list = new base::ListValue; | 744 base::ListValue* list = new base::ListValue; |
| 742 for (size_t i = 0; i < collection_.size(); ++i) { | 745 for (size_t i = 0; i < collection_.size(); ++i) { |
| 743 list->Append(collection_[i].ToValue()); | 746 list->Append(collection_[i].ToValue()); |
| 744 } | 747 } |
| 745 return list; | 748 return list; |
| 746 } | 749 } |
| 747 | 750 |
| 748 } // namespace tracked_objects | 751 } // namespace tracked_objects |
| OLD | NEW |