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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptNative.cpp

Issue 1758313002: DevTools: introduce collections shim to be backed by non-wtf in v8_inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 #include "platform/v8_inspector/InjectedScriptNative.h" 5 #include "platform/v8_inspector/InjectedScriptNative.h"
6 6
7 #include "platform/inspector_protocol/Values.h" 7 #include "platform/inspector_protocol/Values.h"
8 #include "wtf/Vector.h"
9 8
10 namespace blink { 9 namespace blink {
11 10
12 InjectedScriptNative::InjectedScriptNative(v8::Isolate* isolate) 11 InjectedScriptNative::InjectedScriptNative(v8::Isolate* isolate)
13 : m_lastBoundObjectId(1) 12 : m_lastBoundObjectId(1)
14 , m_isolate(isolate) 13 , m_isolate(isolate)
15 { 14 {
16 } 15 }
17 16
18 static const char privateKeyName[] = "v8-inspector#injectedScript"; 17 static const char privateKeyName[] = "v8-inspector#injectedScript";
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return m_idToWrappedObject.contains(id) ? m_idToWrappedObject.get(id)->Get(m _isolate) : v8::Local<v8::Value>(); 59 return m_idToWrappedObject.contains(id) ? m_idToWrappedObject.get(id)->Get(m _isolate) : v8::Local<v8::Value>();
61 } 60 }
62 61
63 void InjectedScriptNative::addObjectToGroup(int objectId, const String& groupNam e) 62 void InjectedScriptNative::addObjectToGroup(int objectId, const String& groupNam e)
64 { 63 {
65 if (groupName.isEmpty()) 64 if (groupName.isEmpty())
66 return; 65 return;
67 if (objectId <= 0) 66 if (objectId <= 0)
68 return; 67 return;
69 m_idToObjectGroupName.set(objectId, groupName); 68 m_idToObjectGroupName.set(objectId, groupName);
70 NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName); 69 auto it = m_nameToObjectGroup.find(groupName);
71 if (groupIt == m_nameToObjectGroup.end()) 70 if (it == m_nameToObjectGroup.end()) {
72 m_nameToObjectGroup.set(groupName, Vector<int>()).storedValue->value.app end(objectId); 71 m_nameToObjectGroup.set(groupName, protocol::Vector<int>());
73 else 72 it = m_nameToObjectGroup.find(groupName);
74 groupIt->value.append(objectId); 73 }
74 it->second->append(objectId);
75 } 75 }
76 76
77 void InjectedScriptNative::releaseObjectGroup(const String& groupName) 77 void InjectedScriptNative::releaseObjectGroup(const String& groupName)
78 { 78 {
79 if (groupName.isEmpty()) 79 if (groupName.isEmpty())
80 return; 80 return;
81 NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName); 81 NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName);
82 if (groupIt == m_nameToObjectGroup.end()) 82 if (groupIt == m_nameToObjectGroup.end())
83 return; 83 return;
84 for (int id : groupIt->value) 84 for (int id : *groupIt->second)
85 unbind(id); 85 unbind(id);
86 m_nameToObjectGroup.remove(groupIt); 86 m_nameToObjectGroup.remove(groupName);
87 } 87 }
88 88
89 String InjectedScriptNative::groupName(int objectId) const 89 String InjectedScriptNative::groupName(int objectId) const
90 { 90 {
91 if (objectId <= 0) 91 if (objectId <= 0)
92 return String(); 92 return String();
93 return m_idToObjectGroupName.get(objectId); 93 return m_idToObjectGroupName.get(objectId);
94 } 94 }
95 95
96 } // namespace blink 96 } // namespace blink
97 97
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698