| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 354   // | 355   // | 
| 355   // This information is stored on a "best effort" basis. It may be dropped if | 356   // This information is stored on a "best effort" basis. It may be dropped if | 
| 356   // the memory buffer is full or the associated activity is beyond the maximum | 357   // the memory buffer is full or the associated activity is beyond the maximum | 
| 357   // recording depth. | 358   // recording depth. | 
| 358   void Set(StringPiece name, const void* memory, size_t size) { | 359   void Set(StringPiece name, const void* memory, size_t size) { | 
| 359     Set(name, RAW_VALUE, memory, size); | 360     Set(name, RAW_VALUE, memory, size); | 
| 360   } | 361   } | 
| 361   void SetString(StringPiece name, StringPiece value) { | 362   void SetString(StringPiece name, StringPiece value) { | 
| 362     Set(name, STRING_VALUE, value.data(), value.length()); | 363     Set(name, STRING_VALUE, value.data(), value.length()); | 
| 363   } | 364   } | 
|  | 365   void SetString(StringPiece name, StringPiece16 value) { | 
|  | 366     SetString(name, UTF16ToUTF8(value)); | 
|  | 367   } | 
| 364   void SetBool(StringPiece name, bool value) { | 368   void SetBool(StringPiece name, bool value) { | 
| 365     char cvalue = value ? 1 : 0; | 369     char cvalue = value ? 1 : 0; | 
| 366     Set(name, BOOL_VALUE, &cvalue, sizeof(cvalue)); | 370     Set(name, BOOL_VALUE, &cvalue, sizeof(cvalue)); | 
| 367   } | 371   } | 
| 368   void SetChar(StringPiece name, char value) { | 372   void SetChar(StringPiece name, char value) { | 
| 369     Set(name, CHAR_VALUE, &value, sizeof(value)); | 373     Set(name, CHAR_VALUE, &value, sizeof(value)); | 
| 370   } | 374   } | 
| 371   void SetInt(StringPiece name, int64_t value) { | 375   void SetInt(StringPiece name, int64_t value) { | 
| 372     Set(name, SIGNED_VALUE, &value, sizeof(value)); | 376     Set(name, SIGNED_VALUE, &value, sizeof(value)); | 
| 373   } | 377   } | 
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 948   ScopedProcessWaitActivity(const void* program_counter, | 952   ScopedProcessWaitActivity(const void* program_counter, | 
| 949                             const base::Process* process); | 953                             const base::Process* process); | 
| 950   DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); | 954   DISALLOW_COPY_AND_ASSIGN(ScopedProcessWaitActivity); | 
| 951 }; | 955 }; | 
| 952 #endif | 956 #endif | 
| 953 | 957 | 
| 954 }  // namespace debug | 958 }  // namespace debug | 
| 955 }  // namespace base | 959 }  // namespace base | 
| 956 | 960 | 
| 957 #endif  // BASE_DEBUG_ACTIVITY_TRACKER_H_ | 961 #endif  // BASE_DEBUG_ACTIVITY_TRACKER_H_ | 
| OLD | NEW | 
|---|