Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef BASE_TRACKED_OBJECTS_H_ | 5 #ifndef BASE_TRACKED_OBJECTS_H_ |
| 6 #define BASE_TRACKED_OBJECTS_H_ | 6 #define BASE_TRACKED_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 UNINITIALIZED, // Pristine, link-time state before running. | 441 UNINITIALIZED, // Pristine, link-time state before running. |
| 442 DORMANT_DURING_TESTS, // Only used during testing. | 442 DORMANT_DURING_TESTS, // Only used during testing. |
| 443 DEACTIVATED, // No longer recording profiling. | 443 DEACTIVATED, // No longer recording profiling. |
| 444 PROFILING_ACTIVE, // Recording profiles. | 444 PROFILING_ACTIVE, // Recording profiles. |
| 445 STATUS_LAST = PROFILING_ACTIVE | 445 STATUS_LAST = PROFILING_ACTIVE |
| 446 }; | 446 }; |
| 447 | 447 |
| 448 typedef base::hash_map<Location, Births*, Location::Hash> BirthMap; | 448 typedef base::hash_map<Location, Births*, Location::Hash> BirthMap; |
| 449 typedef std::map<const Births*, DeathData> DeathMap; | 449 typedef std::map<const Births*, DeathData> DeathMap; |
| 450 | 450 |
| 451 // Initialize the current thread context with a new instance of ThreadData. | 451 // If is_worker_thread, do partial initialization of the thread context, |
| 452 // and wait for just-in-time initilization using potentially recycled | |
|
Lei Zhang
2016/05/12 19:47:40
typo
Zhenyu Shan
2016/05/16 02:05:35
Restored the comment here because we moved is_work
| |
| 453 // context. Otherwise, Initialize the current thread context with a new | |
| 454 // instance of ThreadData. | |
| 452 // This is used by all threads that have names, and should be explicitly | 455 // This is used by all threads that have names, and should be explicitly |
| 453 // set *before* any births on the threads have taken place. It is generally | 456 // set *before* any births on the threads have taken place. It is generally |
| 454 // only used by the message loop, which has a well defined thread name. | 457 // only used by the message loop, which has a well defined thread name. |
| 455 static void InitializeThreadContext(const std::string& suggested_name); | 458 static void InitializeThreadContext(const std::string& suggested_name, |
| 459 bool is_worker_thread = false); | |
| 456 | 460 |
| 457 // Using Thread Local Store, find the current instance for collecting data. | 461 // Using Thread Local Store, find the current instance for collecting data. |
| 458 // If an instance does not exist, construct one (and remember it for use on | 462 // If an instance does not exist, construct one (and remember it for use on |
| 459 // this thread. | 463 // this thread. |
| 460 // This may return NULL if the system is disabled for any reason. | 464 // This may return NULL if the system is disabled for any reason. |
| 461 static ThreadData* Get(); | 465 static ThreadData* Get(); |
| 462 | 466 |
| 463 // Fills |process_data_snapshot| with phased snapshots of all profiling | 467 // Fills |process_data_snapshot| with phased snapshots of all profiling |
| 464 // phases, including the current one, identified by |current_profiling_phase|. | 468 // phases, including the current one, identified by |current_profiling_phase|. |
| 465 // |current_profiling_phase| is necessary because a child process can start | 469 // |current_profiling_phase| is necessary because a child process can start |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 | 511 |
| 508 // Record the end of execution in region, generally corresponding to a scope | 512 // Record the end of execution in region, generally corresponding to a scope |
| 509 // being exited. | 513 // being exited. |
| 510 static void TallyRunInAScopedRegionIfTracking(const Births* births, | 514 static void TallyRunInAScopedRegionIfTracking(const Births* births, |
| 511 const TaskStopwatch& stopwatch); | 515 const TaskStopwatch& stopwatch); |
| 512 | 516 |
| 513 const std::string& thread_name() const { return thread_name_; } | 517 const std::string& thread_name() const { return thread_name_; } |
| 514 | 518 |
| 515 // Initializes all statics if needed (this initialization call should be made | 519 // Initializes all statics if needed (this initialization call should be made |
| 516 // while we are single threaded). | 520 // while we are single threaded). |
| 517 static void Initialize(); | 521 static void EnsureTlsInitialization(); |
| 518 | 522 |
| 519 // Sets internal status_. | 523 // Sets internal status_. |
| 520 // If |status| is false, then status_ is set to DEACTIVATED. | 524 // If |status| is false, then status_ is set to DEACTIVATED. |
| 521 // If |status| is true, then status_ is set to PROFILING_ACTIVE. | 525 // If |status| is true, then status_ is set to PROFILING_ACTIVE. |
| 522 static void InitializeAndSetTrackingStatus(Status status); | 526 static void InitializeAndSetTrackingStatus(Status status); |
| 523 | 527 |
| 524 static Status status(); | 528 static Status status(); |
| 525 | 529 |
| 526 // Indicate if any sort of profiling is being done (i.e., we are more than | 530 // Indicate if any sort of profiling is being done (i.e., we are more than |
| 527 // DEACTIVATED). | 531 // DEACTIVATED). |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 ProcessDataSnapshot(const ProcessDataSnapshot& other); | 815 ProcessDataSnapshot(const ProcessDataSnapshot& other); |
| 812 ~ProcessDataSnapshot(); | 816 ~ProcessDataSnapshot(); |
| 813 | 817 |
| 814 PhasedProcessDataSnapshotMap phased_snapshots; | 818 PhasedProcessDataSnapshotMap phased_snapshots; |
| 815 base::ProcessId process_id; | 819 base::ProcessId process_id; |
| 816 }; | 820 }; |
| 817 | 821 |
| 818 } // namespace tracked_objects | 822 } // namespace tracked_objects |
| 819 | 823 |
| 820 #endif // BASE_TRACKED_OBJECTS_H_ | 824 #endif // BASE_TRACKED_OBJECTS_H_ |
| OLD | NEW |