Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Activity tracking provides a low-overhead method of collecting information | 5 // Activity tracking provides a low-overhead method of collecting information |
| 6 // about the state of the application for analysis both while it is running | 6 // about the state of the application for analysis both while it is running |
| 7 // and after it has terminated unexpectedly. Its primary purpose is to help | 7 // and after it has terminated unexpectedly. Its primary purpose is to help |
| 8 // locate reasons the browser becomes unresponsive by providing insight into | 8 // locate reasons the browser becomes unresponsive by providing insight into |
| 9 // what all the various threads and processes are (or were) doing. | 9 // what all the various threads and processes are (or were) doing. |
| 10 | 10 |
| 11 #ifndef BASE_DEBUG_ACTIVITY_TRACKER_H_ | 11 #ifndef BASE_DEBUG_ACTIVITY_TRACKER_H_ |
| 12 #define BASE_DEBUG_ACTIVITY_TRACKER_H_ | 12 #define BASE_DEBUG_ACTIVITY_TRACKER_H_ |
| 13 | 13 |
| 14 // std::atomic is undesired due to performance issues when used as global | 14 // std::atomic is undesired due to performance issues when used as global |
| 15 // variables. There are no such instances here. This module uses the | 15 // variables. There are no such instances here. This module uses the |
| 16 // PersistentMemoryAllocator which also uses std::atomic and is written | 16 // PersistentMemoryAllocator which also uses std::atomic and is written |
| 17 // by the same author. | 17 // by the same author. |
| 18 #include <atomic> | 18 #include <atomic> |
| 19 #include <map> | 19 #include <map> |
| 20 #include <memory> | 20 #include <memory> |
| 21 #include <string> | 21 #include <string> |
| 22 #include <vector> | 22 #include <vector> |
| 23 | 23 |
| 24 #include "base/base_export.h" | 24 #include "base/base_export.h" |
| 25 #include "base/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
| 26 #include "base/gtest_prod_util.h" | 26 #include "base/gtest_prod_util.h" |
| 27 #include "base/location.h" | 27 #include "base/location.h" |
| 28 #include "base/metrics/persistent_memory_allocator.h" | 28 #include "base/metrics/persistent_memory_allocator.h" |
| 29 #include "base/strings/utf_string_conversions.h" | |
| 29 #include "base/threading/platform_thread.h" | 30 #include "base/threading/platform_thread.h" |
| 30 #include "base/threading/thread_checker.h" | 31 #include "base/threading/thread_checker.h" |
| 31 #include "base/threading/thread_local_storage.h" | 32 #include "base/threading/thread_local_storage.h" |
| 32 | 33 |
| 33 namespace base { | 34 namespace base { |
| 34 | 35 |
| 35 struct PendingTask; | 36 struct PendingTask; |
| 36 | 37 |
| 37 class FilePath; | 38 class FilePath; |
| 38 class Lock; | 39 class Lock; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 // | 326 // |
| 326 // This information is stored on a "best effort" basis. It may be dropped if | 327 // This information is stored on a "best effort" basis. It may be dropped if |
| 327 // the memory buffer is full or the associated activity is beyond the maximum | 328 // the memory buffer is full or the associated activity is beyond the maximum |
| 328 // recording depth. | 329 // recording depth. |
| 329 void Set(StringPiece name, const void* memory, size_t size) { | 330 void Set(StringPiece name, const void* memory, size_t size) { |
| 330 Set(name, RAW_VALUE, memory, size); | 331 Set(name, RAW_VALUE, memory, size); |
| 331 } | 332 } |
| 332 void SetString(StringPiece name, StringPiece value) { | 333 void SetString(StringPiece name, StringPiece value) { |
| 333 Set(name, STRING_VALUE, value.data(), value.length()); | 334 Set(name, STRING_VALUE, value.data(), value.length()); |
| 334 } | 335 } |
| 336 void SetString(StringPiece name, StringPiece16 value) { | |
| 337 SetString(name, base::UTF16ToUTF8(value)); | |
|
bcwhite
2016/12/06 22:37:32
This module is part of base so you can remove the
manzagop (departed)
2016/12/07 14:51:10
Done.
| |
| 338 } | |
| 335 void SetChar(StringPiece name, char value) { | 339 void SetChar(StringPiece name, char value) { |
| 336 Set(name, CHAR_VALUE, &value, sizeof(value)); | 340 Set(name, CHAR_VALUE, &value, sizeof(value)); |
| 337 } | 341 } |
| 338 void SetInt(StringPiece name, int64_t value) { | 342 void SetInt(StringPiece name, int64_t value) { |
| 339 Set(name, SIGNED_VALUE, &value, sizeof(value)); | 343 Set(name, SIGNED_VALUE, &value, sizeof(value)); |
| 340 } | 344 } |
| 341 void SetUint(StringPiece name, uint64_t value) { | 345 void SetUint(StringPiece name, uint64_t value) { |
| 342 Set(name, UNSIGNED_VALUE, &value, sizeof(value)); | 346 Set(name, UNSIGNED_VALUE, &value, sizeof(value)); |
| 343 } | 347 } |
| 344 | 348 |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 863 ScopedProcessWaitActivity(const void* program_counter, | 867 ScopedProcessWaitActivity(const void* program_counter, |
| 864 const base::Process* process); | 868 const base::Process* process); |
| 865 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); | 869 DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); |
| 866 }; | 870 }; |
| 867 #endif | 871 #endif |
| 868 | 872 |
| 869 } // namespace debug | 873 } // namespace debug |
| 870 } // namespace base | 874 } // namespace base |
| 871 | 875 |
| 872 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ | 876 #endif // BASE_DEBUG_ACTIVITY_TRACKER_H_ |
| OLD | NEW |