Chromium Code Reviews| Index: third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp |
| diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp |
| index 1c584e713e07b3ad20e15d8f34a90dbd257db5e7..6c6fad240ea4a1149d5253f4963946b23fa18b8e 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp |
| @@ -111,13 +111,18 @@ void V8InspectorSessionImpl::discardInjectedScripts() |
| if (!contexts) |
| return; |
| - protocol::Vector<int> keys; |
| + std::vector<int> keys; |
| + keys.reserve(contexts->size()); |
| for (auto& idContext : *contexts) |
| - keys.append(idContext.first); |
| + keys.push_back(idContext.first); |
| for (auto& key : keys) { |
| contexts = m_debugger->contextGroup(m_contextGroupId); |
| - if (contexts && contexts->contains(key)) |
| - contexts->get(key)->discardInjectedScript(); // This may destroy some contexts. |
| + if (contexts) { |
| + auto context_iter = contexts->find(key); |
|
dgozman
2016/06/24 17:01:13
Blink avoids abbreviations as much as possible, bu
eostroukhov-old
2016/06/24 22:24:26
Done.
|
| + if (context_iter != contexts->end()) { |
|
dgozman
2016/06/24 17:01:13
style: extra {}
eostroukhov-old
2016/06/24 22:24:26
Done.
|
| + context_iter->second->discardInjectedScript(); // This may destroy some contexts. |
| + } |
| + } |
| } |
| } |
| @@ -129,12 +134,13 @@ InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr |
| } |
| const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_contextGroupId); |
| - if (!contexts || !contexts->contains(contextId)) { |
| + auto contexts_iter = contexts ? contexts->find(contextId) : contexts->end(); |
| + if (contexts_iter == contexts->end()) { |
| *errorString = "Cannot find context with specified id"; |
| return nullptr; |
| } |
| - InspectedContext* context = contexts->get(contextId); |
| + const std::unique_ptr<InspectedContext>& context = contexts_iter->second; |
| if (!context->getInjectedScript()) { |
| context->createInjectedScript(); |
| if (!context->getInjectedScript()) { |
| @@ -158,15 +164,18 @@ void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) |
| if (!contexts) |
| return; |
| - protocol::Vector<int> keys; |
| + std::vector<int> keys; |
| for (auto& idContext : *contexts) |
| - keys.append(idContext.first); |
| + keys.push_back(idContext.first); |
| for (auto& key : keys) { |
| contexts = m_debugger->contextGroup(m_contextGroupId); |
| - if (contexts && contexts->contains(key)) { |
| - InjectedScript* injectedScript = contexts->get(key)->getInjectedScript(); |
| - if (injectedScript) |
| - injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. |
| + if (contexts) { |
|
alph
2016/06/24 17:37:27
nit: here and everywhere:
if (!contexts) continue;
eostroukhov-old
2016/06/24 22:24:26
Done.
|
| + auto contexts_iter = contexts->find(key); |
| + if (contexts_iter != contexts->end()) { |
| + InjectedScript* injectedScript = contexts_iter->second->getInjectedScript(); |
| + if (injectedScript) |
| + injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. |
| + } |
| } |
| } |
| } |
| @@ -227,7 +236,7 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) |
| if (!contexts) |
| return; |
| for (auto& idContext : *contexts) |
| - agent->reportExecutionContextCreated(idContext.second); |
| + agent->reportExecutionContextCreated(idContext.second.get()); |
| } |
| void V8InspectorSessionImpl::changeInstrumentationCounter(int delta) |
| @@ -252,16 +261,16 @@ String16 V8InspectorSessionImpl::stateJSON() |
| void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSession::Inspectable> inspectable) |
| { |
| - m_inspectedObjects.prepend(std::move(inspectable)); |
| - while (m_inspectedObjects.size() > kInspectedObjectBufferSize) |
| - m_inspectedObjects.removeLast(); |
| + m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable)); |
| + if (m_inspectedObjects.size() > kInspectedObjectBufferSize) |
| + m_inspectedObjects.resize(kInspectedObjectBufferSize); |
| } |
| V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigned num) |
| { |
| if (num >= m_inspectedObjects.size()) |
| return nullptr; |
| - return m_inspectedObjects[num]; |
| + return m_inspectedObjects[num].get(); |
| } |
| void V8InspectorSessionImpl::schedulePauseOnNextStatement(const String16& breakReason, std::unique_ptr<protocol::DictionaryValue> data) |