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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixes Created 4 years, 4 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
Index: third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
index 3cefc9b5b95fe73157dbadcf6b849b203c9d0fc4..4b77872bd22625b2d164bf102e6f48dc9004d151 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp
@@ -38,6 +38,7 @@
#include "core/events/EventTarget.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/inspector/InspectorDOMAgent.h"
+#include "core/inspector/V8InspectorString.h"
#include "platform/v8_inspector/public/V8InspectorSession.h"
namespace {
@@ -306,11 +307,8 @@ void InspectorDOMDebuggerAgent::removeBreakpoint(ErrorString* error, const Strin
void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node)
{
- if (hasBreakpoint(node, AttributeModified)) {
- std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
- descriptionForDOMEvent(node, AttributeModified, false, eventData.get());
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::DOM, eventData->toJSONString());
- }
+ if (hasBreakpoint(node, AttributeModified))
+ breakProgramOnDOMEvent(node, AttributeModified, false);
}
void InspectorDOMDebuggerAgent::didInsertDOMNode(Node* node)
@@ -411,15 +409,15 @@ void InspectorDOMDebuggerAgent::getEventListeners(ErrorString* errorString, cons
v8::HandleScope handles(m_isolate);
v8::Local<v8::Value> value;
v8::Local<v8::Context> context;
- String16 objectGroup;
- if (!m_v8Session->unwrapObject(errorString, objectId, &value, &context, &objectGroup))
+ std::unique_ptr<v8_inspector::StringBuffer> objectGroup;
+ if (!m_v8Session->unwrapObject(errorString, toV8InspectorStringView(objectId), &value, &context, &objectGroup))
return;
v8::Context::Scope scope(context);
*listenersArray = protocol::Array<protocol::DOMDebugger::EventListener>::create();
- eventListeners(context, value, objectGroup, listenersArray->get());
+ eventListeners(context, value, toCoreString(std::move(objectGroup)), listenersArray->get());
}
-void InspectorDOMDebuggerAgent::eventListeners(v8::Local<v8::Context> context, v8::Local<v8::Value> object, const String16& objectGroup, protocol::Array<protocol::DOMDebugger::EventListener>* listenersArray)
+void InspectorDOMDebuggerAgent::eventListeners(v8::Local<v8::Context> context, v8::Local<v8::Value> object, const String& objectGroup, protocol::Array<protocol::DOMDebugger::EventListener>* listenersArray)
{
V8EventListenerInfoList eventInformation;
InspectorDOMDebuggerAgent::eventListenersInfoForTarget(context->GetIsolate(), object, eventInformation);
@@ -439,7 +437,7 @@ void InspectorDOMDebuggerAgent::eventListeners(v8::Local<v8::Context> context, v
}
}
-std::unique_ptr<protocol::DOMDebugger::EventListener> InspectorDOMDebuggerAgent::buildObjectForEventListener(v8::Local<v8::Context> context, const V8EventListenerInfo& info, const String16& objectGroupId)
+std::unique_ptr<protocol::DOMDebugger::EventListener> InspectorDOMDebuggerAgent::buildObjectForEventListener(v8::Local<v8::Context> context, const V8EventListenerInfo& info, const String& objectGroupId)
caseq 2016/08/22 23:46:10 Actually, it looks like we never use the fact that
dgozman 2016/08/24 00:45:00 Nice catch! Changed to passing StringBuffer around
{
if (info.handler.IsEmpty())
return nullptr;
@@ -462,11 +460,12 @@ std::unique_ptr<protocol::DOMDebugger::EventListener> InspectorDOMDebuggerAgent:
.setLineNumber(lineNumber)
.setColumnNumber(columnNumber).build();
if (!objectGroupId.isEmpty()) {
- value->setHandler(m_v8Session->wrapObject(context, function, objectGroupId));
- value->setOriginalHandler(m_v8Session->wrapObject(context, info.handler, objectGroupId));
+ v8_inspector::StringView objectGroup = toV8InspectorStringView(objectGroupId);
+ value->setHandler(m_v8Session->wrapObject(context, function, objectGroup));
+ value->setOriginalHandler(m_v8Session->wrapObject(context, info.handler, objectGroup));
v8::Local<v8::Function> removeFunction;
if (info.removeFunction.ToLocal(&removeFunction))
- value->setRemoveFunction(m_v8Session->wrapObject(context, removeFunction, objectGroupId));
+ value->setRemoveFunction(m_v8Session->wrapObject(context, removeFunction, objectGroup));
}
return value;
}
@@ -478,40 +477,30 @@ void InspectorDOMDebuggerAgent::allowNativeBreakpoint(const String& breakpointNa
void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent)
{
- if (hasBreakpoint(parent, SubtreeModified)) {
- std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
- descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get());
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::DOM, eventData->toJSONString());
- }
+ if (hasBreakpoint(parent, SubtreeModified))
+ breakProgramOnDOMEvent(parent, SubtreeModified, true);
}
void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node)
{
Node* parentNode = InspectorDOMAgent::innerParentNode(node);
- if (hasBreakpoint(node, NodeRemoved)) {
- std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
- descriptionForDOMEvent(node, NodeRemoved, false, eventData.get());
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::DOM, eventData->toJSONString());
- } else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) {
- std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
- descriptionForDOMEvent(node, SubtreeModified, false, eventData.get());
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::DOM, eventData->toJSONString());
- }
+ if (hasBreakpoint(node, NodeRemoved))
+ breakProgramOnDOMEvent(node, NodeRemoved, false);
+ else if (parentNode && hasBreakpoint(parentNode, SubtreeModified))
+ breakProgramOnDOMEvent(node, SubtreeModified, false);
didRemoveDOMNode(node);
}
void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element, const AtomicString&, const AtomicString&)
{
- if (hasBreakpoint(element, AttributeModified)) {
- std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
- descriptionForDOMEvent(element, AttributeModified, false, eventData.get());
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::DOM, eventData->toJSONString());
- }
+ if (hasBreakpoint(element, AttributeModified))
+ breakProgramOnDOMEvent(element, AttributeModified, false);
}
-void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, protocol::DictionaryValue* description)
+void InspectorDOMDebuggerAgent::breakProgramOnDOMEvent(Node* target, int breakpointType, bool insertion)
{
- ASSERT(hasBreakpoint(target, breakpointType));
+ DCHECK(hasBreakpoint(target, breakpointType));
+ std::unique_ptr<protocol::DictionaryValue> description = protocol::DictionaryValue::create();
caseq 2016/08/22 23:46:10 nit: auto description = ...
Node* breakpointOwner = target;
if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) {
@@ -538,6 +527,8 @@ void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpo
ASSERT(breakpointOwnerNodeId);
description->setInteger("nodeId", breakpointOwnerNodeId);
description->setString("type", domTypeName(breakpointType));
+ String json = description->toJSONString();
+ m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::API::Paused::ReasonEnum::DOM), toV8InspectorStringView(json));
}
bool InspectorDOMDebuggerAgent::hasBreakpoint(Node* node, int type)
@@ -571,10 +562,11 @@ void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(std::unique_ptr<proto
{
if (!eventData)
return;
+ String json = eventData->toJSONString();
if (synchronous)
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::EventListener, eventData->toJSONString());
+ m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::API::Paused::ReasonEnum::EventListener), toV8InspectorStringView(json));
else
- m_v8Session->schedulePauseOnNextStatement(protocol::Debugger::API::Paused::ReasonEnum::EventListener, eventData->toJSONString());
+ m_v8Session->schedulePauseOnNextStatement(toV8InspectorStringView(protocol::Debugger::API::Paused::ReasonEnum::EventListener), toV8InspectorStringView(json));
}
std::unique_ptr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePauseOnNativeEventData(const String& eventName, const String* targetName)
@@ -663,7 +655,7 @@ void InspectorDOMDebuggerAgent::willSendXMLHttpOrFetchNetworkRequest(const Strin
protocol::DictionaryValue* breakpoints = xhrBreakpoints();
for (size_t i = 0; i < breakpoints->size(); ++i) {
auto breakpoint = breakpoints->at(i);
- if (url.contains(breakpoint.first)) {
+ if (url.contains(String(breakpoint.first))) {
esprehn 2016/08/23 17:35:39 This is allocating a string in the loop, contains
dgozman 2016/08/24 00:45:00 breakpoint.first will become WTF::String with the
breakpointURL = breakpoint.first;
break;
}
@@ -676,7 +668,8 @@ void InspectorDOMDebuggerAgent::willSendXMLHttpOrFetchNetworkRequest(const Strin
std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create();
eventData->setString("breakpointURL", breakpointURL);
eventData->setString("url", url);
- m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::XHR, eventData->toJSONString());
+ String json = eventData->toJSONString();
+ m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::API::Paused::ReasonEnum::XHR), toV8InspectorStringView(json));
esprehn 2016/08/23 17:35:39 protocol::Debugger::API::Paused::ReasonEnum::XHR i
dgozman 2016/08/24 00:45:00 Yeah... We can in theory shorten this to v8_inspec
}
void InspectorDOMDebuggerAgent::didAddBreakpoint()

Powered by Google App Engine
This is Rietveld 408576698