diff options
author | pfeldman <pfeldman@chromium.org> | 2016-03-01 14:15:04 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-01 22:16:38 +0000 |
commit | e8903f001fe670d33ee3b34cc43fc8a5cb778509 (patch) | |
tree | 3869317f65644c03e19abd6c1a9122c609924d8e | |
parent | 73db99fcfed89805c5779bb81aa51ca9e272dc2f (diff) | |
download | chromium_src-e8903f001fe670d33ee3b34cc43fc8a5cb778509.zip chromium_src-e8903f001fe670d33ee3b34cc43fc8a5cb778509.tar.gz chromium_src-e8903f001fe670d33ee3b34cc43fc8a5cb778509.tar.bz2 |
DevTools: migrate protocol values from RefPtr to OwnPtr.
BUG=580337
Review URL: https://codereview.chromium.org/1745423002
Cr-Commit-Position: refs/heads/master@{#378575}
62 files changed, 524 insertions, 495 deletions
diff --git a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp index 41c79ab..b80282c 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.cpp @@ -55,7 +55,7 @@ void InspectorAgent::appended(InstrumentingAgents* instrumentingAgents) init(); } -void InspectorAgent::setState(PassRefPtr<protocol::DictionaryValue> state) +void InspectorAgent::setState(protocol::DictionaryValue* state) { m_state = state; } @@ -68,10 +68,10 @@ InspectorAgentRegistry::InspectorAgentRegistry(InstrumentingAgents* instrumentin void InspectorAgentRegistry::append(PassOwnPtrWillBeRawPtr<InspectorAgent> agent) { - ASSERT(m_state->find(agent->name()) == m_state->end()); - RefPtr<protocol::DictionaryValue> agentState = protocol::DictionaryValue::create(); - m_state->setObject(agent->name(), agentState); - agent->setState(agentState); + ASSERT(!m_state->get(agent->name())); + OwnPtr<protocol::DictionaryValue> agentState = protocol::DictionaryValue::create(); + agent->setState(agentState.get()); + m_state->setObject(agent->name(), agentState.release()); agent->appended(m_instrumentingAgents); m_agents.append(agent); } @@ -90,17 +90,18 @@ void InspectorAgentRegistry::clearFrontend() void InspectorAgentRegistry::restore(const String& savedState) { - RefPtr<protocol::Value> state = protocol::parseJSON(savedState); + OwnPtr<protocol::Value> state = protocol::parseJSON(savedState); if (state) - m_state = protocol::DictionaryValue::cast(state); + m_state = protocol::DictionaryValue::cast(state.release()); if (!m_state) m_state = protocol::DictionaryValue::create(); for (size_t i = 0; i < m_agents.size(); i++) { - RefPtr<protocol::DictionaryValue> agentState = m_state->getObject(m_agents[i]->name()); + protocol::DictionaryValue* agentState = m_state->getObject(m_agents[i]->name()); if (!agentState) { - agentState = protocol::DictionaryValue::create(); - m_state->setObject(m_agents[i]->name(), agentState); + OwnPtr<protocol::DictionaryValue> newState = protocol::DictionaryValue::create(); + agentState = newState.get(); + m_state->setObject(m_agents[i]->name(), newState.release()); } m_agents[i]->setState(agentState); } diff --git a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.h b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.h index 9d046df..f04fec3 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorBaseAgent.h @@ -66,14 +66,14 @@ public: virtual void discardAgent() { } virtual void didCommitLoadForLocalFrame(LocalFrame*) { } virtual void flushPendingProtocolNotifications() { } - virtual void setState(PassRefPtr<protocol::DictionaryValue>); + virtual void setState(protocol::DictionaryValue*); String name() const { return m_name; } void appended(InstrumentingAgents*); protected: RawPtrWillBeMember<InstrumentingAgents> m_instrumentingAgents; - RefPtr<protocol::DictionaryValue> m_state; + protocol::DictionaryValue* m_state; private: String m_name; @@ -99,7 +99,7 @@ public: private: RawPtrWillBeMember<InstrumentingAgents> m_instrumentingAgents; - RefPtr<protocol::DictionaryValue> m_state; + OwnPtr<protocol::DictionaryValue> m_state; WillBeHeapVector<OwnPtrWillBeMember<InspectorAgent>> m_agents; }; diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp index 1c75b35..cbec39b 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp @@ -2042,7 +2042,7 @@ void InspectorDOMAgent::getRelayoutBoundary(ErrorString* errorString, int nodeId *relayoutBoundaryNodeId = pushNodePathToFrontend(resultNode); } -void InspectorDOMAgent::getHighlightObjectForTest(ErrorString* errorString, int nodeId, RefPtr<protocol::DictionaryValue>* result) +void InspectorDOMAgent::getHighlightObjectForTest(ErrorString* errorString, int nodeId, OwnPtr<protocol::DictionaryValue>* result) { Node* node = assertNode(errorString, nodeId); if (!node) diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.h b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.h index 4749ef5..a3cf2f1 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.h @@ -153,7 +153,7 @@ public: void getBoxModel(ErrorString*, int nodeId, OwnPtr<protocol::DOM::BoxModel>*) override; void getNodeForLocation(ErrorString*, int x, int y, int* outNodeId) override; void getRelayoutBoundary(ErrorString*, int nodeId, int* outNodeId) override; - void getHighlightObjectForTest(ErrorString*, int nodeId, RefPtr<protocol::DictionaryValue>* highlight) override; + void getHighlightObjectForTest(ErrorString*, int nodeId, OwnPtr<protocol::DictionaryValue>* highlight) override; bool enabled() const; void releaseDanglingNodes(); diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp index 997af57..277bfbe 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp @@ -179,33 +179,36 @@ void InspectorDOMDebuggerAgent::setInstrumentationBreakpoint(ErrorString* error, setBreakpoint(error, String(instrumentationEventCategoryType) + eventName, String()); } -static PassRefPtr<protocol::DictionaryValue> ensurePropertyObject(PassRefPtr<protocol::DictionaryValue> object, const String& propertyName) +static protocol::DictionaryValue* ensurePropertyObject(protocol::DictionaryValue* object, const String& propertyName) { - protocol::DictionaryValue::iterator it = object->find(propertyName); - if (it != object->end()) - return protocol::DictionaryValue::cast(it->value); + protocol::Value* value = object->get(propertyName); + if (value) + return protocol::DictionaryValue::cast(value); - RefPtr<protocol::DictionaryValue> result = protocol::DictionaryValue::create(); - object->setObject(propertyName, result); - return result.release(); + OwnPtr<protocol::DictionaryValue> newResult = protocol::DictionaryValue::create(); + protocol::DictionaryValue* result = newResult.get(); + object->setObject(propertyName, newResult.release()); + return result; } -PassRefPtr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::eventListenerBreakpoints() +protocol::DictionaryValue* InspectorDOMDebuggerAgent::eventListenerBreakpoints() { - RefPtr<protocol::DictionaryValue> breakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints); + protocol::DictionaryValue* breakpoints = m_state->getObject(DOMDebuggerAgentState::eventListenerBreakpoints); if (!breakpoints) { - breakpoints = protocol::DictionaryValue::create(); - m_state->setObject(DOMDebuggerAgentState::eventListenerBreakpoints, breakpoints); + OwnPtr<protocol::DictionaryValue> newBreakpoints = protocol::DictionaryValue::create(); + breakpoints = newBreakpoints.get(); + m_state->setObject(DOMDebuggerAgentState::eventListenerBreakpoints, newBreakpoints.release()); } return breakpoints; } -PassRefPtr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::xhrBreakpoints() +protocol::DictionaryValue* InspectorDOMDebuggerAgent::xhrBreakpoints() { - RefPtr<protocol::DictionaryValue> breakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints); + protocol::DictionaryValue* breakpoints = m_state->getObject(DOMDebuggerAgentState::xhrBreakpoints); if (!breakpoints) { - breakpoints = protocol::DictionaryValue::create(); - m_state->setObject(DOMDebuggerAgentState::xhrBreakpoints, breakpoints); + OwnPtr<protocol::DictionaryValue> newBreakpoints = protocol::DictionaryValue::create(); + breakpoints = newBreakpoints.get(); + m_state->setObject(DOMDebuggerAgentState::xhrBreakpoints, newBreakpoints.release()); } return breakpoints; } @@ -217,7 +220,7 @@ void InspectorDOMDebuggerAgent::setBreakpoint(ErrorString* error, const String& return; } - RefPtr<protocol::DictionaryValue> breakpointsByTarget = ensurePropertyObject(eventListenerBreakpoints(), eventName); + protocol::DictionaryValue* breakpointsByTarget = ensurePropertyObject(eventListenerBreakpoints(), eventName); if (targetName.isEmpty()) breakpointsByTarget->setBoolean(DOMDebuggerAgentState::eventTargetAny, true); else @@ -242,7 +245,7 @@ void InspectorDOMDebuggerAgent::removeBreakpoint(ErrorString* error, const Strin return; } - RefPtr<protocol::DictionaryValue> breakpointsByTarget = ensurePropertyObject(eventListenerBreakpoints(), eventName); + protocol::DictionaryValue* breakpointsByTarget = ensurePropertyObject(eventListenerBreakpoints(), eventName); if (targetName.isEmpty()) breakpointsByTarget->remove(DOMDebuggerAgentState::eventTargetAny); else @@ -253,7 +256,7 @@ void InspectorDOMDebuggerAgent::removeBreakpoint(ErrorString* error, const Strin void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node) { if (hasBreakpoint(node, AttributeModified)) { - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); descriptionForDOMEvent(node, AttributeModified, false, eventData.get()); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, eventData.release()); } @@ -423,7 +426,7 @@ PassOwnPtr<protocol::DOMDebugger::EventListener> InspectorDOMDebuggerAgent::buil void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent) { if (hasBreakpoint(parent, SubtreeModified)) { - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get()); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, eventData.release()); } @@ -433,11 +436,11 @@ void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node) { Node* parentNode = InspectorDOMAgent::innerParentNode(node); if (hasBreakpoint(node, NodeRemoved)) { - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); descriptionForDOMEvent(node, NodeRemoved, false, eventData.get()); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, eventData.release()); } else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) { - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); descriptionForDOMEvent(node, SubtreeModified, false, eventData.get()); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, eventData.release()); } @@ -447,7 +450,7 @@ void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node) void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element, const AtomicString&, const AtomicString&) { if (hasBreakpoint(element, AttributeModified)) { - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); descriptionForDOMEvent(element, AttributeModified, false, eventData.get()); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, eventData.release()); } @@ -517,7 +520,7 @@ void InspectorDOMDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_t ro updateSubtreeBreakpoints(child, newRootMask, set); } -void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(PassRefPtr<protocol::DictionaryValue> eventData, bool synchronous) +void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(PassOwnPtr<protocol::DictionaryValue> eventData, bool synchronous) { if (!eventData) return; @@ -529,22 +532,22 @@ void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(PassRefPtr<protocol:: m_debuggerAgent->schedulePauseOnNextStatement(protocol::Debugger::Paused::ReasonEnum::EventListener, eventData); } -PassRefPtr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePauseOnNativeEventData(const String& eventName, const String* targetName) +PassOwnPtr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePauseOnNativeEventData(const String& eventName, const String* targetName) { String fullEventName = (targetName ? listenerEventCategoryType : instrumentationEventCategoryType) + eventName; - RefPtr<protocol::DictionaryValue> breakpoints = eventListenerBreakpoints(); - protocol::DictionaryValue::iterator it = breakpoints->find(fullEventName); - if (it == breakpoints->end()) + protocol::DictionaryValue* breakpoints = eventListenerBreakpoints(); + protocol::Value* value = breakpoints->get(fullEventName); + if (!value) return nullptr; bool match = false; - RefPtr<protocol::DictionaryValue> breakpointsByTarget = protocol::DictionaryValue::cast(it->value); + protocol::DictionaryValue* breakpointsByTarget = protocol::DictionaryValue::cast(value); breakpointsByTarget->getBoolean(DOMDebuggerAgentState::eventTargetAny, &match); if (!match && targetName) breakpointsByTarget->getBoolean(targetName->lower(), &match); if (!match) return nullptr; - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); eventData->setString("eventName", fullEventName); if (targetName) eventData->setString("targetName", *targetName); @@ -610,7 +613,7 @@ void InspectorDOMDebuggerAgent::willCloseWindow() void InspectorDOMDebuggerAgent::didFireWebGLError(const String& errorName) { - RefPtr<protocol::DictionaryValue> eventData = preparePauseOnNativeEventData(webglErrorFiredEventName, 0); + OwnPtr<protocol::DictionaryValue> eventData = preparePauseOnNativeEventData(webglErrorFiredEventName, 0); if (!eventData) return; if (!errorName.isEmpty()) @@ -668,7 +671,7 @@ void InspectorDOMDebuggerAgent::willSendXMLHttpRequest(const String& url) if (!m_debuggerAgent->enabled()) return; - RefPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> eventData = protocol::DictionaryValue::create(); eventData->setString("breakpointURL", breakpointURL); eventData->setString("url", url); m_debuggerAgent->breakProgram(protocol::Debugger::Paused::ReasonEnum::XHR, eventData.release()); @@ -681,7 +684,7 @@ void InspectorDOMDebuggerAgent::didAddBreakpoint() setEnabled(true); } -static bool isEmpty(PassRefPtr<protocol::DictionaryValue> object) +static bool isEmpty(const protocol::DictionaryValue* object) { return object->begin() == object->end(); } diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.h b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.h index 63ce0fa..11b7fba 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.h @@ -110,11 +110,11 @@ public: private: InspectorDOMDebuggerAgent(v8::Isolate*, InspectorDOMAgent*, V8RuntimeAgent*, V8DebuggerAgent*); - void pauseOnNativeEventIfNeeded(PassRefPtr<protocol::DictionaryValue> eventData, bool synchronous); - PassRefPtr<protocol::DictionaryValue> preparePauseOnNativeEventData(const String& eventName, const String* targetName); + void pauseOnNativeEventIfNeeded(PassOwnPtr<protocol::DictionaryValue> eventData, bool synchronous); + PassOwnPtr<protocol::DictionaryValue> preparePauseOnNativeEventData(const String& eventName, const String* targetName); - PassRefPtr<protocol::DictionaryValue> eventListenerBreakpoints(); - PassRefPtr<protocol::DictionaryValue> xhrBreakpoints(); + protocol::DictionaryValue* eventListenerBreakpoints(); + protocol::DictionaryValue* xhrBreakpoints(); void descriptionForDOMEvent(Node* target, int breakpointType, bool insertion, protocol::DictionaryValue* description); void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set); diff --git a/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.cpp index 008dd3e..014e819 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.cpp @@ -318,7 +318,7 @@ bool InspectorDebuggerAgent::isPaused() void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText) { - RefPtr<protocol::DictionaryValue> directive = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> directive = protocol::DictionaryValue::create(); directive->setString("directiveText", directiveText); m_v8DebuggerAgent->breakProgramOnException(protocol::Debugger::Paused::ReasonEnum::CSPViolation, directive.release()); } @@ -334,7 +334,7 @@ void InspectorDebuggerAgent::didExecuteScript() } // InspectorBaseAgent overrides. -void InspectorDebuggerAgent::setState(PassRefPtr<protocol::DictionaryValue> state) +void InspectorDebuggerAgent::setState(protocol::DictionaryValue* state) { InspectorBaseAgent::setState(state); m_v8DebuggerAgent->setInspectorState(m_state); diff --git a/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.h b/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.h index 5595230..0f68435 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorDebuggerAgent.h @@ -89,7 +89,7 @@ public: void didExecuteScript(); // InspectorBaseAgent overrides. - void setState(PassRefPtr<protocol::DictionaryValue>) override; + void setState(protocol::DictionaryValue*) override; void init() override; void setFrontend(protocol::Frontend*) override; void clearFrontend() override; diff --git a/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.cpp index 67513c2..ffc6972d 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.cpp @@ -89,7 +89,7 @@ InspectorHeapProfilerAgent::~InspectorHeapProfilerAgent() } // InspectorBaseAgent overrides. -void InspectorHeapProfilerAgent::setState(PassRefPtr<protocol::DictionaryValue> state) +void InspectorHeapProfilerAgent::setState(protocol::DictionaryValue* state) { InspectorBaseAgent::setState(state); m_v8HeapProfilerAgent->setInspectorState(m_state); diff --git a/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.h b/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.h index 095c435..eb5dec1 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.h @@ -57,7 +57,7 @@ public: ~InspectorHeapProfilerAgent() override; // InspectorBaseAgent overrides. - void setState(PassRefPtr<protocol::DictionaryValue>) override; + void setState(protocol::DictionaryValue*) override; void setFrontend(protocol::Frontend*) override; void clearFrontend() override; void restore() override; diff --git a/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp b/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp index 1a0bb64..b587656 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorHighlight.cpp @@ -25,7 +25,7 @@ public: PathBuilder() : m_path(protocol::ListValue::create()) { } virtual ~PathBuilder() { } - PassRefPtr<protocol::ListValue> path() const { return m_path; } + PassOwnPtr<protocol::ListValue> release() { return m_path.release(); } void appendPath(const Path& path) { @@ -44,7 +44,7 @@ private: void appendPathElement(const PathElement*); void appendPathCommandAndPoints(const char* command, const FloatPoint points[], size_t length); - RefPtr<protocol::ListValue> m_path; + OwnPtr<protocol::ListValue> m_path; }; void PathBuilder::appendPathCommandAndPoints(const char* command, const FloatPoint points[], size_t length) @@ -90,11 +90,11 @@ public: , m_layoutObject(layoutObject) , m_shapeOutsideInfo(shapeOutsideInfo) { } - static RefPtr<protocol::ListValue> buildPath(FrameView& view, LayoutObject& layoutObject, const ShapeOutsideInfo& shapeOutsideInfo, const Path& path) + static PassOwnPtr<protocol::ListValue> buildPath(FrameView& view, LayoutObject& layoutObject, const ShapeOutsideInfo& shapeOutsideInfo, const Path& path) { ShapePathBuilder builder(view, layoutObject, shapeOutsideInfo); builder.appendPath(path); - return builder.path(); + return builder.release(); } protected: @@ -163,9 +163,9 @@ const ShapeOutsideInfo* shapeOutsideInfoForNode(Node* node, Shape::DisplayPaths* return shapeOutsideInfo; } -PassRefPtr<protocol::DictionaryValue> buildElementInfo(Element* element) +PassOwnPtr<protocol::DictionaryValue> buildElementInfo(Element* element) { - RefPtr<protocol::DictionaryValue> elementInfo = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> elementInfo = protocol::DictionaryValue::create(); Element* realElement = element; PseudoElement* pseudoElement = nullptr; if (element->isPseudoElement()) { @@ -200,7 +200,7 @@ PassRefPtr<protocol::DictionaryValue> buildElementInfo(Element* element) LayoutObject* layoutObject = element->layoutObject(); FrameView* containingView = element->document().view(); if (!layoutObject || !containingView) - return elementInfo; + return elementInfo.release(); // layoutObject the getBoundingClientRect() data in the tooltip // to be consistent with the rulers (see http://crbug.com/262338). @@ -208,7 +208,7 @@ PassRefPtr<protocol::DictionaryValue> buildElementInfo(Element* element) elementInfo->setString("nodeWidth", String::number(boundingBox->width())); elementInfo->setString("nodeHeight", String::number(boundingBox->height())); - return elementInfo; + return elementInfo.release(); } } // namespace @@ -250,12 +250,12 @@ void InspectorHighlight::appendQuad(const FloatQuad& quad, const Color& fillColo Path path = quadToPath(quad); PathBuilder builder; builder.appendPath(path); - appendPath(builder.path(), fillColor, outlineColor, name); + appendPath(builder.release(), fillColor, outlineColor, name); } -void InspectorHighlight::appendPath(PassRefPtr<protocol::ListValue> path, const Color& fillColor, const Color& outlineColor, const String& name) +void InspectorHighlight::appendPath(PassOwnPtr<protocol::ListValue> path, const Color& fillColor, const Color& outlineColor, const String& name) { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); object->setValue("path", path); object->setString("fillColor", fillColor.serialized()); if (outlineColor != Color::transparent) @@ -321,14 +321,14 @@ void InspectorHighlight::appendNodeHighlight(Node* node, const InspectorHighligh appendQuad(margin, highlightConfig.margin, Color::transparent, "margin"); } -PassRefPtr<protocol::DictionaryValue> InspectorHighlight::asProtocolValue() const +PassOwnPtr<protocol::DictionaryValue> InspectorHighlight::asProtocolValue() const { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); - object->setArray("paths", m_highlightPaths); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + object->setValue("paths", m_highlightPaths->clone()); object->setBoolean("showRulers", m_showRulers); object->setBoolean("showExtensionLines", m_showExtensionLines); if (m_elementInfo) - object->setObject("elementInfo", m_elementInfo); + object->setValue("elementInfo", m_elementInfo->clone()); object->setBoolean("displayAsMaterial", m_displayAsMaterial); return object.release(); } @@ -362,8 +362,8 @@ bool InspectorHighlight::getBoxModel(Node* node, OwnPtr<protocol::DOM::BoxModel> if (const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &paths, &boundsQuad)) { (*model)->setShapeOutside(protocol::DOM::ShapeOutsideInfo::create() .setBounds(buildArrayForQuad(boundsQuad)) - .setShape(protocol::Array<RefPtr<protocol::Value>>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.shape), &errors)) - .setMarginShape(protocol::Array<RefPtr<protocol::Value>>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.marginShape), &errors)) + .setShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.shape).get(), &errors)) + .setMarginShape(protocol::Array<protocol::Value>::parse(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.marginShape).get(), &errors)) .build()); } diff --git a/third_party/WebKit/Source/core/inspector/InspectorHighlight.h b/third_party/WebKit/Source/core/inspector/InspectorHighlight.h index b5251f7..61e657f 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorHighlight.h +++ b/third_party/WebKit/Source/core/inspector/InspectorHighlight.h @@ -53,17 +53,17 @@ public: static InspectorHighlightConfig defaultConfig(); static bool buildNodeQuads(Node*, FloatQuad* content, FloatQuad* padding, FloatQuad* border, FloatQuad* margin); - void appendPath(PassRefPtr<protocol::ListValue> path, const Color& fillColor, const Color& outlineColor, const String& name = String()); + void appendPath(PassOwnPtr<protocol::ListValue> path, const Color& fillColor, const Color& outlineColor, const String& name = String()); void appendQuad(const FloatQuad&, const Color& fillColor, const Color& outlineColor = Color::transparent, const String& name = String()); void appendEventTargetQuads(Node* eventTargetNode, const InspectorHighlightConfig&); - PassRefPtr<protocol::DictionaryValue> asProtocolValue() const; + PassOwnPtr<protocol::DictionaryValue> asProtocolValue() const; private: void appendNodeHighlight(Node*, const InspectorHighlightConfig&); void appendPathsForShapeOutside(Node*, const InspectorHighlightConfig&); - RefPtr<protocol::DictionaryValue> m_elementInfo; - RefPtr<protocol::ListValue> m_highlightPaths; + OwnPtr<protocol::DictionaryValue> m_elementInfo; + OwnPtr<protocol::ListValue> m_highlightPaths; bool m_showRulers; bool m_showExtensionLines; bool m_displayAsMaterial; diff --git a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp index 6930281..c5e0a62 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.cpp @@ -86,7 +86,7 @@ void InspectorInspectorAgent::evaluateForTestInFrontend(long callId, const Strin } } -void InspectorInspectorAgent::inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassRefPtr<protocol::DictionaryValue> hints) +void InspectorInspectorAgent::inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassOwnPtr<protocol::DictionaryValue> hints) { if (frontend() && m_state->booleanProperty(InspectorAgentState::inspectorAgentEnabled, false)) frontend()->inspect(objectToInspect, hints); diff --git a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h index d60b115..555e944 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorInspectorAgent.h @@ -65,7 +65,7 @@ public: // Generic code called from custom implementations. void evaluateForTestInFrontend(long testCallId, const String& script); - void inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassRefPtr<protocol::DictionaryValue> hints); + void inspect(PassOwnPtr<protocol::Runtime::RemoteObject> objectToInspect, PassOwnPtr<protocol::DictionaryValue> hints); private: InspectorInspectorAgent(); diff --git a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp index dd93783..44f1e4b 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp @@ -435,14 +435,14 @@ void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const St } } -void InspectorLayerTreeAgent::snapshotCommandLog(ErrorString* errorString, const String& snapshotId, OwnPtr<Array<RefPtr<protocol::DictionaryValue>>>* commandLog) +void InspectorLayerTreeAgent::snapshotCommandLog(ErrorString* errorString, const String& snapshotId, OwnPtr<Array<protocol::DictionaryValue>>* commandLog) { const PictureSnapshot* snapshot = snapshotById(errorString, snapshotId); if (!snapshot) return; protocol::ErrorSupport errors(errorString); - RefPtr<protocol::Value> logValue = protocol::parseJSON(snapshot->snapshotCommandLog()->toJSONString()); - *commandLog = Array<RefPtr<protocol::DictionaryValue>>::parse(logValue, &errors); + OwnPtr<protocol::Value> logValue = protocol::parseJSON(snapshot->snapshotCommandLog()->toJSONString()); + *commandLog = Array<protocol::DictionaryValue>::parse(logValue.get(), &errors); } void InspectorLayerTreeAgent::willAddPageOverlay(const GraphicsLayer* layer) diff --git a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.h b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.h index 5b8e593..09ccecc8 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.h @@ -81,7 +81,7 @@ public: void releaseSnapshot(ErrorString*, const String& snapshotId) override; void profileSnapshot(ErrorString*, const String& snapshotId, const Maybe<int>& minRepeatCount, const Maybe<double>& minDuration, const Maybe<protocol::DOM::Rect>& clipRect, OwnPtr<protocol::Array<protocol::Array<double>>>* timings) override; void replaySnapshot(ErrorString*, const String& snapshotId, const Maybe<int>& fromStep, const Maybe<int>& toStep, const Maybe<double>& scale, String* dataURL) override; - void snapshotCommandLog(ErrorString*, const String& snapshotId, OwnPtr<protocol::Array<RefPtr<protocol::DictionaryValue>>>* commandLog) override; + void snapshotCommandLog(ErrorString*, const String& snapshotId, OwnPtr<protocol::Array<protocol::DictionaryValue>>* commandLog) override; // Called by other agents. PassOwnPtr<protocol::Array<protocol::LayerTree::Layer>> buildLayerTree(); diff --git a/third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp index 07a473e..d0fb0d4 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp @@ -388,23 +388,24 @@ void InspectorPageAgent::disable(ErrorString*) void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& source, String* identifier) { - RefPtr<protocol::DictionaryValue> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); + protocol::DictionaryValue* scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); if (!scripts) { - scripts = protocol::DictionaryValue::create(); - m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, scripts); + OwnPtr<protocol::DictionaryValue> newScripts = protocol::DictionaryValue::create(); + scripts = newScripts.get(); + m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, newScripts.release()); } // Assure we don't override existing ids -- m_lastScriptIdentifier could get out of sync WRT actual // scripts once we restored the scripts from the cookie during navigation. do { *identifier = String::number(++m_lastScriptIdentifier); - } while (scripts->find(*identifier) != scripts->end()); + } while (scripts->get(*identifier)); scripts->setString(*identifier, source); } void InspectorPageAgent::removeScriptToEvaluateOnLoad(ErrorString* error, const String& identifier) { - RefPtr<protocol::DictionaryValue> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); - if (!scripts || scripts->find(identifier) == scripts->end()) { + protocol::DictionaryValue* scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); + if (!scripts || !scripts->get(identifier)) { *error = "Script not found"; return; } @@ -589,7 +590,7 @@ void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) if (!frontend()) return; - RefPtr<protocol::DictionaryValue> scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); + protocol::DictionaryValue* scripts = m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); if (scripts) { for (const auto& script : *scripts) { String scriptText; diff --git a/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.cpp index a719bb1..fefd936 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.cpp @@ -58,7 +58,7 @@ InspectorProfilerAgent::~InspectorProfilerAgent() } // InspectorBaseAgent overrides. -void InspectorProfilerAgent::setState(PassRefPtr<protocol::DictionaryValue> state) +void InspectorProfilerAgent::setState(protocol::DictionaryValue* state) { InspectorBaseAgent::setState(state); m_v8ProfilerAgent->setInspectorState(m_state); diff --git a/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.h b/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.h index 32d29ae..905776f 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorProfilerAgent.h @@ -62,7 +62,7 @@ public: DECLARE_VIRTUAL_TRACE(); // InspectorBaseAgent overrides. - void setState(PassRefPtr<protocol::DictionaryValue>) override; + void setState(protocol::DictionaryValue*) override; void setFrontend(protocol::Frontend*) override; void clearFrontend() override; void restore() override; diff --git a/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp index 6f067e3..e1d6058 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorResourceAgent.cpp @@ -111,11 +111,11 @@ bool matches(const String& url, const String& pattern) static PassOwnPtr<protocol::Network::Headers> buildObjectForHeaders(const HTTPHeaderMap& headers) { - RefPtr<protocol::DictionaryValue> headersObject = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> headersObject = protocol::DictionaryValue::create(); for (const auto& header : headers) headersObject->setString(header.key.string(), header.value); protocol::ErrorSupport errors; - return protocol::Network::Headers::parse(headersObject, &errors); + return protocol::Network::Headers::parse(headersObject.get(), &errors); } class InspectorFileReaderLoaderClient final : public FileReaderLoaderClient { @@ -300,7 +300,6 @@ static PassOwnPtr<protocol::Network::Response> buildObjectForResourceResponse(co status = response.httpStatusCode(); statusText = response.httpStatusText(); } - RefPtr<protocol::DictionaryValue> headers; HTTPHeaderMap headersMap; if (response.resourceLoadInfo() && response.resourceLoadInfo()->responseHeaders.size()) headersMap = response.resourceLoadInfo()->responseHeaders; @@ -439,7 +438,7 @@ DEFINE_TRACE(InspectorResourceAgent) bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) { - RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); + protocol::DictionaryValue* blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); if (!blockedURLs) return false; String url = request.url().string(); @@ -502,7 +501,7 @@ void InspectorResourceAgent::willSendRequest(LocalFrame* frame, unsigned long id if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->substituteData().isValid()) return; - RefPtr<protocol::DictionaryValue> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders); + protocol::DictionaryValue* headers = m_state->getObject(ResourceAgentState::extraRequestHeaders); if (headers) { for (const auto& header : *headers) { String value; @@ -967,17 +966,18 @@ void InspectorResourceAgent::getResponseBody(ErrorString* errorString, const Str void InspectorResourceAgent::addBlockedURL(ErrorString*, const String& url) { - RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); + protocol::DictionaryValue* blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); if (!blockedURLs) { - blockedURLs = protocol::DictionaryValue::create(); - m_state->setObject(ResourceAgentState::blockedURLs, blockedURLs); + OwnPtr<protocol::DictionaryValue> newList = protocol::DictionaryValue::create(); + blockedURLs = newList.get(); + m_state->setObject(ResourceAgentState::blockedURLs, newList.release()); } blockedURLs->setBoolean(url, true); } void InspectorResourceAgent::removeBlockedURL(ErrorString*, const String& url) { - RefPtr<protocol::DictionaryValue> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); + protocol::DictionaryValue* blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); if (blockedURLs) blockedURLs->remove(url); } diff --git a/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.cpp index 9ee8e1a..e5c7859 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.cpp @@ -56,7 +56,7 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent() } // InspectorBaseAgent overrides. -void InspectorRuntimeAgent::setState(PassRefPtr<protocol::DictionaryValue> state) +void InspectorRuntimeAgent::setState(protocol::DictionaryValue* state) { InspectorBaseAgent::setState(state); m_v8RuntimeAgent->setInspectorState(m_state); diff --git a/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.h b/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.h index d2ce4bd..035c7dc 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.h +++ b/third_party/WebKit/Source/core/inspector/InspectorRuntimeAgent.h @@ -69,7 +69,7 @@ public: ~InspectorRuntimeAgent() override; // InspectorBaseAgent overrides. - void setState(PassRefPtr<protocol::DictionaryValue>) override; + void setState(protocol::DictionaryValue*) override; void setFrontend(protocol::Frontend*) override; void clearFrontend() override; void restore() override; diff --git a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp index 640a958..2bf8679 100644 --- a/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp +++ b/third_party/WebKit/Source/core/inspector/LayoutEditor.cpp @@ -27,26 +27,26 @@ namespace blink { namespace { -PassRefPtr<protocol::DictionaryValue> createAnchor(const String& type, const String& propertyName, PassRefPtr<protocol::DictionaryValue> valueDescription) +PassOwnPtr<protocol::DictionaryValue> createAnchor(const String& type, const String& propertyName, PassOwnPtr<protocol::DictionaryValue> valueDescription) { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); object->setString("type", type); object->setString("propertyName", propertyName); object->setObject("propertyValue", valueDescription); return object.release(); } -PassRefPtr<protocol::DictionaryValue> pointToJSON(FloatPoint point) +PassOwnPtr<protocol::DictionaryValue> pointToJSON(FloatPoint point) { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); object->setNumber("x", point.x()); object->setNumber("y", point.y()); return object.release(); } -PassRefPtr<protocol::DictionaryValue> quadToJSON(FloatQuad& quad) +PassOwnPtr<protocol::DictionaryValue> quadToJSON(FloatQuad& quad) { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); object->setObject("p1", pointToJSON(quad.p1())); object->setObject("p2", pointToJSON(quad.p2())); object->setObject("p3", pointToJSON(quad.p3())); @@ -165,8 +165,8 @@ DEFINE_TRACE(LayoutEditor) void LayoutEditor::rebuild() { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); - RefPtr<protocol::ListValue> anchors = protocol::ListValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::ListValue> anchors = protocol::ListValue::create(); appendAnchorFor(anchors.get(), "padding", "padding-top"); appendAnchorFor(anchors.get(), "padding", "padding-right"); @@ -255,13 +255,13 @@ bool LayoutEditor::growInside(String propertyName, CSSPrimitiveValue* value) return false; } -PassRefPtr<protocol::DictionaryValue> LayoutEditor::createValueDescription(const String& propertyName) +PassOwnPtr<protocol::DictionaryValue> LayoutEditor::createValueDescription(const String& propertyName) { RefPtrWillBeRawPtr<CSSPrimitiveValue> cssValue = getPropertyCSSValue(cssPropertyID(propertyName)); if (cssValue && !(cssValue->isLength() || cssValue->isPercentage())) return nullptr; - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); object->setNumber("value", cssValue ? cssValue->getFloatValue() : 0); CSSPrimitiveValue::UnitType unitType = cssValue ? cssValue->typeWithCalcResolved() : CSSPrimitiveValue::UnitType::Pixels; object->setString("unit", CSSPrimitiveValue::unitTypeToString(unitType)); @@ -276,7 +276,7 @@ PassRefPtr<protocol::DictionaryValue> LayoutEditor::createValueDescription(const void LayoutEditor::appendAnchorFor(protocol::ListValue* anchors, const String& type, const String& propertyName) { - RefPtr<protocol::DictionaryValue> description = createValueDescription(propertyName); + OwnPtr<protocol::DictionaryValue> description = createValueDescription(propertyName); if (description) anchors->pushValue(createAnchor(type, propertyName, description.release())); } @@ -366,9 +366,9 @@ void LayoutEditor::editableSelectorUpdated(bool hasChanged) const m_cssAgent->layoutEditorItemSelected(m_element.get(), style); } -PassRefPtr<protocol::DictionaryValue> LayoutEditor::currentSelectorInfo(CSSStyleDeclaration* style) const +PassOwnPtr<protocol::DictionaryValue> LayoutEditor::currentSelectorInfo(CSSStyleDeclaration* style) const { - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::create(); CSSStyleRule* rule = style->parentRule() ? toCSSStyleRule(style->parentRule()) : nullptr; String currentSelectorText = rule ? rule->selectorText() : "element.style"; object->setString("selector", currentSelectorText); @@ -379,7 +379,7 @@ PassRefPtr<protocol::DictionaryValue> LayoutEditor::currentSelectorInfo(CSSStyle Vector<String> medias; buildMediaListChain(rule, medias); - RefPtr<protocol::ListValue> mediaListValue = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> mediaListValue = protocol::ListValue::create(); for (size_t i = 0; i < medias.size(); ++i) mediaListValue->pushValue(protocol::StringValue::create(medias[i])); @@ -391,7 +391,7 @@ PassRefPtr<protocol::DictionaryValue> LayoutEditor::currentSelectorInfo(CSSStyle if (!elements || exceptionState.hadException()) return object.release(); - RefPtr<protocol::ListValue> highlights = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> highlights = protocol::ListValue::create(); InspectorHighlightConfig config = affectedNodesHighlightConfig(); for (unsigned i = 0; i < elements->length(); ++i) { Element* element = elements->item(i); @@ -413,10 +413,10 @@ bool LayoutEditor::setCSSPropertyValueInCurrentRule(const String& value) return errorString.isEmpty(); } -void LayoutEditor::evaluateInOverlay(const String& method, PassRefPtr<protocol::Value> argument) const +void LayoutEditor::evaluateInOverlay(const String& method, PassOwnPtr<protocol::Value> argument) const { ScriptForbiddenScope::AllowUserAgentScript allowScript; - RefPtr<protocol::ListValue> command = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> command = protocol::ListValue::create(); command->pushValue(protocol::StringValue::create(method)); command->pushValue(argument); m_scriptController->executeScriptInMainWorld("dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisabled); diff --git a/third_party/WebKit/Source/core/inspector/LayoutEditor.h b/third_party/WebKit/Source/core/inspector/LayoutEditor.h index 32dc360..279d7fe 100644 --- a/third_party/WebKit/Source/core/inspector/LayoutEditor.h +++ b/third_party/WebKit/Source/core/inspector/LayoutEditor.h @@ -47,12 +47,12 @@ public: private: LayoutEditor(Element*, InspectorCSSAgent*, InspectorDOMAgent*, ScriptController*); RefPtrWillBeRawPtr<CSSPrimitiveValue> getPropertyCSSValue(CSSPropertyID) const; - PassRefPtr<protocol::DictionaryValue> createValueDescription(const String&); + PassOwnPtr<protocol::DictionaryValue> createValueDescription(const String&); void appendAnchorFor(protocol::ListValue*, const String&, const String&); bool setCSSPropertyValueInCurrentRule(const String&); void editableSelectorUpdated(bool hasChanged) const; - void evaluateInOverlay(const String&, PassRefPtr<protocol::Value>) const; - PassRefPtr<protocol::DictionaryValue> currentSelectorInfo(CSSStyleDeclaration*) const; + void evaluateInOverlay(const String&, PassOwnPtr<protocol::Value>) const; + PassOwnPtr<protocol::DictionaryValue> currentSelectorInfo(CSSStyleDeclaration*) const; bool growInside(String propertyName, CSSPrimitiveValue*); RefPtrWillBeMember<Element> m_element; diff --git a/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp b/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp index 63cb568..314f0da 100644 --- a/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp +++ b/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp @@ -93,12 +93,12 @@ private: { } - void sendProtocolResponse(int sessionId, int callId, PassRefPtr<protocol::DictionaryValue> message) override + void sendProtocolResponse(int sessionId, int callId, PassOwnPtr<protocol::DictionaryValue> message) override { // Worker messages are wrapped, no need to handle callId. m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageInspector(message->toJSONString()); } - void sendProtocolNotification(PassRefPtr<protocol::DictionaryValue> message) override + void sendProtocolNotification(PassOwnPtr<protocol::DictionaryValue> message) override { m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageInspector(message->toJSONString()); } diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp index c6fc10e..43f312c 100644 --- a/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp +++ b/third_party/WebKit/Source/modules/accessibility/InspectorAccessibilityAgent.cpp @@ -256,7 +256,7 @@ PassOwnPtr<AXProperty> createRelatedNodeListProperty(const String& key, AXObject { OwnPtr<AXValue> nodeListValue = createRelatedNodeListValue(nodes); const AtomicString& attrValue = axObject->getAttribute(attr); - nodeListValue->setValue(protocol::StringValue::create(attrValue).get()); + nodeListValue->setValue(protocol::StringValue::create(attrValue)); return createProperty(key, nodeListValue.release()); } diff --git a/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp b/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp index 1085a5b..11fbef5 100644 --- a/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp +++ b/third_party/WebKit/Source/modules/accessibility/InspectorTypeBuilderHelper.cpp @@ -188,7 +188,7 @@ PassOwnPtr<AXValueSource> createValueSource(NameSource& nameSource) if (nameSource.attribute == aria_labelledbyAttr || nameSource.attribute == aria_labeledbyAttr) { OwnPtr<AXValue> attributeValue = createRelatedNodeListValue(nameSource.relatedObjects, AXValueTypeEnum::IdrefList); if (!nameSource.attributeValue.isNull()) - attributeValue->setValue(protocol::StringValue::create(nameSource.attributeValue.string()).get()); + attributeValue->setValue(protocol::StringValue::create(nameSource.attributeValue.string())); valueSource->setAttributeValue(attributeValue.release()); } else if (nameSource.attribute == QualifiedName::null()) { valueSource->setNativeSourceValue(createRelatedNodeListValue(nameSource.relatedObjects, AXValueTypeEnum::NodeList)); diff --git a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp index a944367..2b70960 100644 --- a/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp +++ b/third_party/WebKit/Source/modules/indexeddb/InspectorIndexedDBAgent.cpp @@ -474,9 +474,9 @@ public: const String errorMessage("\"Inspection error. Maximum depth reached?\""); ScriptState* scriptState = m_scriptState.get(); ScriptState::Scope scope(scriptState); - RefPtr<protocol::Value> keyJsonValue = toProtocolValue(scriptState->context(), idbCursor->key(scriptState).v8Value()); - RefPtr<protocol::Value> primaryKeyJsonValue = toProtocolValue(scriptState->context(), idbCursor->primaryKey(scriptState).v8Value()); - RefPtr<protocol::Value> valueJsonValue = toProtocolValue(scriptState->context(), idbCursor->value(scriptState).v8Value()); + OwnPtr<protocol::Value> keyJsonValue = toProtocolValue(scriptState->context(), idbCursor->key(scriptState).v8Value()); + OwnPtr<protocol::Value> primaryKeyJsonValue = toProtocolValue(scriptState->context(), idbCursor->primaryKey(scriptState).v8Value()); + OwnPtr<protocol::Value> valueJsonValue = toProtocolValue(scriptState->context(), idbCursor->value(scriptState).v8Value()); String key = keyJsonValue ? keyJsonValue->toJSONString() : errorMessage; String value = valueJsonValue ? valueJsonValue->toJSONString() : errorMessage; String primaryKey = primaryKeyJsonValue ? primaryKeyJsonValue->toJSONString() : errorMessage; diff --git a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp index 8c86ed6..be950bd 100644 --- a/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp +++ b/third_party/WebKit/Source/modules/webdatabase/InspectorDatabaseAgent.cpp @@ -63,7 +63,7 @@ void reportTransactionFailed(ExecuteSQLCallback* requestCallback, SQLError* erro OwnPtr<protocol::Database::Error> errorObject = protocol::Database::Error::create() .setMessage(error->message()) .setCode(error->code()).build(); - requestCallback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protocol::Array<RefPtr<protocol::Value>>>(), errorObject.release()); + requestCallback->sendSuccess(Maybe<protocol::Array<String>>(), Maybe<protocol::Array<protocol::Value>>(), errorObject.release()); } class StatementCallback final : public SQLStatementCallback { @@ -89,7 +89,7 @@ public: for (size_t i = 0; i < columns.size(); ++i) columnNames->addItem(columns[i]); - OwnPtr<protocol::Array<RefPtr<protocol::Value>>> values = protocol::Array<RefPtr<protocol::Value>>::create(); + OwnPtr<protocol::Array<protocol::Value>> values = protocol::Array<protocol::Value>::create(); const Vector<SQLValue>& data = rowList->values(); for (size_t i = 0; i < data.size(); ++i) { const SQLValue& value = rowList->values()[i]; diff --git a/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py b/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py index 0d0a87a..43c9c56 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py +++ b/third_party/WebKit/Source/platform/inspector_protocol/CodeGenerator.py @@ -115,27 +115,27 @@ def create_user_type_definition(domain_name, type): def create_object_type_definition(): return { - "return_type": "PassRefPtr<protocol::DictionaryValue>", - "pass_type": "PassRefPtr<protocol::DictionaryValue>", - "to_raw_type": "%s", + "return_type": "PassOwnPtr<protocol::DictionaryValue>", + "pass_type": "PassOwnPtr<protocol::DictionaryValue>", + "to_raw_type": "%s.get()", "to_pass_type": "%s.release()", - "type": "RefPtr<protocol::DictionaryValue>", - "raw_type": "RefPtr<protocol::DictionaryValue>", - "raw_pass_type": "PassRefPtr<protocol::DictionaryValue>", - "raw_return_type": "RefPtr<protocol::DictionaryValue>", + "type": "OwnPtr<protocol::DictionaryValue>", + "raw_type": "protocol::DictionaryValue", + "raw_pass_type": "protocol::DictionaryValue*", + "raw_return_type": "protocol::DictionaryValue*", } def create_any_type_definition(): return { - "return_type": "PassRefPtr<protocol::Value>", - "pass_type": "PassRefPtr<protocol::Value>", + "return_type": "PassOwnPtr<protocol::Value>", + "pass_type": "PassOwnPtr<protocol::Value>", + "to_raw_type": "%s.get()", "to_pass_type": "%s.release()", - "to_raw_type": "%s", - "type": "RefPtr<protocol::Value>", - "raw_type": "RefPtr<protocol::Value>", - "raw_pass_type": "PassRefPtr<protocol::Value>", - "raw_return_type": "RefPtr<protocol::Value>", + "type": "OwnPtr<protocol::Value>", + "raw_type": "protocol::Value", + "raw_pass_type": "protocol::Value*", + "raw_return_type": "protocol::Value*", } diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template index d790ca3..0dbad39 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template +++ b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_cpp.template @@ -45,7 +45,7 @@ public: virtual void reportProtocolError(int sessionId, int callId, CommonErrorCode, const String& errorMessage, ErrorSupport* errors) const; using Dispatcher::reportProtocolError; - void sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<protocol::DictionaryValue> result); + void sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassOwnPtr<protocol::DictionaryValue> result); bool isActive() { return m_frontendChannel; } {% for domain in api.domains %} @@ -53,14 +53,14 @@ public: {% endfor %} private: - using CallHandler = void (DispatcherImpl::*)(int sessionId, int callId, DictionaryValue* messageObject, ErrorSupport* errors); + using CallHandler = void (DispatcherImpl::*)(int sessionId, int callId, PassOwnPtr<DictionaryValue> messageObject, ErrorSupport* errors); using DispatchMap = HashMap<String, CallHandler>; {% for domain in api.domains %} {% for command in domain.commands %} {% if "redirect" in command %}{% continue %}{% endif %} {% if "handlers" in command and not ("renderer" in command["handlers"]) %}{% continue %}{% endif %} - void {{domain.domain}}_{{command.name}}(int sessionId, int callId, DictionaryValue* requestMessageObject, ErrorSupport*); + void {{domain.domain}}_{{command.name}}(int sessionId, int callId, PassOwnPtr<DictionaryValue> requestMessageObject, ErrorSupport*); {% endfor %} {% endfor %} @@ -70,7 +70,7 @@ private: {{domain.domain}}CommandHandler* m_{{domain.domain | lower}}Agent; {% endfor %} - void sendResponse(int sessionId, int callId, ErrorString invocationError, PassRefPtr<protocol::DictionaryValue> result) + void sendResponse(int sessionId, int callId, ErrorString invocationError, PassOwnPtr<protocol::DictionaryValue> result) { sendResponse(sessionId, callId, invocationError, nullptr, result); } @@ -105,20 +105,20 @@ void Dispatcher::{{domain.domain}}CommandHandler::{{command.name | to_title_case {%- if not loop.last -%}, {% endif -%} {% endfor %}) { - RefPtr<protocol::DictionaryValue> resultObject = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> resultObject = DictionaryValue::create(); {% for parameter in command.returns %} {% if "optional" in parameter %} if ({{parameter.name}}.isJust()) resultObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust())); {% else %} - resultObject->setValue("{{parameter.name}}", toValue({{parameter.name}})); + resultObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}})); {% endif %} {% endfor %} sendIfActive(resultObject.release(), ErrorString()); } {% endif %} -void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callId, DictionaryValue* requestMessageObject, ErrorSupport* errors) +void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callId, PassOwnPtr<DictionaryValue> requestMessageObject, ErrorSupport* errors) { if (!m_{{domain.domain | lower}}Agent) errors->addError("{{domain.domain}} handler is not available."); @@ -130,10 +130,10 @@ void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callI {% if "parameters" in command %} // Prepare input parameters. - RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(requestMessageObject->get("params")); + protocol::DictionaryValue* object = DictionaryValue::cast(requestMessageObject->get("params")); errors->push(); {% for property in command.parameters %} - RefPtr<protocol::Value> {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr; + protocol::Value* {{property.name}}Value = object ? object->get("{{property.name}}") : nullptr; {% if property.optional %} Maybe<{{resolve_type(property).raw_type}}> in_{{property.name}}; if ({{property.name}}Value) { @@ -156,7 +156,7 @@ void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callI RefPtr<{{domain.domain}}CommandHandler::{{command.name | to_title_case}}Callback> callback = adoptRef(new {{domain.domain}}CommandHandler::{{command.name | to_title_case}}Callback(this, sessionId, callId)); {% elif "returns" in command %} // Declare output parameters. - RefPtr<protocol::DictionaryValue> result = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> result = DictionaryValue::create(); {% for property in command.returns %} {% if "optional" in property %} Maybe<{{resolve_type(property).raw_type}}> out_{{property.name}}; @@ -189,11 +189,11 @@ void DispatcherImpl::{{domain.domain}}_{{command.name}}(int sessionId, int callI if (out_{{parameter.name}}.isJust()) result->setValue("{{parameter.name}}", toValue(out_{{parameter.name}}.fromJust())); {% else %} - result->setValue("{{parameter.name}}", toValue(out_{{parameter.name}})); + result->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % ("out_" + parameter.name)}})); {% endif %} {% endfor %} } - sendResponse(sessionId, callId, error, result); + sendResponse(sessionId, callId, error, result.release()); {% elif not("async" in command) %} sendResponse(sessionId, callId, error); {% endif %} @@ -210,16 +210,16 @@ void DispatcherImpl::dispatch(int sessionId, const String& message) { RefPtr<Dispatcher> protect(this); int callId = 0; - RefPtr<protocol::Value> parsedMessage = parseJSON(message); + OwnPtr<protocol::Value> parsedMessage = parseJSON(message); ASSERT(parsedMessage); - RefPtr<protocol::DictionaryValue> messageObject = DictionaryValue::cast(parsedMessage.release()); + OwnPtr<protocol::DictionaryValue> messageObject = DictionaryValue::cast(parsedMessage.release()); ASSERT(messageObject); - RefPtr<protocol::Value> callIdValue = messageObject->get("id"); + protocol::Value* callIdValue = messageObject->get("id"); bool success = callIdValue->asNumber(&callId); ASSERT_UNUSED(success, success); - RefPtr<protocol::Value> methodValue = messageObject->get("method"); + protocol::Value* methodValue = messageObject->get("method"); String method; success = methodValue && methodValue->asString(&method); ASSERT_UNUSED(success, success); @@ -231,17 +231,17 @@ void DispatcherImpl::dispatch(int sessionId, const String& message) } protocol::ErrorSupport errors; - ((*this).*it->value)(sessionId, callId, messageObject.get(), &errors); + ((*this).*it->value)(sessionId, callId, messageObject.release(), &errors); } -void DispatcherImpl::sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassRefPtr<protocol::DictionaryValue> result) +void DispatcherImpl::sendResponse(int sessionId, int callId, const ErrorString& invocationError, ErrorSupport* errors, PassOwnPtr<protocol::DictionaryValue> result) { if (invocationError.length() || (errors && errors->hasErrors())) { reportProtocolError(sessionId, callId, ServerError, invocationError, errors); return; } - RefPtr<protocol::DictionaryValue> responseMessage = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> responseMessage = DictionaryValue::create(); responseMessage->setNumber("id", callId); responseMessage->setObject("result", result); if (m_frontendChannel) @@ -259,14 +259,14 @@ void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorC ASSERT(code >=0); ASSERT((unsigned)code < m_commonErrors.size()); ASSERT(m_commonErrors[code]); - RefPtr<protocol::DictionaryValue> error = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> error = DictionaryValue::create(); error->setNumber("code", m_commonErrors[code]); error->setString("message", errorMessage); ASSERT(error); if (errors && errors->hasErrors()) error->setString("data", errors->errors()); - RefPtr<protocol::DictionaryValue> message = DictionaryValue::create(); - message->setObject("error", error); + OwnPtr<protocol::DictionaryValue> message = DictionaryValue::create(); + message->setObject("error", error.release()); message->setNumber("id", callId); if (m_frontendChannel) m_frontendChannel->sendProtocolResponse(sessionId, callId, message.release()); @@ -274,11 +274,11 @@ void DispatcherImpl::reportProtocolError(int sessionId, int callId, CommonErrorC bool Dispatcher::getCommandName(const String& message, String* result) { - RefPtr<protocol::Value> value = parseJSON(message); + OwnPtr<protocol::Value> value = parseJSON(message); if (!value) return false; - RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(value.release()); + protocol::DictionaryValue* object = DictionaryValue::cast(value.get()); if (!object) return false; @@ -304,7 +304,7 @@ bool Dispatcher::CallbackBase::isActive() return !m_alreadySent && m_backendImpl->isActive(); } -void Dispatcher::CallbackBase::sendIfActive(PassRefPtr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError) +void Dispatcher::CallbackBase::sendIfActive(PassOwnPtr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError) { if (m_alreadySent) return; diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_h.template b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_h.template index 93b3988..0694e5f 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_h.template +++ b/third_party/WebKit/Source/platform/inspector_protocol/Dispatcher_h.template @@ -29,7 +29,7 @@ public: bool isActive(); protected: - void sendIfActive(PassRefPtr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError); + void sendIfActive(PassOwnPtr<protocol::DictionaryValue> partialMessage, const ErrorString& invocationError); private: void disable() { m_alreadySent = true; } diff --git a/third_party/WebKit/Source/platform/inspector_protocol/FrontendChannel.h b/third_party/WebKit/Source/platform/inspector_protocol/FrontendChannel.h index dfb7fc3..37c15d0 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/FrontendChannel.h +++ b/third_party/WebKit/Source/platform/inspector_protocol/FrontendChannel.h @@ -35,8 +35,8 @@ namespace protocol { class FrontendChannel { public: virtual ~FrontendChannel() { } - virtual void sendProtocolResponse(int sessionId, int callId, PassRefPtr<protocol::DictionaryValue> message) = 0; - virtual void sendProtocolNotification(PassRefPtr<protocol::DictionaryValue> message) = 0; + virtual void sendProtocolResponse(int sessionId, int callId, PassOwnPtr<protocol::DictionaryValue> message) = 0; + virtual void sendProtocolNotification(PassOwnPtr<protocol::DictionaryValue> message) = 0; virtual void flush() = 0; }; diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Frontend_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/Frontend_cpp.template index 6773e9b..94041d3 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Frontend_cpp.template +++ b/third_party/WebKit/Source/platform/inspector_protocol/Frontend_cpp.template @@ -32,18 +32,18 @@ void Frontend::{{domain.domain}}::{{event.name}}( {%- endif %} {{parameter.name}}{%- if not loop.last -%}, {% endif -%} {% endfor -%}) { - RefPtr<protocol::DictionaryValue> jsonMessage = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> jsonMessage = DictionaryValue::create(); jsonMessage->setString("method", "{{domain.domain}}.{{event.name}}"); - RefPtr<protocol::DictionaryValue> paramsObject = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> paramsObject = DictionaryValue::create(); {% for parameter in event.parameters %} {% if "optional" in parameter %} if ({{parameter.name}}.isJust()) paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}}.fromJust())); {% else %} - paramsObject->setValue("{{parameter.name}}", toValue({{parameter.name}})); + paramsObject->setValue("{{parameter.name}}", toValue({{resolve_type(parameter).to_raw_type % parameter.name}})); {% endif %} {% endfor %} - jsonMessage->setObject("params", paramsObject); + jsonMessage->setObject("params", paramsObject.release()); if (m_frontendChannel) m_frontendChannel->sendProtocolNotification(jsonMessage.release()); } diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp b/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp index 2257c3c..ce72028 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp +++ b/third_party/WebKit/Source/platform/inspector_protocol/Parser.cpp @@ -419,12 +419,12 @@ bool decodeString(const CharType* start, const CharType* end, String* output) } template<typename CharType> -PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const CharType** valueTokenEnd, int depth) +PassOwnPtr<Value> buildValue(const CharType* start, const CharType* end, const CharType** valueTokenEnd, int depth) { if (depth > stackLimit) return nullptr; - RefPtr<Value> result; + OwnPtr<Value> result; const CharType* tokenStart; const CharType* tokenEnd; Token token = parseToken(start, end, &tokenStart, &tokenEnd); @@ -459,14 +459,14 @@ PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const C break; } case ArrayBegin: { - RefPtr<ListValue> array = ListValue::create(); + OwnPtr<ListValue> array = ListValue::create(); start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); while (token != ArrayEnd) { - RefPtr<Value> arrayNode = buildValue(start, end, &tokenEnd, depth + 1); + OwnPtr<Value> arrayNode = buildValue(start, end, &tokenEnd, depth + 1); if (!arrayNode) return nullptr; - array->pushValue(arrayNode); + array->pushValue(arrayNode.release()); // After a list value, we expect a comma or the end of the list. start = tokenEnd; @@ -487,7 +487,7 @@ PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const C break; } case ObjectBegin: { - RefPtr<DictionaryValue> object = DictionaryValue::create(); + OwnPtr<DictionaryValue> object = DictionaryValue::create(); start = tokenEnd; token = parseToken(start, end, &tokenStart, &tokenEnd); while (token != ObjectEnd) { @@ -503,10 +503,10 @@ PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const C return nullptr; start = tokenEnd; - RefPtr<Value> value = buildValue(start, end, &tokenEnd, depth + 1); + OwnPtr<Value> value = buildValue(start, end, &tokenEnd, depth + 1); if (!value) return nullptr; - object->setValue(key, value); + object->setValue(key, value.release()); start = tokenEnd; // After a key/value pair, we expect a comma or the end of the @@ -538,11 +538,11 @@ PassRefPtr<Value> buildValue(const CharType* start, const CharType* end, const C } template<typename CharType> -PassRefPtr<Value> parseJSONInternal(const CharType* start, unsigned length) +PassOwnPtr<Value> parseJSONInternal(const CharType* start, unsigned length) { const CharType* end = start + length; const CharType *tokenEnd; - RefPtr<Value> value = buildValue(start, end, &tokenEnd, 0); + OwnPtr<Value> value = buildValue(start, end, &tokenEnd, 0); if (!value || tokenEnd != end) return nullptr; return value.release(); @@ -550,7 +550,7 @@ PassRefPtr<Value> parseJSONInternal(const CharType* start, unsigned length) } // anonymous namespace -PassRefPtr<Value> parseJSON(const String& json) +PassOwnPtr<Value> parseJSON(const String& json) { if (json.isEmpty()) return nullptr; diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Parser.h b/third_party/WebKit/Source/platform/inspector_protocol/Parser.h index 9234777..17849d3 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Parser.h +++ b/third_party/WebKit/Source/platform/inspector_protocol/Parser.h @@ -14,7 +14,7 @@ namespace protocol { class Value; -PLATFORM_EXPORT PassRefPtr<Value> parseJSON(const String& json); +PLATFORM_EXPORT PassOwnPtr<Value> parseJSON(const String& json); } // namespace platform } // namespace blink diff --git a/third_party/WebKit/Source/platform/inspector_protocol/ParserTest.cpp b/third_party/WebKit/Source/platform/inspector_protocol/ParserTest.cpp index 415b36c..d05fb37 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/ParserTest.cpp +++ b/third_party/WebKit/Source/platform/inspector_protocol/ParserTest.cpp @@ -13,9 +13,9 @@ namespace protocol { TEST(ParserTest, Reading) { - RefPtr<protocol::Value> tmpValue; - RefPtr<protocol::Value> root; - RefPtr<protocol::Value> root2; + protocol::Value* tmpValue; + OwnPtr<protocol::Value> root; + OwnPtr<protocol::Value> root2; String strVal; int intVal = 0; @@ -58,20 +58,20 @@ TEST(ParserTest, Reading) EXPECT_EQ("sample string", strVal); root = parseJSON("[1, /* comment, 2 ] */ \n 3]"); ASSERT_TRUE(root.get()); - RefPtr<protocol::ListValue> list = ListValue::cast(root); + protocol::ListValue* list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(2u, list->length()); tmpValue = list->get(0); - ASSERT_TRUE(tmpValue.get()); + ASSERT_TRUE(tmpValue); EXPECT_TRUE(tmpValue->asNumber(&intVal)); EXPECT_EQ(1, intVal); tmpValue = list->get(1); - ASSERT_TRUE(tmpValue.get()); + ASSERT_TRUE(tmpValue); EXPECT_TRUE(tmpValue->asNumber(&intVal)); EXPECT_EQ(3, intVal); root = parseJSON("[1, /*a*/2, 3]"); ASSERT_TRUE(root.get()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(3u, list->length()); root = parseJSON("/* comment **/42"); @@ -254,7 +254,7 @@ TEST(ParserTest, Reading) root = parseJSON("[true, false, null]"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeArray, root->type()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(3U, list->length()); @@ -262,7 +262,7 @@ TEST(ParserTest, Reading) root = parseJSON("[]"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeArray, root->type()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(0U, list->length()); @@ -270,7 +270,7 @@ TEST(ParserTest, Reading) root = parseJSON("[[true], [], [false, [], [null]], null]"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeArray, root->type()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(4U, list->length()); @@ -293,11 +293,11 @@ TEST(ParserTest, Reading) root = parseJSON("[true]"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeArray, root->type()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(1U, list->length()); tmpValue = list->get(0); - ASSERT_TRUE(tmpValue.get()); + ASSERT_TRUE(tmpValue); EXPECT_EQ(Value::TypeBoolean, tmpValue->type()); bool boolValue = false; EXPECT_TRUE(tmpValue->asBoolean(&boolValue)); @@ -321,13 +321,13 @@ TEST(ParserTest, Reading) root = parseJSON("{\"number\":9.87654321, \"null\":null , \"\\x53\" : \"str\" }"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeObject, root->type()); - RefPtr<protocol::DictionaryValue> objectVal = DictionaryValue::cast(root); + protocol::DictionaryValue* objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); doubleVal = 0.0; EXPECT_TRUE(objectVal->getNumber("number", &doubleVal)); EXPECT_DOUBLE_EQ(9.87654321, doubleVal); - RefPtr<protocol::Value> nullVal = objectVal->get("null"); - ASSERT_TRUE(nullVal.get()); + protocol::Value* nullVal = objectVal->get("null"); + ASSERT_TRUE(nullVal); EXPECT_EQ(Value::TypeNull, nullVal->type()); EXPECT_TRUE(objectVal->getString("S", &strVal)); EXPECT_EQ("str", strVal); @@ -355,24 +355,24 @@ TEST(ParserTest, Reading) root = parseJSON("{\"inner\":{\"array\":[true]},\"false\":false,\"d\":{}}"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeObject, root->type()); - objectVal = DictionaryValue::cast(root); + objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); - RefPtr<protocol::DictionaryValue> innerObject = objectVal->getObject("inner"); - ASSERT_TRUE(innerObject.get()); - RefPtr<protocol::ListValue> innerArray = innerObject->getArray("array"); - ASSERT_TRUE(innerArray.get()); + protocol::DictionaryValue* innerObject = objectVal->getObject("inner"); + ASSERT_TRUE(innerObject); + protocol::ListValue* innerArray = innerObject->getArray("array"); + ASSERT_TRUE(innerArray); EXPECT_EQ(1U, innerArray->length()); boolValue = true; EXPECT_TRUE(objectVal->getBoolean("false", &boolValue)); EXPECT_FALSE(boolValue); innerObject = objectVal->getObject("d"); - EXPECT_TRUE(innerObject.get()); + EXPECT_TRUE(innerObject); // Test keys with periods root = parseJSON("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeObject, root->type()); - objectVal = DictionaryValue::cast(root); + objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); int integerValue = 0; EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); @@ -380,7 +380,7 @@ TEST(ParserTest, Reading) EXPECT_TRUE(objectVal->getNumber("c", &integerValue)); EXPECT_EQ(2, integerValue); innerObject = objectVal->getObject("d.e.f"); - ASSERT_TRUE(innerObject.get()); + ASSERT_TRUE(innerObject); EXPECT_EQ(1, innerObject->size()); EXPECT_TRUE(innerObject->getNumber("g.h.i.j", &integerValue)); EXPECT_EQ(1, integerValue); @@ -388,10 +388,10 @@ TEST(ParserTest, Reading) root = parseJSON("{\"a\":{\"b\":2},\"a.b\":1}"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeObject, root->type()); - objectVal = DictionaryValue::cast(root); + objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); innerObject = objectVal->getObject("a"); - ASSERT_TRUE(innerObject.get()); + ASSERT_TRUE(innerObject); EXPECT_TRUE(innerObject->getNumber("b", &integerValue)); EXPECT_EQ(2, integerValue); EXPECT_TRUE(objectVal->getNumber("a.b", &integerValue)); @@ -447,7 +447,7 @@ TEST(ParserTest, Reading) root = parseJSON(notEvil.toString()); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeArray, root->type()); - list = ListValue::cast(root); + list = ListValue::cast(root.get()); ASSERT_TRUE(list); EXPECT_EQ(5001U, list->length()); @@ -462,7 +462,7 @@ TEST(ParserTest, Reading) root = parseJSON("{\"path\": \"/tmp/\\xc3\\xa0\\xc3\\xa8\\xc3\\xb2.png\"}"); ASSERT_TRUE(root.get()); EXPECT_EQ(Value::TypeObject, root->type()); - objectVal = DictionaryValue::cast(root); + objectVal = DictionaryValue::cast(root.get()); ASSERT_TRUE(objectVal); EXPECT_TRUE(objectVal->getString("path", &strVal)); UChar tmp5[] = {0x2f, 0x74, 0x6d, 0x70, 0x2f, 0xe0, 0xe8, 0xf2, 0x2e, 0x70, 0x6e, 0x67}; @@ -544,7 +544,7 @@ TEST(ParserTest, InvalidSanity) }; for (size_t i = 0; i < WTF_ARRAY_LENGTH(invalidJson); ++i) { - RefPtr<protocol::Value> result = parseJSON(invalidJson[i]); + OwnPtr<protocol::Value> result = parseJSON(invalidJson[i]); EXPECT_FALSE(result.get()); } } diff --git a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template index 5fd39196..ce26b9a 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template +++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_cpp.template @@ -62,33 +62,36 @@ String ErrorSupport::errors() return builder.toString(); } -PassOwnPtr<Object> Object::parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) +PassOwnPtr<Object> Object::parse(protocol::Value* value, ErrorSupport* errors) { - RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(value); + protocol::DictionaryValue* object = DictionaryValue::cast(value); if (!object) { errors->addError("object expected"); return nullptr; } - return adoptPtr(new Object(object.release())); + return adoptPtr(new Object(adoptPtr(static_cast<DictionaryValue*>(object->clone().leakPtr())))); } -PassRefPtr<protocol::DictionaryValue> Object::serialize() const +PassOwnPtr<protocol::DictionaryValue> Object::serialize() const { - return m_object; + return DictionaryValue::cast(m_object->clone()); } PassOwnPtr<Object> Object::clone() const { - return adoptPtr(new Object(m_object)); + return adoptPtr(new Object(DictionaryValue::cast(m_object->clone()))); } -Object::Object(PassRefPtr<protocol::DictionaryValue> object) : m_object(object) { } +Object::Object(PassOwnPtr<protocol::DictionaryValue> object) : m_object(object) { } Object::~Object() { } -PassRefPtr<protocol::Value> toValue(int value) { return FundamentalValue::create(value); } -PassRefPtr<protocol::Value> toValue(double value) { return FundamentalValue::create(value); } -PassRefPtr<protocol::Value> toValue(bool value) { return FundamentalValue::create(value); } -PassRefPtr<protocol::Value> toValue(const String& param) { return StringValue::create(param); } +PassOwnPtr<protocol::Value> toValue(int value) { return FundamentalValue::create(value); } +PassOwnPtr<protocol::Value> toValue(double value) { return FundamentalValue::create(value); } +PassOwnPtr<protocol::Value> toValue(bool value) { return FundamentalValue::create(value); } +PassOwnPtr<protocol::Value> toValue(const String& param) { return StringValue::create(param); } +PassOwnPtr<protocol::Value> toValue(Value* param) { return param->clone(); } +PassOwnPtr<protocol::Value> toValue(DictionaryValue* param) { return param->clone(); } +PassOwnPtr<protocol::Value> toValue(ListValue* param) { return param->clone(); } // ------------- Enum values from types. {% for domain in api.domains %} @@ -113,7 +116,7 @@ const char* {{type.id}}::{{property.name | to_title_case}}Enum::{{ literal | das {% endfor %} {% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %} -PassOwnPtr<{{type.id}}> {{type.id}}::parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) +PassOwnPtr<{{type.id}}> {{type.id}}::parse(protocol::Value* value, ErrorSupport* errors) { if (!value || value->type() != protocol::Value::TypeObject) { errors->addError("object expected"); @@ -121,10 +124,10 @@ PassOwnPtr<{{type.id}}> {{type.id}}::parse(PassRefPtr<protocol::Value> value, Er } OwnPtr<{{type.id}}> result = adoptPtr(new {{type.id}}()); - RefPtr<protocol::DictionaryValue> object = DictionaryValue::cast(value); + protocol::DictionaryValue* object = DictionaryValue::cast(value); errors->push(); {% for property in type.properties %} - RefPtr<protocol::Value> {{property.name}}Value = object->get("{{property.name}}"); + protocol::Value* {{property.name}}Value = object->get("{{property.name}}"); {% if property.optional %} if ({{property.name}}Value) { errors->setName("{{property.name}}"); @@ -141,15 +144,15 @@ PassOwnPtr<{{type.id}}> {{type.id}}::parse(PassRefPtr<protocol::Value> value, Er return result.release(); } -PassRefPtr<protocol::DictionaryValue> {{type.id}}::serialize() const +PassOwnPtr<protocol::DictionaryValue> {{type.id}}::serialize() const { - RefPtr<protocol::DictionaryValue> result = DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> result = DictionaryValue::create(); {% for property in type.properties %} {% if property.optional %} if (m_{{property.name}}.isJust()) result->setValue("{{property.name}}", toValue(m_{{property.name}}.fromJust())); {% else %} - result->setValue("{{property.name}}", toValue(m_{{property.name}})); + result->setValue("{{property.name}}", toValue({{resolve_type(property).to_raw_type % ("m_" + property.name)}})); {% endif %} {% endfor %} return result.release(); diff --git a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template index 8341cc1..d7dc499 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template +++ b/third_party/WebKit/Source/platform/inspector_protocol/TypeBuilder_h.template @@ -11,7 +11,6 @@ #include "platform/inspector_protocol/Values.h" #include "wtf/Assertions.h" #include "wtf/PassOwnPtr.h" -#include "wtf/PassRefPtr.h" #include "wtf/text/StringBuilder.h" #include "wtf/text/WTFString.h" @@ -80,34 +79,18 @@ public: using MaybeBase::operator=; }; -template<typename T> -class Maybe<RefPtr<T>> { -public: - Maybe() { } - Maybe(RefPtr<T> value) : m_value(value) { } - Maybe(PassRefPtr<T> value) : m_value(value) { } - Maybe(T* value) : m_value(value) { } - void operator=(PassRefPtr<T> value) { m_value = value; } - PassRefPtr<T> fromJust() const { ASSERT(m_value); return m_value; } - PassRefPtr<T> fromMaybe(const PassRefPtr<T> defaultValue) const { return m_value || defaultValue; } - bool isJust() const { return !!m_value; } - PassRefPtr<T> takeJust() { return m_value; } - -protected: - RefPtr<T> m_value; -}; - template<typename T> class Array; -PLATFORM_EXPORT PassRefPtr<protocol::Value> toValue(int value); -PLATFORM_EXPORT PassRefPtr<protocol::Value> toValue(double value); -PLATFORM_EXPORT PassRefPtr<protocol::Value> toValue(bool value); -PLATFORM_EXPORT PassRefPtr<protocol::Value> toValue(const String& param); -template<typename T> PassRefPtr<protocol::Value> toValue(PassRefPtr<T> param) { return param; } -template<typename T> PassRefPtr<protocol::Value> toValue(const RefPtr<T>& param) { return param; } -template<typename T> PassRefPtr<protocol::Value> toValue(T* param) { return param->serialize(); } -template<typename T> PassRefPtr<protocol::Value> toValue(PassOwnPtr<T> param) { return param->serialize(); } -template<typename T> PassRefPtr<protocol::Value> toValue(const OwnPtr<T>& param) { return param->serialize(); } +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(int value); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(double value); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(bool value); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(const String& param); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(protocol::Value* param); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(protocol::DictionaryValue* param); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toValue(protocol::ListValue* param); +template<typename T> PassOwnPtr<protocol::Value> toValue(T* param) { return param->serialize(); } +template<typename T> PassOwnPtr<protocol::Value> toValue(const OwnPtr<T>& param) { static_assert(sizeof(T) == 0, "use raw pointer version."); return nullptr; } +template<typename T> PassOwnPtr<protocol::Value> toValue(PassOwnPtr<T> param) { static_assert(sizeof(T) == 0, "use raw pointer version."); return nullptr; } class PLATFORM_EXPORT ErrorSupport { public: @@ -131,7 +114,7 @@ private: template<typename T> struct FromValue { - static PassOwnPtr<T> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<T> parse(protocol::Value* value, ErrorSupport* errors) { return T::parse(value, errors); } @@ -140,7 +123,7 @@ struct FromValue template<> struct FromValue<bool> { - static bool parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static bool parse(protocol::Value* value, ErrorSupport* errors) { bool result = false; bool success = value ? value->asBoolean(&result) : false; @@ -153,7 +136,7 @@ struct FromValue<bool> template<> struct FromValue<int> { - static int parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static int parse(protocol::Value* value, ErrorSupport* errors) { int result = 0; bool success = value ? value->asNumber(&result) : false; @@ -166,7 +149,7 @@ struct FromValue<int> template<> struct FromValue<double> { - static double parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static double parse(protocol::Value* value, ErrorSupport* errors) { double result = 0; bool success = value ? value->asNumber(&result) : false; @@ -179,7 +162,7 @@ struct FromValue<double> template<> struct FromValue<String> { - static String parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static String parse(protocol::Value* value, ErrorSupport* errors) { String result; bool success = value ? value->asString(&result) : false; @@ -189,33 +172,49 @@ struct FromValue<String> } }; -template<typename T> -struct FromValue<RefPtr<T>> +template<> +struct FromValue<Value> { - static PassRefPtr<T> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<Value> parse(protocol::Value* value, ErrorSupport* errors) { - if (!value) + String result; + bool success = !!value; + if (!success) errors->addError("value expected"); - return value; + return value->clone(); } }; template<> -struct FromValue<RefPtr<protocol::DictionaryValue>> +struct FromValue<DictionaryValue> { - static PassRefPtr<protocol::DictionaryValue> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<DictionaryValue> parse(protocol::Value* value, ErrorSupport* errors) { - if (value && value->type() == protocol::Value::TypeObject) - return DictionaryValue::cast(value); - errors->addError("object expected"); - return nullptr; + String result; + bool success = value && value->type() == protocol::Value::TypeObject; + if (!success) + errors->addError("object expected"); + return DictionaryValue::cast(value->clone()); + } +}; + +template<> +struct FromValue<ListValue> +{ + static PassOwnPtr<ListValue> parse(protocol::Value* value, ErrorSupport* errors) + { + String result; + bool success = value && value->type() == protocol::Value::TypeArray; + if (!success) + errors->addError("list expected"); + return ListValue::cast(value->clone()); } }; template<typename T> struct FromValue<protocol::Array<T>> { - static PassOwnPtr<protocol::Array<T>> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<protocol::Array<T>> parse(protocol::Value* value, ErrorSupport* errors) { return protocol::Array<T>::parse(value, errors); } @@ -229,9 +228,9 @@ public: return adoptPtr(new Array<T>()); } - static PassOwnPtr<Array<T>> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors) { - RefPtr<protocol::ListValue> array = ListValue::cast(value); + protocol::ListValue* array = ListValue::cast(value); if (!array) { errors->addError("array expected"); return nullptr; @@ -264,9 +263,9 @@ public: return m_vector[index]; } - PassRefPtr<protocol::ListValue> serialize() + PassOwnPtr<protocol::ListValue> serialize() { - RefPtr<protocol::ListValue> result = ListValue::create(); + OwnPtr<protocol::ListValue> result = ListValue::create(); for (auto& item : m_vector) result->pushValue(toValue(item)); return result.release(); @@ -280,7 +279,6 @@ template<> class Array<String> : public ArrayBase<String> {}; template<> class Array<int> : public ArrayBase<int> {}; template<> class Array<double> : public ArrayBase<double> {}; template<> class Array<bool> : public ArrayBase<bool> {}; -template<typename T> class Array<RefPtr<T>> : public ArrayBase<RefPtr<T>> {}; template<typename T> class Array { @@ -290,9 +288,9 @@ public: return adoptPtr(new Array<T>()); } - static PassOwnPtr<Array<T>> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors) + static PassOwnPtr<Array<T>> parse(protocol::Value* value, ErrorSupport* errors) { - RefPtr<protocol::ListValue> array = ListValue::cast(value); + protocol::ListValue* array = ListValue::cast(value); if (!array) { errors->addError("array expected"); return nullptr; @@ -323,11 +321,11 @@ public: return m_vector[index].get(); } - PassRefPtr<protocol::ListValue> serialize() + PassOwnPtr<protocol::ListValue> serialize() { - RefPtr<protocol::ListValue> result = ListValue::create(); + OwnPtr<protocol::ListValue> result = ListValue::create(); for (auto& item : m_vector) - result->pushValue(toValue(item)); + result->pushValue(toValue(item.get())); return result.release(); } @@ -337,14 +335,14 @@ private: class PLATFORM_EXPORT Object { public: - static PassOwnPtr<Object> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors); + static PassOwnPtr<Object> parse(protocol::Value* value, ErrorSupport* errors); ~Object(); - PassRefPtr<protocol::DictionaryValue> serialize() const; + PassOwnPtr<protocol::DictionaryValue> serialize() const; PassOwnPtr<Object> clone() const; private: - Object(PassRefPtr<protocol::DictionaryValue> object); - RefPtr<protocol::DictionaryValue> m_object; + Object(PassOwnPtr<protocol::DictionaryValue> object); + OwnPtr<protocol::DictionaryValue> m_object; }; {% for domain in api.domains %} @@ -416,7 +414,7 @@ namespace {{domain.domain}} { // {{type.description}} class PLATFORM_EXPORT {{type.id}} { public: - static PassOwnPtr<{{type.id}}> parse(PassRefPtr<protocol::Value> value, ErrorSupport* errors); + static PassOwnPtr<{{type.id}}> parse(protocol::Value* value, ErrorSupport* errors); ~{{type.id}}() { } {% for property in type.properties %} @@ -438,7 +436,7 @@ public: void set{{property.name | to_title_case}}({{resolve_type(property).pass_type}} value) { m_{{property.name}} = value; } {% endfor %} - PassRefPtr<protocol::DictionaryValue> serialize() const; + PassOwnPtr<protocol::DictionaryValue> serialize() const; PassOwnPtr<{{type.id}}> clone() const; template<int STATE> diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Values.cpp b/third_party/WebKit/Source/platform/inspector_protocol/Values.cpp index 23e79d3..d35271e 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Values.cpp +++ b/third_party/WebKit/Source/platform/inspector_protocol/Values.cpp @@ -5,6 +5,7 @@ #include "platform/inspector_protocol/Values.h" #include "platform/Decimal.h" +#include "platform/inspector_protocol/Parser.h" #include "wtf/MathExtras.h" #include "wtf/text/StringBuilder.h" @@ -95,6 +96,11 @@ void Value::writeJSON(StringBuilder* output) const output->append(nullString, 4); } +PassOwnPtr<Value> Value::clone() const +{ + return Value::null(); +} + bool FundamentalValue::asBoolean(bool* output) const { if (type() != TypeBoolean) @@ -136,6 +142,11 @@ void FundamentalValue::writeJSON(StringBuilder* output) const } } +PassOwnPtr<Value> FundamentalValue::clone() const +{ + return type() == TypeNumber ? FundamentalValue::create(m_doubleValue) : FundamentalValue::create(m_boolValue); +} + bool StringValue::asString(String* output) const { *output = m_stringValue; @@ -148,6 +159,11 @@ void StringValue::writeJSON(StringBuilder* output) const doubleQuoteStringForJSON(m_stringValue, output); } +PassOwnPtr<Value> StringValue::clone() const +{ + return StringValue::create(m_stringValue); +} + DictionaryValue::~DictionaryValue() { } @@ -167,40 +183,30 @@ void DictionaryValue::setString(const String& name, const String& value) setValue(name, StringValue::create(value)); } -void DictionaryValue::setValue(const String& name, PassRefPtr<Value> value) +void DictionaryValue::setValue(const String& name, PassOwnPtr<Value> value) { ASSERT(value); if (m_data.set(name, value).isNewEntry) m_order.append(name); } -void DictionaryValue::setObject(const String& name, PassRefPtr<DictionaryValue> value) +void DictionaryValue::setObject(const String& name, PassOwnPtr<DictionaryValue> value) { ASSERT(value); if (m_data.set(name, value).isNewEntry) m_order.append(name); } -void DictionaryValue::setArray(const String& name, PassRefPtr<ListValue> value) +void DictionaryValue::setArray(const String& name, PassOwnPtr<ListValue> value) { ASSERT(value); if (m_data.set(name, value).isNewEntry) m_order.append(name); } -DictionaryValue::iterator DictionaryValue::find(const String& name) -{ - return m_data.find(name); -} - -DictionaryValue::const_iterator DictionaryValue::find(const String& name) const -{ - return m_data.find(name); -} - bool DictionaryValue::getBoolean(const String& name, bool* output) const { - RefPtr<protocol::Value> value = get(name); + protocol::Value* value = get(name); if (!value) return false; return value->asBoolean(output); @@ -208,28 +214,28 @@ bool DictionaryValue::getBoolean(const String& name, bool* output) const bool DictionaryValue::getString(const String& name, String* output) const { - RefPtr<protocol::Value> value = get(name); + protocol::Value* value = get(name); if (!value) return false; return value->asString(output); } -PassRefPtr<DictionaryValue> DictionaryValue::getObject(const String& name) const +DictionaryValue* DictionaryValue::getObject(const String& name) const { return DictionaryValue::cast(get(name)); } -PassRefPtr<protocol::ListValue> DictionaryValue::getArray(const String& name) const +protocol::ListValue* DictionaryValue::getArray(const String& name) const { return ListValue::cast(get(name)); } -PassRefPtr<protocol::Value> DictionaryValue::get(const String& name) const +protocol::Value* DictionaryValue::get(const String& name) const { Dictionary::const_iterator it = m_data.find(name); if (it == m_data.end()) return nullptr; - return it->value; + return it->value.get(); } bool DictionaryValue::booleanProperty(const String& name, bool defaultValue) const @@ -265,6 +271,17 @@ void DictionaryValue::writeJSON(StringBuilder* output) const output->append('}'); } +PassOwnPtr<Value> DictionaryValue::clone() const +{ + OwnPtr<DictionaryValue> result = DictionaryValue::create(); + for (size_t i = 0; i < m_order.size(); ++i) { + Dictionary::const_iterator it = m_data.find(m_order[i]); + ASSERT(it != m_data.end()); + result->setValue(it->key, it->value->clone()); + } + return result.release(); +} + DictionaryValue::DictionaryValue() : Value(TypeObject) , m_data() @@ -279,7 +296,7 @@ ListValue::~ListValue() void ListValue::writeJSON(StringBuilder* output) const { output->append('['); - for (Vector<RefPtr<protocol::Value>>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) { + for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) { if (it != m_data.begin()) output->append(','); (*it)->writeJSON(output); @@ -287,22 +304,30 @@ void ListValue::writeJSON(StringBuilder* output) const output->append(']'); } +PassOwnPtr<Value> ListValue::clone() const +{ + OwnPtr<ListValue> result = ListValue::create(); + for (Vector<OwnPtr<protocol::Value>>::const_iterator it = m_data.begin(); it != m_data.end(); ++it) + result->pushValue((*it)->clone()); + return result.release(); +} + ListValue::ListValue() : Value(TypeArray) , m_data() { } -void ListValue::pushValue(PassRefPtr<protocol::Value> value) +void ListValue::pushValue(PassOwnPtr<protocol::Value> value) { ASSERT(value); m_data.append(value); } -PassRefPtr<protocol::Value> ListValue::get(size_t index) +protocol::Value* ListValue::get(size_t index) { ASSERT_WITH_SECURITY_IMPLICATION(index < m_data.size()); - return m_data[index]; + return m_data[index].get(); } } // namespace protocol diff --git a/third_party/WebKit/Source/platform/inspector_protocol/Values.h b/third_party/WebKit/Source/platform/inspector_protocol/Values.h index f7147a0..fe75c6e 100644 --- a/third_party/WebKit/Source/platform/inspector_protocol/Values.h +++ b/third_party/WebKit/Source/platform/inspector_protocol/Values.h @@ -9,7 +9,7 @@ #include "wtf/Allocator.h" #include "wtf/Forward.h" #include "wtf/HashMap.h" -#include "wtf/RefCounted.h" +#include "wtf/PassOwnPtr.h" #include "wtf/TypeTraits.h" #include "wtf/Vector.h" #include "wtf/text/StringHash.h" @@ -22,15 +22,16 @@ class ListValue; class DictionaryValue; class Value; -class PLATFORM_EXPORT Value : public RefCounted<Value> { +class PLATFORM_EXPORT Value { + WTF_MAKE_NONCOPYABLE(Value); public: static const int maxDepth = 1000; virtual ~Value() { } - static PassRefPtr<Value> null() + static PassOwnPtr<Value> null() { - return adoptRef(new Value()); + return adoptPtr(new Value()); } typedef enum { @@ -53,6 +54,7 @@ public: String toJSONString() const; virtual void writeJSON(StringBuilder* output) const; + virtual PassOwnPtr<Value> clone() const; protected: Value() : m_type(TypeNull) { } @@ -67,27 +69,26 @@ private: class PLATFORM_EXPORT FundamentalValue : public Value { public: - - static PassRefPtr<FundamentalValue> create(bool value) + static PassOwnPtr<FundamentalValue> create(bool value) { - return adoptRef(new FundamentalValue(value)); + return adoptPtr(new FundamentalValue(value)); } - static PassRefPtr<FundamentalValue> create(int value) + static PassOwnPtr<FundamentalValue> create(int value) { - return adoptRef(new FundamentalValue(value)); + return adoptPtr(new FundamentalValue(value)); } - static PassRefPtr<FundamentalValue> create(double value) + static PassOwnPtr<FundamentalValue> create(double value) { - return adoptRef(new FundamentalValue(value)); + return adoptPtr(new FundamentalValue(value)); } bool asBoolean(bool* output) const override; bool asNumber(double* output) const override; bool asNumber(int* output) const override; - void writeJSON(StringBuilder* output) const override; + PassOwnPtr<Value> clone() const override; private: explicit FundamentalValue(bool value) : Value(TypeBoolean), m_boolValue(value) { } @@ -102,19 +103,19 @@ private: class PLATFORM_EXPORT StringValue : public Value { public: - static PassRefPtr<StringValue> create(const String& value) + static PassOwnPtr<StringValue> create(const String& value) { - return adoptRef(new StringValue(value)); + return adoptPtr(new StringValue(value)); } - static PassRefPtr<StringValue> create(const char* value) + static PassOwnPtr<StringValue> create(const char* value) { - return adoptRef(new StringValue(value)); + return adoptPtr(new StringValue(value)); } bool asString(String* output) const override; - void writeJSON(StringBuilder* output) const override; + PassOwnPtr<Value> clone() const override; private: explicit StringValue(const String& value) : Value(TypeString), m_stringValue(value) { } @@ -125,49 +126,54 @@ private: class PLATFORM_EXPORT DictionaryValue : public Value { private: - typedef HashMap<String, RefPtr<Value>> Dictionary; + typedef HashMap<String, OwnPtr<Value>> Dictionary; public: typedef Dictionary::iterator iterator; typedef Dictionary::const_iterator const_iterator; - static PassRefPtr<DictionaryValue> create() + static PassOwnPtr<DictionaryValue> create() { - return adoptRef(new DictionaryValue()); + return adoptPtr(new DictionaryValue()); } - static PassRefPtr<DictionaryValue> cast(PassRefPtr<Value> value) + static DictionaryValue* cast(Value* value) { if (!value || value->type() != TypeObject) return nullptr; - return adoptRef(static_cast<DictionaryValue*>(value.leakRef())); + return static_cast<DictionaryValue*>(value); + } + + static PassOwnPtr<DictionaryValue> cast(PassOwnPtr<Value> value) + { + return adoptPtr(DictionaryValue::cast(value.leakPtr())); } void writeJSON(StringBuilder* output) const override; + PassOwnPtr<Value> clone() const override; int size() const { return m_data.size(); } void setBoolean(const String& name, bool); void setNumber(const String& name, double); void setString(const String& name, const String&); - void setValue(const String& name, PassRefPtr<Value>); - void setObject(const String& name, PassRefPtr<DictionaryValue>); - void setArray(const String& name, PassRefPtr<ListValue>); + void setValue(const String& name, PassOwnPtr<Value>); + void setObject(const String& name, PassOwnPtr<DictionaryValue>); + void setArray(const String& name, PassOwnPtr<ListValue>); - iterator find(const String& name); - const_iterator find(const String& name) const; bool getBoolean(const String& name, bool* output) const; template<class T> bool getNumber(const String& name, T* output) const { - RefPtr<Value> value = get(name); + Value* value = get(name); if (!value) return false; return value->asNumber(output); } bool getString(const String& name, String* output) const; - PassRefPtr<DictionaryValue> getObject(const String& name) const; - PassRefPtr<ListValue> getArray(const String& name) const; - PassRefPtr<Value> get(const String& name) const; + + DictionaryValue* getObject(const String& name) const; + ListValue* getArray(const String& name) const; + Value* get(const String& name) const; bool booleanProperty(const String& name, bool defaultValue) const; @@ -188,38 +194,36 @@ private: class PLATFORM_EXPORT ListValue : public Value { public: - typedef Vector<RefPtr<Value>>::iterator iterator; - typedef Vector<RefPtr<Value>>::const_iterator const_iterator; - - static PassRefPtr<ListValue> create() + static PassOwnPtr<ListValue> create() { - return adoptRef(new ListValue()); + return adoptPtr(new ListValue()); } - static PassRefPtr<ListValue> cast(PassRefPtr<Value> value) + static ListValue* cast(Value* value) { if (!value || value->type() != TypeArray) return nullptr; - return adoptRef(static_cast<ListValue*>(value.leakRef())); + return static_cast<ListValue*>(value); + } + + static PassOwnPtr<ListValue> cast(PassOwnPtr<Value> value) + { + return adoptPtr(ListValue::cast(value.leakPtr())); } ~ListValue() override; void writeJSON(StringBuilder* output) const override; + PassOwnPtr<Value> clone() const override; - void pushValue(PassRefPtr<Value>); + void pushValue(PassOwnPtr<Value>); - PassRefPtr<Value> get(size_t index); + Value* get(size_t index); unsigned length() const { return m_data.size(); } - iterator begin() { return m_data.begin(); } - iterator end() { return m_data.end(); } - const_iterator begin() const { return m_data.begin(); } - const_iterator end() const { return m_data.end(); } - private: ListValue(); - Vector<RefPtr<Value>> m_data; + Vector<OwnPtr<Value>> m_data; }; } // namespace protocol diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp index 8f3d055..3ca5b66 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp @@ -54,7 +54,7 @@ using blink::protocol::Maybe; namespace blink { -static PassOwnPtr<protocol::Runtime::ExceptionDetails> toExceptionDetails(PassRefPtr<protocol::DictionaryValue> object) +static PassOwnPtr<protocol::Runtime::ExceptionDetails> toExceptionDetails(protocol::DictionaryValue* object) { String text; if (!object->getString("text", &text)) @@ -73,11 +73,11 @@ static PassOwnPtr<protocol::Runtime::ExceptionDetails> toExceptionDetails(PassRe int originScriptId = 0; object->getNumber("scriptId", &originScriptId); - RefPtr<protocol::ListValue> stackTrace = object->getArray("stackTrace"); + protocol::ListValue* stackTrace = object->getArray("stackTrace"); if (stackTrace && stackTrace->length() > 0) { OwnPtr<protocol::Array<protocol::Runtime::CallFrame>> frames = protocol::Array<protocol::Runtime::CallFrame>::create(); for (unsigned i = 0; i < stackTrace->length(); ++i) { - RefPtr<protocol::DictionaryValue> stackFrame = protocol::DictionaryValue::cast(stackTrace->get(i)); + protocol::DictionaryValue* stackFrame = protocol::DictionaryValue::cast(stackTrace->get(i)); int lineNumber = 0; stackFrame->getNumber("lineNumber", &lineNumber); int column = 0; @@ -140,7 +140,7 @@ void InjectedScript::evaluate(ErrorString* errorString, const String& expression function.appendArgument(includeCommandLineAPI); function.appendArgument(returnByValue); function.appendArgument(generatePreview); - makeEvalCall(errorString, function, result, wasThrown, exceptionDetails); + *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); } void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown) @@ -152,7 +152,7 @@ void InjectedScript::callFunctionOn(ErrorString* errorString, const String& obje function.appendArgument(arguments); function.appendArgument(returnByValue); function.appendArgument(generatePreview); - makeEvalCall(errorString, function, result, wasThrown); + *result = makeEvalCall(errorString, function, wasThrown); } void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, bool isAsyncCallStack, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) @@ -167,7 +167,7 @@ void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: function.appendArgument(includeCommandLineAPI); function.appendArgument(returnByValue); function.appendArgument(generatePreview); - makeEvalCall(errorString, function, result, wasThrown, exceptionDetails); + *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); } void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object> callFrames, const String& callFrameId) @@ -176,8 +176,7 @@ void InjectedScript::restartFrame(ErrorString* errorString, v8::Local<v8::Object V8FunctionCall function(m_client, context(), v8Value(), "restartFrame"); function.appendArgument(callFrames); function.appendArgument(callFrameId); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); if (resultValue) { if (resultValue->type() == protocol::Value::TypeString) { resultValue->asString(errorString); @@ -196,8 +195,7 @@ void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8:: V8FunctionCall function(m_client, context(), v8Value(), "getStepInPositions"); function.appendArgument(callFrames); function.appendArgument(callFrameId); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); if (resultValue) { if (resultValue->type() == protocol::Value::TypeString) { resultValue->asString(errorString); @@ -205,7 +203,7 @@ void InjectedScript::getStepInPositions(ErrorString* errorString, v8::Local<v8:: } if (resultValue->type() == protocol::Value::TypeArray) { protocol::ErrorSupport errors(errorString); - *positions = Array<protocol::Debugger::Location>::parse(resultValue.release(), &errors); + *positions = Array<protocol::Debugger::Location>::parse(resultValue.get(), &errors); return; } } @@ -236,8 +234,7 @@ void InjectedScript::setVariableValue(ErrorString* errorString, function.appendArgument(scopeNumber); function.appendArgument(variableName); function.appendArgument(newValueStr); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); if (!resultValue) { *errorString = "Internal error"; return; @@ -254,10 +251,9 @@ void InjectedScript::getFunctionDetails(ErrorString* errorString, const String& v8::HandleScope handles(m_isolate); V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails"); function.appendArgument(functionId); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); protocol::ErrorSupport errors(errorString); - *result = FunctionDetails::parse(resultValue, &errors); + *result = FunctionDetails::parse(resultValue.get(), &errors); } void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const String& objectId, OwnPtr<GeneratorObjectDetails>* result) @@ -265,10 +261,9 @@ void InjectedScript::getGeneratorObjectDetails(ErrorString* errorString, const S v8::HandleScope handles(m_isolate); V8FunctionCall function(m_client, context(), v8Value(), "getGeneratorObjectDetails"); function.appendArgument(objectId); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); protocol::ErrorSupport errors(errorString); - *result = GeneratorObjectDetails::parse(resultValue, &errors); + *result = GeneratorObjectDetails::parse(resultValue.get(), &errors); } void InjectedScript::getCollectionEntries(ErrorString* errorString, const String& objectId, OwnPtr<Array<CollectionEntry>>* result) @@ -276,10 +271,9 @@ void InjectedScript::getCollectionEntries(ErrorString* errorString, const String v8::HandleScope handles(m_isolate); V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntries"); function.appendArgument(objectId); - RefPtr<protocol::Value> resultValue; - makeCall(function, &resultValue); + OwnPtr<protocol::Value> resultValue = makeCall(function); protocol::ErrorSupport errors(errorString); - *result = Array<CollectionEntry>::parse(resultValue, &errors); + *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); } void InjectedScript::getProperties(ErrorString* errorString, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, OwnPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) @@ -291,15 +285,14 @@ void InjectedScript::getProperties(ErrorString* errorString, const String& objec function.appendArgument(accessorPropertiesOnly); function.appendArgument(generatePreview); - RefPtr<protocol::Value> result; - makeCallWithExceptionDetails(function, &result, exceptionDetails); + OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exceptionDetails); if (exceptionDetails->isJust()) { // FIXME: make properties optional *properties = Array<PropertyDescriptor>::create(); return; } protocol::ErrorSupport errors(errorString); - *properties = Array<PropertyDescriptor>::parse(result.release(), &errors); + *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); } void InjectedScript::getInternalProperties(ErrorString* errorString, const String& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) @@ -308,22 +301,21 @@ void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperties"); function.appendArgument(objectId); - RefPtr<protocol::Value> result; - makeCallWithExceptionDetails(function, &result, exceptionDetails); + OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exceptionDetails); if (exceptionDetails->isJust()) return; protocol::ErrorSupport errors(errorString); - OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDescriptor>::parse(result.release(), &errors); + OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDescriptor>::parse(result.get(), &errors); if (!errors.hasErrors() && array->length() > 0) *properties = array.release(); } void InjectedScript::releaseObject(const String& objectId) { - RefPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); + OwnPtr<protocol::Value> parsedObjectId = protocol::parseJSON(objectId); if (!parsedObjectId) return; - RefPtr<protocol::DictionaryValue> object = protocol::DictionaryValue::cast(parsedObjectId); + protocol::DictionaryValue* object = protocol::DictionaryValue::cast(parsedObjectId.get()); if (!object) return; int boundId = 0; @@ -360,10 +352,10 @@ PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object bool hadException = false; v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); ASSERT(!hadException); - RefPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue); + OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue); protocol::ErrorSupport errors; if (result && result->type() == protocol::Value::TypeArray) - return Array<CallFrame>::parse(result.release(), &errors); + return Array<CallFrame>::parse(result.get(), &errors); return Array<CallFrame>::create(); } @@ -380,7 +372,7 @@ PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local if (hadException) return nullptr; protocol::ErrorSupport errors; - return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r), &errors); + return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).get(), &errors); } PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const @@ -398,7 +390,7 @@ PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< if (hadException) return nullptr; protocol::ErrorSupport errors; - return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r), &errors); + return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r).get(), &errors); } v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const @@ -428,8 +420,7 @@ void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) v8::HandleScope handles(m_isolate); V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectFormatterEnabled"); function.appendArgument(enabled); - RefPtr<protocol::Value> result; - makeCall(function, &result); + makeCall(function); } bool InjectedScript::canAccessInspectedWindow() const @@ -464,11 +455,12 @@ v8::Local<v8::Value> InjectedScript::callFunctionWithEvalEnabled(V8FunctionCall& return resultValue; } -void InjectedScript::makeCall(V8FunctionCall& function, RefPtr<protocol::Value>* result) +PassOwnPtr<protocol::Value> InjectedScript::makeCall(V8FunctionCall& function) { + OwnPtr<protocol::Value> result; if (!canAccessInspectedWindow()) { - *result = protocol::StringValue::create("Can not access given context."); - return; + result = protocol::StringValue::create("Can not access given context."); + return nullptr; } bool hadException = false; @@ -476,50 +468,51 @@ void InjectedScript::makeCall(V8FunctionCall& function, RefPtr<protocol::Value>* ASSERT(!hadException); if (!hadException) { - *result = toProtocolValue(function.context(), resultValue); - if (!*result) - *result = protocol::StringValue::create(String::format("Object has too long reference chain(must not be longer than %d)", protocol::Value::maxDepth)); + result = toProtocolValue(function.context(), resultValue); + if (!result) + result = protocol::StringValue::create(String::format("Object has too long reference chain(must not be longer than %d)", protocol::Value::maxDepth)); } else { - *result = protocol::StringValue::create("Exception while making a call."); + result = protocol::StringValue::create("Exception while making a call."); } + return result.release(); } -void InjectedScript::makeEvalCall(ErrorString* errorString, V8FunctionCall& function, OwnPtr<protocol::Runtime::RemoteObject>* objectResult, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) +PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::makeEvalCall(ErrorString* errorString, V8FunctionCall& function, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { - RefPtr<protocol::Value> result; - makeCall(function, &result); + OwnPtr<protocol::Value> result = makeCall(function); if (!result) { *errorString = "Internal error: result value is empty"; - return; + return nullptr; } if (result->type() == protocol::Value::TypeString) { result->asString(errorString); ASSERT(errorString->length()); - return; + return nullptr; } - RefPtr<protocol::DictionaryValue> resultPair = protocol::DictionaryValue::cast(result); + protocol::DictionaryValue* resultPair = protocol::DictionaryValue::cast(result.get()); if (!resultPair) { *errorString = "Internal error: result is not an Object"; - return; + return nullptr; } - RefPtr<protocol::DictionaryValue> resultObj = resultPair->getObject("result"); + protocol::DictionaryValue* resultObj = resultPair->getObject("result"); bool wasThrownVal = false; if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) { *errorString = "Internal error: result is not a pair of value and wasThrown flag"; - return; + return nullptr; } if (wasThrownVal) { - RefPtr<protocol::DictionaryValue> objectExceptionDetails = resultPair->getObject("exceptionDetails"); + protocol::DictionaryValue* objectExceptionDetails = resultPair->getObject("exceptionDetails"); if (objectExceptionDetails) - *exceptionDetails = toExceptionDetails(objectExceptionDetails.release()); + *exceptionDetails = toExceptionDetails(objectExceptionDetails); } protocol::ErrorSupport errors(errorString); - *objectResult = protocol::Runtime::RemoteObject::parse(resultObj, &errors); *wasThrown = wasThrownVal; + return protocol::Runtime::RemoteObject::parse(resultObj, &errors); } -void InjectedScript::makeCallWithExceptionDetails(V8FunctionCall& function, RefPtr<protocol::Value>* result, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) +PassOwnPtr<protocol::Value> InjectedScript::makeCallWithExceptionDetails(V8FunctionCall& function, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { + OwnPtr<protocol::Value> result; v8::HandleScope handles(m_isolate); v8::Context::Scope scope(context()); v8::TryCatch tryCatch(m_isolate); @@ -529,10 +522,11 @@ void InjectedScript::makeCallWithExceptionDetails(V8FunctionCall& function, RefP String text = !message.IsEmpty() ? toWTFStringWithTypeCheck(message->Get()) : "Internal error"; *exceptionDetails = protocol::Runtime::ExceptionDetails::create().setText(text).build(); } else { - *result = toProtocolValue(function.context(), resultValue); - if (!*result) - *result = protocol::StringValue::create(String::format("Object has too long reference chain(must not be longer than %d)", protocol::Value::maxDepth)); + result = toProtocolValue(function.context(), resultValue); + if (!result) + result = protocol::StringValue::create(String::format("Object has too long reference chain(must not be longer than %d)", protocol::Value::maxDepth)); } + return result.release(); } void InjectedScript::dispose() diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h index ece0f9d..591e6b5 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScript.h @@ -125,9 +125,9 @@ private: bool canAccessInspectedWindow() const; v8::Local<v8::Value> v8Value() const; v8::Local<v8::Value> callFunctionWithEvalEnabled(V8FunctionCall&, bool& hadException) const; - void makeCall(V8FunctionCall&, RefPtr<protocol::Value>* result); - void makeEvalCall(ErrorString*, V8FunctionCall&, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* = 0); - void makeCallWithExceptionDetails(V8FunctionCall&, RefPtr<protocol::Value>* result, Maybe<protocol::Runtime::ExceptionDetails>*); + PassOwnPtr<protocol::Value> makeCall(V8FunctionCall&); + PassOwnPtr<protocol::Runtime::RemoteObject> makeEvalCall(ErrorString*, V8FunctionCall&, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* = 0); + PassOwnPtr<protocol::Value> makeCallWithExceptionDetails(V8FunctionCall&, Maybe<protocol::Runtime::ExceptionDetails>*); InjectedScriptManager* m_manager; v8::Isolate* m_isolate; diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.cpp index 38b4350..29d94c8 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.cpp @@ -75,11 +75,11 @@ void InjectedScriptHost::disconnect() m_inspectedObjects.clear(); } -void InjectedScriptHost::inspectImpl(PassRefPtr<protocol::Value> object, PassRefPtr<protocol::Value> hints) +void InjectedScriptHost::inspectImpl(PassOwnPtr<protocol::Value> object, PassOwnPtr<protocol::Value> hints) { if (m_inspectCallback) { protocol::ErrorSupport errors; - OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(object, &errors); + OwnPtr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(object.get(), &errors); (*m_inspectCallback)(remoteObject.release(), protocol::DictionaryValue::cast(hints)); } } diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.h b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.h index b4e32af..6573888 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.h +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptHost.h @@ -67,7 +67,7 @@ public: void clearInspectedObjects(); V8RuntimeAgent::Inspectable* inspectedObject(unsigned num); - void inspectImpl(PassRefPtr<protocol::Value> objectToInspect, PassRefPtr<protocol::Value> hints); + void inspectImpl(PassOwnPtr<protocol::Value> objectToInspect, PassOwnPtr<protocol::Value> hints); void clearConsoleMessages(); void debugFunction(const String& scriptId, int lineNumber, int columnNumber); diff --git a/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.cpp b/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.cpp index 35f7159..5cc5bf1 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.cpp @@ -14,13 +14,13 @@ namespace blink { RemoteObjectIdBase::RemoteObjectIdBase() : m_injectedScriptId(0) { } -PassRefPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId(const String& objectId) +PassOwnPtr<protocol::DictionaryValue> RemoteObjectIdBase::parseInjectedScriptId(const String& objectId) { - RefPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId); + OwnPtr<protocol::Value> parsedValue = protocol::parseJSON(objectId); if (!parsedValue || parsedValue->type() != protocol::Value::TypeObject) return nullptr; - RefPtr<protocol::DictionaryValue> parsedObjectId = protocol::DictionaryValue::cast(parsedValue.release()); + OwnPtr<protocol::DictionaryValue> parsedObjectId = adoptPtr(protocol::DictionaryValue::cast(parsedValue.leakPtr())); bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScriptId); if (success) return parsedObjectId.release(); @@ -32,7 +32,7 @@ RemoteObjectId::RemoteObjectId() : RemoteObjectIdBase(), m_id(0) { } PassOwnPtr<RemoteObjectId> RemoteObjectId::parse(const String& objectId) { OwnPtr<RemoteObjectId> result = adoptPtr(new RemoteObjectId()); - RefPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScriptId(objectId); + OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScriptId(objectId); if (!parsedObjectId) return nullptr; @@ -47,7 +47,7 @@ RemoteCallFrameId::RemoteCallFrameId() : RemoteObjectIdBase(), m_frameOrdinal(0) PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String& objectId) { OwnPtr<RemoteCallFrameId> result = adoptPtr(new RemoteCallFrameId()); - RefPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScriptId(objectId); + OwnPtr<protocol::DictionaryValue> parsedObjectId = result->parseInjectedScriptId(objectId); if (!parsedObjectId) return nullptr; @@ -55,7 +55,7 @@ PassOwnPtr<RemoteCallFrameId> RemoteCallFrameId::parse(const String& objectId) if (!success) return nullptr; - RefPtr<protocol::Value> value = parsedObjectId->get("asyncOrdinal"); + protocol::Value* value = parsedObjectId->get("asyncOrdinal"); if (value &&!value->asNumber(&result->m_asyncStackOrdinal)) return nullptr; return result.release(); diff --git a/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.h b/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.h index 6f45483..005a5c1 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.h +++ b/third_party/WebKit/Source/platform/v8_inspector/RemoteObjectId.h @@ -23,7 +23,7 @@ protected: RemoteObjectIdBase(); ~RemoteObjectIdBase() { } - PassRefPtr<protocol::DictionaryValue> parseInjectedScriptId(const String&); + PassOwnPtr<protocol::DictionaryValue> parseInjectedScriptId(const String&); int m_injectedScriptId; }; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp index f974afb..f0ca783 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp @@ -285,7 +285,7 @@ void V8DebuggerAgentImpl::internalSetAsyncCallStackDepth(int depth) m_v8AsyncCallTracker->asyncCallTrackingStateChanged(m_maxAsyncCallStackDepth); } -void V8DebuggerAgentImpl::setInspectorState(PassRefPtr<protocol::DictionaryValue> state) +void V8DebuggerAgentImpl::setInspectorState(protocol::DictionaryValue* state) { m_state = state; } @@ -336,9 +336,9 @@ bool V8DebuggerAgentImpl::isPaused() return debugger().isPaused(); } -static PassRefPtr<protocol::DictionaryValue> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex) +static PassOwnPtr<protocol::DictionaryValue> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex) { - RefPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryValue::create(); breakpointObject->setString(DebuggerAgentState::url, url); breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); @@ -384,18 +384,18 @@ void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, bool isRegex = optionalURLRegex.isJust(); String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber); - RefPtr<protocol::DictionaryValue> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); + protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); if (!breakpointsCookie) { - breakpointsCookie = protocol::DictionaryValue::create(); - m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie); + OwnPtr<protocol::DictionaryValue> newValue = protocol::DictionaryValue::create(); + breakpointsCookie = newValue.get(); + m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, newValue.release()); } - if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) { + if (breakpointsCookie->get(breakpointId)) { *errorString = "Breakpoint at specified location already exists."; return; } breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, isRegex)); - m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie); ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); for (auto& script : m_scripts) { @@ -449,7 +449,7 @@ void V8DebuggerAgentImpl::removeBreakpoint(ErrorString* errorString, const Strin { if (!checkEnabled(errorString)) return; - RefPtr<protocol::DictionaryValue> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); + protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); if (breakpointsCookie) breakpointsCookie->remove(breakpointId); removeBreakpoint(breakpointId); @@ -776,7 +776,7 @@ void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S injectedScript->getCollectionEntries(errorString, objectId, entries); } -void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) +void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) { ASSERT(enabled()); if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isPaused()) @@ -1033,7 +1033,7 @@ void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, *errorString = "Either call frame or function object must be specified"; return; } - String newValueString = protocol::toValue(newValue)->toJSONString(); + String newValueString = protocol::toValue(newValue.get())->toJSONString(); v8::HandleScope scope(m_isolate); v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString); @@ -1496,12 +1496,12 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr if (scriptURL.isEmpty() || !parsedScript.success) return; - RefPtr<protocol::DictionaryValue> breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); + protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAgentState::javaScriptBreakpoints); if (!breakpointsCookie) return; for (auto& cookie : *breakpointsCookie) { - RefPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryValue::cast(cookie.value); + protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue::cast(cookie.value.get()); bool isRegex; breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); String url; @@ -1579,7 +1579,7 @@ V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 if (!m_asyncOperationNotifications.isEmpty()) flushAsyncOperationEvents(nullptr); - m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData, hitBreakpointIds.release(), currentAsyncStackTrace()); + m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData.release(), hitBreakpointIds.release(), currentAsyncStackTrace()); m_scheduledDebuggerStep = NoStep; m_javaScriptPauseScheduled = false; m_steppingFromFramework = false; @@ -1608,7 +1608,7 @@ bool V8DebuggerAgentImpl::canBreakProgram() return debugger().canBreakProgram(); } -void V8DebuggerAgentImpl::breakProgram(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) +void V8DebuggerAgentImpl::breakProgram(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) { ASSERT(enabled()); if (m_skipAllPauses || !m_pausedContext.IsEmpty() || isCallStackEmptyOrBlackboxed()) @@ -1622,7 +1622,7 @@ void V8DebuggerAgentImpl::breakProgram(const String& breakReason, PassRefPtr<pro debugger().breakProgram(); } -void V8DebuggerAgentImpl::breakProgramOnException(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) +void V8DebuggerAgentImpl::breakProgramOnException(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) { if (m_debugger->pauseOnExceptionsState() == V8DebuggerImpl::DontPauseOnExceptions) return; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.h b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.h index 0196862..73f390a 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.h @@ -61,7 +61,7 @@ public: V8DebuggerAgentImpl(InjectedScriptManager*, V8DebuggerImpl*, int contextGroupId); ~V8DebuggerAgentImpl() override; - void setInspectorState(PassRefPtr<protocol::DictionaryValue>) override; + void setInspectorState(protocol::DictionaryValue*) override; void setFrontend(protocol::Frontend::Debugger* frontend) override { m_frontend = frontend; } void clearFrontend() override; void restore() override; @@ -165,11 +165,11 @@ public: const String& scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> positions) override; - void schedulePauseOnNextStatement(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) override; + void schedulePauseOnNextStatement(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) override; void cancelPauseOnNextStatement() override; bool canBreakProgram() override; - void breakProgram(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) override; - void breakProgramOnException(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) override; + void breakProgram(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) override; + void breakProgramOnException(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) override; void willExecuteScript(int scriptId) override; void didExecuteScript() override; @@ -251,7 +251,7 @@ private: V8DebuggerImpl* m_debugger; int m_contextGroupId; bool m_enabled; - RefPtr<protocol::DictionaryValue> m_state; + protocol::DictionaryValue* m_state; protocol::Frontend::Debugger* m_frontend; v8::Isolate* m_isolate; v8::Global<v8::Context> m_pausedContext; @@ -262,7 +262,7 @@ private: MuteBreakpoins m_muteBreakpoints; String m_continueToLocationBreakpointId; String m_breakReason; - RefPtr<protocol::DictionaryValue> m_breakAuxData; + OwnPtr<protocol::DictionaryValue> m_breakAuxData; DebuggerStep m_scheduledDebuggerStep; bool m_skipNextDebuggerStepOut; bool m_javaScriptPauseScheduled; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.h b/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.h index 366951b..428318c 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8HeapProfilerAgentImpl.h @@ -23,7 +23,7 @@ public: explicit V8HeapProfilerAgentImpl(v8::Isolate*, V8RuntimeAgent*); ~V8HeapProfilerAgentImpl() override; - void setInspectorState(PassRefPtr<protocol::DictionaryValue> state) override { m_state = state; } + void setInspectorState(protocol::DictionaryValue* state) override { m_state = state; } void setFrontend(protocol::Frontend::HeapProfiler* frontend) override { m_frontend = frontend; } void clearFrontend() override; void restore() override; @@ -54,7 +54,7 @@ private: v8::Isolate* m_isolate; V8RuntimeAgent* m_runtimeAgent; protocol::Frontend::HeapProfiler* m_frontend; - RefPtr<protocol::DictionaryValue> m_state; + protocol::DictionaryValue* m_state; }; } // namespace blink diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h index b92f003..b71ac26 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8ProfilerAgentImpl.h @@ -25,7 +25,7 @@ public: explicit V8ProfilerAgentImpl(V8Debugger*); ~V8ProfilerAgentImpl() override; - void setInspectorState(PassRefPtr<protocol::DictionaryValue> state) override { m_state = state; } + void setInspectorState(protocol::DictionaryValue* state) override { m_state = state; } void setFrontend(protocol::Frontend::Profiler* frontend) override { m_frontend = frontend; } void clearFrontend() override; void restore() override; @@ -52,7 +52,7 @@ private: V8DebuggerImpl* m_debugger; v8::Isolate* m_isolate; - RefPtr<protocol::DictionaryValue> m_state; + protocol::DictionaryValue* m_state; protocol::Frontend::Profiler* m_frontend; bool m_enabled; bool m_recordingCPUProfile; diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp index 6e684ef..64d8664 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.cpp @@ -301,7 +301,7 @@ void V8RuntimeAgentImpl::runScript(ErrorString* errorString, *result = injectedScript->wrapObject(value, objectGroup.fromMaybe("")); } -void V8RuntimeAgentImpl::setInspectorState(PassRefPtr<protocol::DictionaryValue> state) +void V8RuntimeAgentImpl::setInspectorState(protocol::DictionaryValue* state) { m_state = state; } diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.h b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.h index 9075d84..41fc727 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.h +++ b/third_party/WebKit/Source/platform/v8_inspector/V8RuntimeAgentImpl.h @@ -56,7 +56,7 @@ public: ~V8RuntimeAgentImpl() override; // State management methods. - void setInspectorState(PassRefPtr<protocol::DictionaryValue>) override; + void setInspectorState(protocol::DictionaryValue*) override; void setFrontend(protocol::Frontend::Runtime*) override; void clearFrontend() override; void restore() override; @@ -131,7 +131,7 @@ private: void reportExecutionContextDestroyed(v8::Local<v8::Context>) override; PassOwnPtr<protocol::Runtime::ExceptionDetails> createExceptionDetails(v8::Isolate*, v8::Local<v8::Message>); - RefPtr<protocol::DictionaryValue> m_state; + protocol::DictionaryValue* m_state; protocol::Frontend::Runtime* m_frontend; OwnPtr<InjectedScriptManager> m_injectedScriptManager; V8DebuggerImpl* m_debugger; diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8Debugger.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8Debugger.h index 7ec6369..cd4646f 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8Debugger.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8Debugger.h @@ -27,7 +27,7 @@ public: template <typename T> class Agent { public: - virtual void setInspectorState(PassRefPtr<protocol::DictionaryValue>) = 0; + virtual void setInspectorState(protocol::DictionaryValue*) = 0; virtual void setFrontend(T*) = 0; virtual void clearFrontend() = 0; virtual void restore() = 0; diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerAgent.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerAgent.h index 573a8b6..c05ab71 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerAgent.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8DebuggerAgent.h @@ -21,11 +21,11 @@ public: virtual ~V8DebuggerAgent() { } // API for the embedder to report native activities. - virtual void schedulePauseOnNextStatement(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) = 0; + virtual void schedulePauseOnNextStatement(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) = 0; virtual void cancelPauseOnNextStatement() = 0; virtual bool canBreakProgram() = 0; - virtual void breakProgram(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) = 0; - virtual void breakProgramOnException(const String& breakReason, PassRefPtr<protocol::DictionaryValue> data) = 0; + virtual void breakProgram(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) = 0; + virtual void breakProgramOnException(const String& breakReason, PassOwnPtr<protocol::DictionaryValue> data) = 0; virtual void willExecuteScript(int scriptId) = 0; virtual void didExecuteScript() = 0; virtual void reset() = 0; diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8RuntimeAgent.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8RuntimeAgent.h index bfceb64..baa2c83 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8RuntimeAgent.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8RuntimeAgent.h @@ -35,7 +35,7 @@ public: // Embedder API. using ClearConsoleCallback = Function<void()>; virtual void setClearConsoleCallback(PassOwnPtr<ClearConsoleCallback>) = 0; - using InspectCallback = Function<void(PassOwnPtr<protocol::Runtime::RemoteObject>, PassRefPtr<protocol::DictionaryValue>)>; + using InspectCallback = Function<void(PassOwnPtr<protocol::Runtime::RemoteObject>, PassOwnPtr<protocol::DictionaryValue>)>; virtual void setInspectObjectCallback(PassOwnPtr<InspectCallback>) = 0; // FIXME: remove while preserving the default context evaluation. virtual int ensureDefaultContextAvailable(v8::Local<v8::Context>) = 0; diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.cpp b/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.cpp index 8c4a921..4bd0b37f 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.cpp +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.cpp @@ -15,7 +15,7 @@ static String coreString(v8::Local<v8::String> v8String) return result; } -PassRefPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth) +PassOwnPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth) { if (value.IsEmpty()) { ASSERT_NOT_REACHED(); @@ -36,21 +36,21 @@ PassRefPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8:: return protocol::StringValue::create(coreString(value.As<v8::String>())); if (value->IsArray()) { v8::Local<v8::Array> array = value.As<v8::Array>(); - RefPtr<protocol::ListValue> inspectorArray = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> inspectorArray = protocol::ListValue::create(); uint32_t length = array->Length(); for (uint32_t i = 0; i < length; i++) { v8::Local<v8::Value> value; if (!array->Get(context, i).ToLocal(&value)) return nullptr; - RefPtr<protocol::Value> element = toProtocolValue(context, value, maxDepth); + OwnPtr<protocol::Value> element = toProtocolValue(context, value, maxDepth); if (!element) return nullptr; - inspectorArray->pushValue(element); + inspectorArray->pushValue(element.release()); } - return inspectorArray; + return inspectorArray.release(); } if (value->IsObject()) { - RefPtr<protocol::DictionaryValue> jsonObject = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> jsonObject = protocol::DictionaryValue::create(); v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); v8::Local<v8::Array> propertyNames; if (!object->GetPropertyNames(context).ToLocal(&propertyNames)) @@ -72,12 +72,12 @@ PassRefPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8:: v8::Local<v8::Value> property; if (!object->Get(context, name).ToLocal(&property)) return nullptr; - RefPtr<protocol::Value> propertyValue = toProtocolValue(context, property, maxDepth); + OwnPtr<protocol::Value> propertyValue = toProtocolValue(context, property, maxDepth); if (!propertyValue) return nullptr; - jsonObject->setValue(coreString(propertyName), propertyValue); + jsonObject->setValue(coreString(propertyName), propertyValue.release()); } - return jsonObject; + return jsonObject.release(); } ASSERT_NOT_REACHED(); return nullptr; diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.h b/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.h index ee152ce..165d7c9 100644 --- a/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.h +++ b/third_party/WebKit/Source/platform/v8_inspector/public/V8ToProtocolValue.h @@ -10,7 +10,7 @@ namespace blink { -PLATFORM_EXPORT PassRefPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context>, v8::Local<v8::Value>, int maxDepth = protocol::Value::maxDepth); +PLATFORM_EXPORT PassOwnPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context>, v8::Local<v8::Value>, int maxDepth = protocol::Value::maxDepth); } // namespace blink diff --git a/third_party/WebKit/Source/web/InspectorOverlay.cpp b/third_party/WebKit/Source/web/InspectorOverlay.cpp index 01f2fb5..3d380b7 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.cpp +++ b/third_party/WebKit/Source/web/InspectorOverlay.cpp @@ -400,9 +400,9 @@ void InspectorOverlay::rebuildOverlayPage() m_layoutEditor->rebuild(); } -static PassRefPtr<protocol::DictionaryValue> buildObjectForSize(const IntSize& size) +static PassOwnPtr<protocol::DictionaryValue> buildObjectForSize(const IntSize& size) { - RefPtr<protocol::DictionaryValue> result = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> result = protocol::DictionaryValue::create(); result->setNumber("width", size.width()); result->setNumber("height", size.height()); return result.release(); @@ -425,7 +425,7 @@ void InspectorOverlay::drawNodeHighlight() for (unsigned i = 0; i < elements->length(); ++i) { Element* element = elements->item(i); InspectorHighlight highlight(element, m_nodeHighlightConfig, false); - RefPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtocolValue(); + OwnPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtocolValue(); evaluateInOverlay("drawHighlight", highlightJSON.release()); } } @@ -435,7 +435,7 @@ void InspectorOverlay::drawNodeHighlight() if (m_eventTargetNode) highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighlightConfig); - RefPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtocolValue(); + OwnPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtocolValue(); evaluateInOverlay("drawHighlight", highlightJSON.release()); } @@ -532,7 +532,7 @@ LocalFrame* InspectorOverlay::overlayMainFrame() void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& documentScrollOffset) { - RefPtr<protocol::DictionaryValue> resetData = protocol::DictionaryValue::create(); + OwnPtr<protocol::DictionaryValue> resetData = protocol::DictionaryValue::create(); resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScaleFactor()); resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFactor()); resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); @@ -545,16 +545,16 @@ void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume void InspectorOverlay::evaluateInOverlay(const String& method, const String& argument) { ScriptForbiddenScope::AllowUserAgentScript allowScript; - RefPtr<protocol::ListValue> command = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> command = protocol::ListValue::create(); command->pushValue(protocol::StringValue::create(method)); command->pushValue(protocol::StringValue::create(argument)); toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld("dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisabled); } -void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<protocol::Value> argument) +void InspectorOverlay::evaluateInOverlay(const String& method, PassOwnPtr<protocol::Value> argument) { ScriptForbiddenScope::AllowUserAgentScript allowScript; - RefPtr<protocol::ListValue> command = protocol::ListValue::create(); + OwnPtr<protocol::ListValue> command = protocol::ListValue::create(); command->pushValue(protocol::StringValue::create(method)); command->pushValue(argument); toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld("dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisabled); diff --git a/third_party/WebKit/Source/web/InspectorOverlay.h b/third_party/WebKit/Source/web/InspectorOverlay.h index c16af67..bc2a614e 100644 --- a/third_party/WebKit/Source/web/InspectorOverlay.h +++ b/third_party/WebKit/Source/web/InspectorOverlay.h @@ -130,7 +130,7 @@ private: LocalFrame* overlayMainFrame(); void reset(const IntSize& viewportSize, const IntPoint& documentScrollOffset); void evaluateInOverlay(const String& method, const String& argument); - void evaluateInOverlay(const String& method, PassRefPtr<protocol::Value> argument); + void evaluateInOverlay(const String& method, PassOwnPtr<protocol::Value> argument); void onTimer(Timer<InspectorOverlay>*); void rebuildOverlayPage(); void invalidate(); diff --git a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp index e352d20..0b249dd 100644 --- a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp +++ b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp @@ -487,7 +487,7 @@ void WebDevToolsAgentImpl::initializeDeferredAgents() m_workerAgent->setPageConsoleAgent(m_pageConsoleAgent); m_pageRuntimeAgent->v8Agent()->setClearConsoleCallback(bind<>(&InspectorConsoleAgent::clearAllMessages, m_pageConsoleAgent.get())); - m_pageRuntimeAgent->v8Agent()->setInspectObjectCallback(bind<PassOwnPtr<protocol::Runtime::RemoteObject>, PassRefPtr<protocol::DictionaryValue>>(&InspectorInspectorAgent::inspect, m_inspectorAgent.get())); + m_pageRuntimeAgent->v8Agent()->setInspectObjectCallback(bind<PassOwnPtr<protocol::Runtime::RemoteObject>, PassOwnPtr<protocol::DictionaryValue>>(&InspectorInspectorAgent::inspect, m_inspectorAgent.get())); if (m_overlay) m_overlay->init(cssAgent, debuggerAgent, m_domAgent.get()); @@ -650,7 +650,7 @@ void WebDevToolsAgentImpl::failedToRequestDevTools() ClientMessageLoopAdapter::resumeForCreateWindow(); } -void WebDevToolsAgentImpl::sendProtocolResponse(int sessionId, int callId, PassRefPtr<protocol::DictionaryValue> message) +void WebDevToolsAgentImpl::sendProtocolResponse(int sessionId, int callId, PassOwnPtr<protocol::DictionaryValue> message) { if (!m_attached) return; @@ -667,7 +667,7 @@ void WebDevToolsAgentImpl::sendProtocolResponse(int sessionId, int callId, PassR m_client->sendProtocolMessage(sessionId, callId, message->toJSONString(), stateToSend); } -void WebDevToolsAgentImpl::sendProtocolNotification(PassRefPtr<protocol::DictionaryValue> message) +void WebDevToolsAgentImpl::sendProtocolNotification(PassOwnPtr<protocol::DictionaryValue> message) { if (!m_attached) return; diff --git a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h index efbab9b..9e34e15 100644 --- a/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h +++ b/third_party/WebKit/Source/web/WebDevToolsAgentImpl.h @@ -133,8 +133,8 @@ private: void waitForCreateWindow(LocalFrame*) override; // protocol::FrontendChannel implementation. - void sendProtocolResponse(int sessionId, int callId, PassRefPtr<protocol::DictionaryValue> message) override; - void sendProtocolNotification(PassRefPtr<protocol::DictionaryValue> message) override; + void sendProtocolResponse(int sessionId, int callId, PassOwnPtr<protocol::DictionaryValue> message) override; + void sendProtocolNotification(PassOwnPtr<protocol::DictionaryValue> message) override; void flush() override; // WebThread::TaskObserver implementation. @@ -173,7 +173,7 @@ private: InspectorAgentRegistry m_agents; bool m_deferredAgentsInitialized; - typedef Vector<std::pair<int, RefPtr<protocol::Value>>> NotificationQueue; + typedef Vector<std::pair<int, OwnPtr<protocol::Value>>> NotificationQueue; NotificationQueue m_notificationQueue; int m_sessionId; String m_stateCookie; |