Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1176)

Unified Diff: Source/core/inspector/InspectorIdentifiers.h

Issue 1085033003: Introduce InspectorIdentifiers<> and use it to assign/lookup LocalFrame and DocumentLoader (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win build error fixed Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/inspector/InspectorInstrumentation.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorIdentifiers.h
diff --git a/Source/core/inspector/InspectorIdentifiers.h b/Source/core/inspector/InspectorIdentifiers.h
new file mode 100644
index 0000000000000000000000000000000000000000..9df2e5ac45eba34c50a3cd7e3fe7d4f70afdfaf0
--- /dev/null
+++ b/Source/core/inspector/InspectorIdentifiers.h
@@ -0,0 +1,39 @@
+// 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 InspectorIdentifiers_h
+#define InspectorIdentifiers_h
+
+#include "core/dom/WeakIdentifierMap.h"
+#include "core/inspector/IdentifiersFactory.h"
+
+namespace blink {
+
+struct InspectorIdentifierGenerator {
+ using IdentifierType = String;
+ static IdentifierType next()
+ {
+ return IdentifiersFactory::createIdentifier();
+ }
+};
+
+template<typename T> class InspectorIdentifiers {
+public:
+ static String identifier(T* object) { return map().identifier(object); }
+ static T* lookup(const String& identifier) { return map().lookup(identifier); }
+
+private:
+ using IdentifierMap = WeakIdentifierMap<T, InspectorIdentifierGenerator>;
+ InspectorIdentifiers() { }
+
+ static IdentifierMap& map()
+ {
+ DEFINE_STATIC_LOCAL(typename IdentifierMap::ReferenceType, identifierMap, (new IdentifierMap));
+ return *identifierMap;
+ }
+};
+
+} // namespace blink
+
+#endif // #ifndef InspectorIdentifiers_h
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.cpp ('k') | Source/core/inspector/InspectorInstrumentation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698