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" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // snapshot it (but they lock before copying it). | 335 // snapshot it (but they lock before copying it). |
336 base::AutoLock lock(map_lock_); | 336 base::AutoLock lock(map_lock_); |
337 birth_map_[location] = tracker; | 337 birth_map_[location] = tracker; |
338 return tracker; | 338 return tracker; |
339 } | 339 } |
340 | 340 |
341 void ThreadData::TallyADeath(const Births& birth, | 341 void ThreadData::TallyADeath(const Births& birth, |
342 DurationInt queue_duration, | 342 DurationInt queue_duration, |
343 DurationInt run_duration) { | 343 DurationInt run_duration) { |
344 // Stir in some randomness, plus add constant in case durations are zero. | 344 // Stir in some randomness, plus add constant in case durations are zero. |
345 const DurationInt kSomePrimeNumber = 4294967279; | 345 const DurationInt kSomePrimeNumber = 5939; // To big is 4294967279; |
346 random_number_ += queue_duration + run_duration + kSomePrimeNumber; | 346 random_number_ += queue_duration + run_duration + kSomePrimeNumber; |
347 // An address is going to have some randomness to it as well ;-). | 347 // An address is going to have some randomness to it as well ;-). |
348 random_number_ ^= static_cast<int32>(&birth - reinterpret_cast<Births*>(0)); | 348 random_number_ ^= static_cast<int32>(&birth - reinterpret_cast<Births*>(0)); |
349 | 349 |
350 DeathMap::iterator it = death_map_.find(&birth); | 350 DeathMap::iterator it = death_map_.find(&birth); |
351 DeathData* death_data; | 351 DeathData* death_data; |
352 if (it != death_map_.end()) { | 352 if (it != death_map_.end()) { |
353 death_data = &it->second; | 353 death_data = &it->second; |
354 } else { | 354 } else { |
355 base::AutoLock lock(map_lock_); // Lock as the map may get relocated now. | 355 base::AutoLock lock(map_lock_); // Lock as the map may get relocated now. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 | 739 |
740 base::ListValue* DataCollector::ToValue() const { | 740 base::ListValue* DataCollector::ToValue() const { |
741 base::ListValue* list = new base::ListValue; | 741 base::ListValue* list = new base::ListValue; |
742 for (size_t i = 0; i < collection_.size(); ++i) { | 742 for (size_t i = 0; i < collection_.size(); ++i) { |
743 list->Append(collection_[i].ToValue()); | 743 list->Append(collection_[i].ToValue()); |
744 } | 744 } |
745 return list; | 745 return list; |
746 } | 746 } |
747 | 747 |
748 } // namespace tracked_objects | 748 } // namespace tracked_objects |
OLD | NEW |