OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ |
6 #define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 namespace trace_event { | 14 namespace trace_event { |
15 | 15 |
16 class BASE_EXPORT MemoryAllocatorDumpGuid { | 16 class BASE_EXPORT MemoryAllocatorDumpGuid { |
17 public: | 17 public: |
18 MemoryAllocatorDumpGuid(); | 18 MemoryAllocatorDumpGuid(); |
19 explicit MemoryAllocatorDumpGuid(uint64 guid); | 19 explicit MemoryAllocatorDumpGuid(uint64 guid); |
20 | 20 |
21 // Utility ctor to hash a GUID if the caller prefers a string. The caller | 21 // Utility ctor to hash a GUID if the caller prefers a string. The caller |
22 // still has to ensure that |guid_str| is unique, per snapshot, within the | 22 // can insert "$$" in the string and it will be replaced by the unique child |
23 // global scope of all the traced processes. | 23 // process id for creating cross-process unique guid. Otherwise the caller |
| 24 // has to ensure that |guid_str| is unique, per snapshot, within the global |
| 25 // scope of all the traced processes. |
24 explicit MemoryAllocatorDumpGuid(const std::string& guid_str); | 26 explicit MemoryAllocatorDumpGuid(const std::string& guid_str); |
25 | 27 |
| 28 // Sets the unique id of the child process for creating cross process unique |
| 29 // guids. |
| 30 static void SetUniqueChildProcessId(int child_process_id); |
| 31 |
26 // Returns a (hex-encoded) string representation of the guid. | 32 // Returns a (hex-encoded) string representation of the guid. |
27 std::string ToString() const; | 33 std::string ToString() const; |
28 | 34 |
29 bool empty() const { return guid_ == 0u; } | 35 bool empty() const { return guid_ == 0u; } |
30 | 36 |
31 bool operator==(const MemoryAllocatorDumpGuid& other) const { | 37 bool operator==(const MemoryAllocatorDumpGuid& other) const { |
32 return guid_ == other.guid_; | 38 return guid_ == other.guid_; |
33 } | 39 } |
34 | 40 |
35 bool operator!=(const MemoryAllocatorDumpGuid& other) const { | 41 bool operator!=(const MemoryAllocatorDumpGuid& other) const { |
36 return !(*this == other); | 42 return !(*this == other); |
37 } | 43 } |
38 | 44 |
39 private: | 45 private: |
40 uint64 guid_; | 46 uint64 guid_; |
41 | 47 |
42 // Deliberately copy-able. | 48 // Deliberately copy-able. |
43 }; | 49 }; |
44 | 50 |
45 } // namespace trace_event | 51 } // namespace trace_event |
46 } // namespace base | 52 } // namespace base |
47 | 53 |
48 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ | 54 #endif // BASE_TRACE_EVENT_MEMORY_ALLOCATOR_DUMP_GUID_H_ |
OLD | NEW |