Index: ui/gfx/generic_shared_memory_tracing_id.h |
diff --git a/ui/gfx/generic_shared_memory_tracing_id.h b/ui/gfx/generic_shared_memory_tracing_id.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ccefe73f9ddabc24517f9c7ad8f58e15e7488ea2 |
--- /dev/null |
+++ b/ui/gfx/generic_shared_memory_tracing_id.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ |
+#define UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ |
+ |
+#include "base/trace_event/memory_allocator_dump.h" |
+#include "ui/gfx/gfx_export.h" |
+ |
+namespace gfx { |
+ |
+// Defines an ID type which is used accross all types of shared memory |
+// allocations in content/. This ID type is in ui/gfx, as components outside |
+// content/ may need to hold an ID (but should not generate one). |
+class GFX_EXPORT GenericSharedMemoryTracingId { |
+ public: |
+ int id; |
+ |
+ // Invalid ID is -1 to match semantics of base::StaticAtomicSequenceNumber. |
+ GenericSharedMemoryTracingId() : id(-1) {} |
+ explicit GenericSharedMemoryTracingId(int id) : id(id) {} |
+ GenericSharedMemoryTracingId(const GenericSharedMemoryTracingId& other) = |
+ default; |
+ GenericSharedMemoryTracingId& operator=( |
+ const GenericSharedMemoryTracingId& other) = default; |
+ |
+ bool operator==(const GenericSharedMemoryTracingId& other) const { |
danakj
2015/08/13 00:05:11
Can you make an Equals method instead? Style guide
ericrk
2015/08/13 00:13:56
Need this for hash_map... I could also specialize
danakj
2015/08/13 00:25:06
Oh.. okay.
|
+ return id == other.id; |
+ } |
+}; |
+ |
+// Generates GUID which can be used to trace shared memory using its |
+// GenericSharedMemoryId. |
+BASE_EXPORT base::trace_event::MemoryAllocatorDumpGuid |
+GetGenericSharedMemoryGUIDForTracing( |
+ uint64_t tracing_process_id, |
+ GenericSharedMemoryTracingId generic_shared_memory_tracing_id); |
+ |
+} // namespace gfx |
+ |
+namespace BASE_HASH_NAMESPACE { |
+template <> |
+struct hash<gfx::GenericSharedMemoryTracingId> { |
+ size_t operator()(gfx::GenericSharedMemoryTracingId key) const { |
+ return BASE_HASH_NAMESPACE::hash<int>()(key.id); |
+ } |
+}; |
+} // namespace BASE_HASH_NAMESPACE |
+ |
+#endif // UI_GFX_GENERIC_SHARED_MEMORY_TRACING_ID_H_ |