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

Side by Side Diff: sky/engine/core/inspector/InspectorNodeIds.cpp

Issue 683703003: Remove various Heap* types. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/html/imports/HTMLImportsController.cpp ('k') | sky/engine/core/page/Page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "config.h" 5 #include "config.h"
6 #include "core/inspector/InspectorNodeIds.h" 6 #include "core/inspector/InspectorNodeIds.h"
7 7
8 #if ENABLE(OILPAN) 8 #if ENABLE(OILPAN)
9 #include "core/dom/Node.h" 9 #include "core/dom/Node.h"
10 #else 10 #else
11 #include "core/dom/WeakNodeMap.h" 11 #include "core/dom/WeakNodeMap.h"
12 #endif 12 #endif
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 #if ENABLE(OILPAN)
18 typedef HeapHashMap<WeakMember<Node>, int> NodeToIdMap;
19 typedef HeapHashMap<int, WeakMember<Node> > IdToNodeMap;
20
21 static NodeToIdMap& nodeToIdMap()
22 {
23 DEFINE_STATIC_LOCAL(Persistent<NodeToIdMap>, nodeToIdMap, (new NodeToIdMap() ));
24 return *nodeToIdMap;
25 }
26
27 static IdToNodeMap& idToNodeMap()
28 {
29 DEFINE_STATIC_LOCAL(Persistent<IdToNodeMap>, idToNodeMap, (new IdToNodeMap() ));
30 return *idToNodeMap;
31 }
32
33 int InspectorNodeIds::idForNode(Node* node)
34 {
35 static int s_nextNodeId = 1;
36 NodeToIdMap::iterator it = nodeToIdMap().find(node);
37 if (it != nodeToIdMap().end())
38 return it->value;
39 int id = s_nextNodeId++;
40 nodeToIdMap().set(node, id);
41 ASSERT(idToNodeMap().find(id) == idToNodeMap().end());
42 idToNodeMap().set(id, node);
43 return id;
44 }
45
46 Node* InspectorNodeIds::nodeForId(int id)
47 {
48 return idToNodeMap().get(id);
49 }
50 #else
51 static WeakNodeMap& nodeIds() 17 static WeakNodeMap& nodeIds()
52 { 18 {
53 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ()); 19 DEFINE_STATIC_LOCAL(WeakNodeMap, self, ());
54 return self; 20 return self;
55 } 21 }
56 22
57 int InspectorNodeIds::idForNode(Node* node) 23 int InspectorNodeIds::idForNode(Node* node)
58 { 24 {
59 static int s_nextNodeId = 1; 25 static int s_nextNodeId = 1;
60 WeakNodeMap& ids = nodeIds(); 26 WeakNodeMap& ids = nodeIds();
61 int result = ids.value(node); 27 int result = ids.value(node);
62 if (!result) { 28 if (!result) {
63 result = s_nextNodeId++; 29 result = s_nextNodeId++;
64 ids.put(node, result); 30 ids.put(node, result);
65 } 31 }
66 return result; 32 return result;
67 } 33 }
68 34
69 Node* InspectorNodeIds::nodeForId(int id) 35 Node* InspectorNodeIds::nodeForId(int id)
70 { 36 {
71 return nodeIds().node(id); 37 return nodeIds().node(id);
72 } 38 }
73 #endif
74 39
75 } 40 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/imports/HTMLImportsController.cpp ('k') | sky/engine/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698