| 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 UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ | 5 #ifndef UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ |
| 6 #define UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ | 6 #define UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/hash.h" |
| 11 #include "base/trace_event/memory_allocator_dump.h" | 13 #include "base/trace_event/memory_allocator_dump.h" |
| 12 #include "ui/gfx/gfx_export.h" | 14 #include "ui/gfx/gfx_export.h" |
| 13 | 15 |
| 14 namespace gfx { | 16 namespace gfx { |
| 15 | 17 |
| 16 // Defines an ID type which is used across all types of shared memory | 18 // Defines an ID type which is used across all types of shared memory |
| 17 // allocations in content/. This ID type is in ui/gfx, as components outside | 19 // allocations in content/. This ID type is in ui/gfx, as components outside |
| 18 // content/ may need to hold an ID (but should not generate one). | 20 // content/ may need to hold an ID (but should not generate one). |
| 19 class GFX_EXPORT GenericSharedMemoryId { | 21 class GFX_EXPORT GenericSharedMemoryId { |
| 20 public: | 22 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 51 struct hash<gfx::GenericSharedMemoryId> { | 53 struct hash<gfx::GenericSharedMemoryId> { |
| 52 size_t operator()(gfx::GenericSharedMemoryId key) const { | 54 size_t operator()(gfx::GenericSharedMemoryId key) const { |
| 53 return BASE_HASH_NAMESPACE::hash<int>()(key.id); | 55 return BASE_HASH_NAMESPACE::hash<int>()(key.id); |
| 54 } | 56 } |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 template <typename Second> | 59 template <typename Second> |
| 58 struct hash<std::pair<gfx::GenericSharedMemoryId, Second>> { | 60 struct hash<std::pair<gfx::GenericSharedMemoryId, Second>> { |
| 59 size_t operator()( | 61 size_t operator()( |
| 60 const std::pair<gfx::GenericSharedMemoryId, Second>& pair) const { | 62 const std::pair<gfx::GenericSharedMemoryId, Second>& pair) const { |
| 61 return base::HashPair(pair.first.id, pair.second); | 63 return base::HashInts(pair.first.id, pair.second); |
| 62 } | 64 } |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 } // namespace BASE_HASH_NAMESPACE | 67 } // namespace BASE_HASH_NAMESPACE |
| 66 | 68 |
| 67 #endif // UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ | 69 #endif // UI_GFX_GENERIC_SHARED_MEMORY_ID_H_ |
| OLD | NEW |