| 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 InspectorIdentifiers_h |
| 6 #define InspectorIdentifiers_h |
| 7 |
| 8 #include "core/dom/WeakIdentifierMap.h" |
| 9 #include "core/inspector/IdentifiersFactory.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 struct InspectorIdentifierGenerator { |
| 14 using IdentifierType = String; |
| 15 static IdentifierType next() |
| 16 { |
| 17 return IdentifiersFactory::createIdentifier(); |
| 18 } |
| 19 }; |
| 20 |
| 21 template<typename T> class InspectorIdentifiers { |
| 22 public: |
| 23 static String identifier(T* object) { return map().identifier(object); } |
| 24 static T* lookup(const String& identifier) { return map().lookup(identifier)
; } |
| 25 |
| 26 private: |
| 27 using IdentifierMap = WeakIdentifierMap<T, InspectorIdentifierGenerator>; |
| 28 InspectorIdentifiers() { } |
| 29 |
| 30 static IdentifierMap& map() |
| 31 { |
| 32 DEFINE_STATIC_LOCAL(typename IdentifierMap::ReferenceType, identifierMap
, (new IdentifierMap)); |
| 33 return *identifierMap; |
| 34 } |
| 35 }; |
| 36 |
| 37 } // namespace blink |
| 38 |
| 39 #endif // #ifndef InspectorIdentifiers_h |
| OLD | NEW |