OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ | |
6 #define UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ | |
7 | |
8 #include "base/trace_event/memory_allocator_dump.h" | |
9 #include "ui/gfx/gfx_export.h" | |
10 | |
11 namespace gfx { | |
reveman
2015/08/13 08:24:44
This is OK but FYI, I was hoping to use this for d
danakj
2015/08/13 17:29:50
Yep. We can move it when we need it.
| |
12 | |
13 // Defines an ID type which is used across all types of shared memory | |
14 // allocations in content/. This ID type is in ui/gfx, as components outside | |
15 // content/ may need to hold an ID (but should not generate one). | |
16 class GFX_EXPORT GenericSharedMemoryTracingId { | |
reveman
2015/08/13 08:24:44
What are some examples of usage that we're trying
danakj
2015/08/13 17:29:50
This was my idea. If we're going to use a typedef
reveman
2015/08/13 20:12:23
We would see a difference. We'd not render anythin
danakj
2015/08/13 21:20:26
Most ids are a part of a single small system. This
reveman
2015/08/14 12:36:32
Ok, I buy that.
How about we add "operator int()
| |
17 public: | |
18 int id; | |
19 | |
20 // Invalid ID is -1 to match semantics of base::StaticAtomicSequenceNumber. | |
21 GenericSharedMemoryTracingId() : id(-1) {} | |
22 explicit GenericSharedMemoryTracingId(int id) : id(id) {} | |
23 GenericSharedMemoryTracingId(const GenericSharedMemoryTracingId& other) = | |
24 default; | |
25 GenericSharedMemoryTracingId& operator=( | |
26 const GenericSharedMemoryTracingId& other) = default; | |
27 | |
28 bool operator==(const GenericSharedMemoryTracingId& other) const { | |
29 return id == other.id; | |
30 } | |
31 }; | |
32 | |
33 // Generates GUID which can be used to trace shared memory using its | |
34 // GenericSharedMemoryId. | |
35 BASE_EXPORT base::trace_event::MemoryAllocatorDumpGuid | |
36 GetGenericSharedMemoryGUIDForTracing( | |
37 uint64_t tracing_process_id, | |
38 GenericSharedMemoryTracingId generic_shared_memory_tracing_id); | |
39 | |
40 } // namespace gfx | |
41 | |
42 namespace BASE_HASH_NAMESPACE { | |
43 template <> | |
44 struct hash<gfx::GenericSharedMemoryTracingId> { | |
45 size_t operator()(gfx::GenericSharedMemoryTracingId key) const { | |
46 return BASE_HASH_NAMESPACE::hash<int>()(key.id); | |
47 } | |
48 }; | |
49 } // namespace BASE_HASH_NAMESPACE | |
50 | |
51 #endif // UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ | |
OLD | NEW |