Chromium Code Reviews| 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..d90e67a74b19e8d2de86ce8a1f7d97f86322a703 |
| --- /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 { |
|
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.
|
| + |
| +// Defines an ID type which is used across 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 { |
|
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()
|
| + 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 { |
| + 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_ |