diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-20 16:01:03 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-20 16:01:03 +0000 |
commit | a95972d843da1bfe3b0c5a3d850604dc660609d7 (patch) | |
tree | 955c8f5ba9a7a45601a68f1f2f744b63e8ee1f6d /webkit/glue/devtools | |
parent | daa071ea80b8498f497ed41b4892e5e02208e38d (diff) | |
download | chromium_src-a95972d843da1bfe3b0c5a3d850604dc660609d7.zip chromium_src-a95972d843da1bfe3b0c5a3d850604dc660609d7.tar.gz chromium_src-a95972d843da1bfe3b0c5a3d850604dc660609d7.tar.bz2 |
Add support for Javascript function callbacks into the WebDevToolsClient.
Review URL: http://codereview.chromium.org/42443
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools')
-rw-r--r-- | webkit/glue/devtools/devtools_rpc.cc | 13 | ||||
-rw-r--r-- | webkit/glue/devtools/devtools_rpc.h | 14 | ||||
-rw-r--r-- | webkit/glue/devtools/dom_agent.h | 15 | ||||
-rw-r--r-- | webkit/glue/devtools/dom_agent_impl.cc | 35 | ||||
-rw-r--r-- | webkit/glue/devtools/dom_agent_impl.h | 10 | ||||
-rw-r--r-- | webkit/glue/devtools/dom_agent_unittest.cc | 107 | ||||
-rw-r--r-- | webkit/glue/devtools/net_agent.h | 7 | ||||
-rw-r--r-- | webkit/glue/devtools/net_agent_impl.cc | 4 | ||||
-rw-r--r-- | webkit/glue/devtools/net_agent_impl.h | 3 |
9 files changed, 128 insertions, 80 deletions
diff --git a/webkit/glue/devtools/devtools_rpc.cc b/webkit/glue/devtools/devtools_rpc.cc index e392ef9..c19e373 100644 --- a/webkit/glue/devtools/devtools_rpc.cc +++ b/webkit/glue/devtools/devtools_rpc.cc @@ -61,6 +61,14 @@ void DevToolsRpc::GetListValue( void DevToolsRpc::GetListValue( const ListValue& message, int index, + std::string* value) { + message.GetString(index, value); +} + +// static +void DevToolsRpc::GetListValue( + const ListValue& message, + int index, Value** value) { message.Get(index, value); } @@ -72,6 +80,11 @@ Value* DevToolsRpc::CreateValue(const String* value) { } // static +Value* DevToolsRpc::CreateValue(const std::string* value) { + return Value::CreateStringValue(*value); +} + +// static Value* DevToolsRpc::CreateValue(int* value) { return Value::CreateIntegerValue(*value); } diff --git a/webkit/glue/devtools/devtools_rpc.h b/webkit/glue/devtools/devtools_rpc.h index c85b32a..56d5266 100644 --- a/webkit/glue/devtools/devtools_rpc.h +++ b/webkit/glue/devtools/devtools_rpc.h @@ -95,6 +95,15 @@ struct RpcTypeTrait<String> { } }; +template<> +struct RpcTypeTrait<std::string> { + typedef const std::string& ApiType; + typedef std::string DispatchType; + static const DispatchType& Pass(const DispatchType& t) { + return t; + } +}; + /////////////////////////////////////////////////////// // RPC Api method declarations @@ -343,6 +352,10 @@ class DevToolsRpc { const ListValue& message, int index, String* value); + static void GetListValue( + const ListValue& message, + int index, + std::string* value); static void GetListValue(const ListValue& message, int index, Value** value); protected: @@ -352,6 +365,7 @@ class DevToolsRpc { private: // Value adapters for supported Rpc types. static Value* CreateValue(const String* value); + static Value* CreateValue(const std::string* value); static Value* CreateValue(int* value); static Value* CreateValue(bool* value); static Value* CreateValue(const Value* value); diff --git a/webkit/glue/devtools/dom_agent.h b/webkit/glue/devtools/dom_agent.h index a2d8818..491adb8 100644 --- a/webkit/glue/devtools/dom_agent.h +++ b/webkit/glue/devtools/dom_agent.h @@ -13,10 +13,10 @@ // DomAgent's environment is represented with the DomAgentDelegate interface. #define DOM_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3) \ /* Requests that the document root element is sent to the delegate. */ \ - METHOD0(GetDocumentElement) \ + METHOD1(GetDocumentElement, int /* call_id */) \ \ /* Requests that the element's children are sent to the client. */ \ - METHOD1(GetChildNodes, int /* id */) \ + METHOD2(GetChildNodes, int /* call_id */, int /* id */) \ \ /* Sets attribute value in the element with given id. */ \ METHOD3(SetAttribute, int /* id */, String /* name */, String /* value */) \ @@ -35,14 +35,17 @@ DEFINE_RPC_CLASS(DomAgent, DOM_AGENT_STRUCT) #define DOM_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3) \ - /* Notifies the delegate that document element is available. */ \ - METHOD1(DocumentElementUpdated, Value /* node */) \ + /* Response to GetDocumentElement. */ \ + METHOD2(GetDocumentElementResult, int /* call_id */, std::string /* json */) \ + \ + /* Response to GetChildNodes. */ \ + METHOD2(GetChildNodesResult, int /* call_id */, std::string /* json */) \ \ /* Notifies the delegate that element's attributes are updated. */ \ METHOD2(AttributesUpdated, int /* id */, Value /* attributes */) \ \ /* Notifies the delegate that element's child nodes have been updated. */ \ - METHOD2(ChildNodesUpdated, int /* id */, Value /* node */) \ + METHOD2(ChildNodesUpdated, int /* parent_id */, Value /* nodes */) \ \ /* Notifies the delegate that element's 'has children' state has been updated */ \ @@ -53,7 +56,7 @@ DEFINE_RPC_CLASS(DomAgent, DOM_AGENT_STRUCT) Value /* node */) \ \ /* Notifies the delegate that child node has been deleted. */ \ - METHOD2(ChildNodeRemoved, int /* parent_id */, int /* id */) + METHOD2(ChildNodeRemoved, int /* parent_id */, int /* id */) \ DEFINE_RPC_CLASS(DomAgentDelegate, DOM_AGENT_DELEGATE_STRUCT) diff --git a/webkit/glue/devtools/dom_agent_impl.cc b/webkit/glue/devtools/dom_agent_impl.cc index 4cdbf1e..28b11da 100644 --- a/webkit/glue/devtools/dom_agent_impl.cc +++ b/webkit/glue/devtools/dom_agent_impl.cc @@ -20,6 +20,7 @@ #include <wtf/Vector.h> #undef LOG +#include "base/json_writer.h" #include "base/values.h" #include "webkit/glue/devtools/dom_agent_impl.h" #include "webkit/glue/glue_util.h" @@ -46,7 +47,7 @@ void DomAgentImpl::EventListenerWrapper::handleEvent( DomAgentImpl::DomAgentImpl(DomAgentDelegate* delegate) : delegate_(delegate), last_node_id_(1), - document_element_requested_(false) { + document_element_call_id_(0) { event_listener_ = EventListenerWrapper::Create(this); } @@ -66,15 +67,15 @@ void DomAgentImpl::SetDocument(Document* doc) { if (doc) { StartListening(doc); - if (document_element_requested_) { - GetDocumentElement(); - document_element_requested_ = false; + if (document_element_call_id_) { + GetDocumentElement(document_element_call_id_); + document_element_call_id_ = 0; } } } void DomAgentImpl::StartListening(Document* doc) { - if (documents_.find(doc) != documents_.end()) + if (documents_.contains(doc)) return; doc->addEventListener(eventNames().DOMContentLoadedEvent, event_listener_, false); @@ -179,8 +180,7 @@ void DomAgentImpl::handleEvent(Event* event, bool isWindowEvent) { // Parent is not mapped yet -> ignore the event. return; } - HashSet<int>::iterator cit = children_requested_.find(parent_id); - if (cit == children_requested_.end()) { + if (!children_requested_.contains(parent_id)) { // No children are mapped yet -> only notify on changes of hasChildren. delegate_->HasChildrenUpdated(parent_id, true); } else { @@ -196,8 +196,7 @@ void DomAgentImpl::handleEvent(Event* event, bool isWindowEvent) { // Parent is not mapped yet -> ignore the event. return; } - HashSet<int>::iterator cit = children_requested_.find(parent_id); - if (cit == children_requested_.end()) { + if (!children_requested_.contains(parent_id)) { // No children are mapped yet -> only notify on changes of hasChildren. if (parent->childNodeCount() == 1) delegate_->HasChildrenUpdated(parent_id, false); @@ -210,17 +209,19 @@ void DomAgentImpl::handleEvent(Event* event, bool isWindowEvent) { } } -void DomAgentImpl::GetDocumentElement() { +void DomAgentImpl::GetDocumentElement(int call_id) { if (documents_.size() > 0) { OwnPtr<Value> value( BuildValueForNode((*documents_.begin())->documentElement(), 0)); - delegate_->DocumentElementUpdated(*value.get()); + std::string json; + ToJson(value.get(), &json); + delegate_->GetDocumentElementResult(call_id, json); } else { - document_element_requested_ = true; + document_element_call_id_ = call_id; } } -void DomAgentImpl::GetChildNodes(int element_id) { +void DomAgentImpl::GetChildNodes(int call_id, int element_id) { Node* node = GetNodeForId(element_id); if (!node || (node->nodeType() != Node::ELEMENT_NODE)) return; @@ -228,7 +229,9 @@ void DomAgentImpl::GetChildNodes(int element_id) { Element* element = static_cast<Element*>(node); OwnPtr<Value> children(BuildValueForElementChildren(element, 1)); children_requested_.add(element_id); - delegate_->ChildNodesUpdated(element_id, *children.get()); + std::string json; + ToJson(children.get(), &json); + delegate_->GetChildNodesResult(call_id, json); } int DomAgentImpl::GetPathToNode(Node* node_to_select) { @@ -404,3 +407,7 @@ Element* DomAgentImpl::InnerParentElement(Node* node) { } return element; } + +void DomAgentImpl::ToJson(const Value* value, std::string* json) { + JSONWriter::Write(value, false, json); +} diff --git a/webkit/glue/devtools/dom_agent_impl.h b/webkit/glue/devtools/dom_agent_impl.h index 5a58433..51e5ffa 100644 --- a/webkit/glue/devtools/dom_agent_impl.h +++ b/webkit/glue/devtools/dom_agent_impl.h @@ -32,8 +32,8 @@ class DomAgentImpl : public DomAgent { virtual ~DomAgentImpl(); // DomAgent implementation. - void GetDocumentElement(); - void GetChildNodes(int element_id); + void GetDocumentElement(int call_id); + void GetChildNodes(int call_id, int element_id); void SetAttribute( int element_id, const WebCore::String& name, @@ -103,6 +103,8 @@ class DomAgentImpl : public DomAgent { int InnerChildNodeCount(WebCore::Node* node); WebCore::Element* InnerParentElement(WebCore::Node* node); + void ToJson(const Value* value, std::string* json); + DomAgentDelegate* delegate_; HashMap<WebCore::Node*, int> node_to_id_; HashMap<int, WebCore::Node*> id_to_node_; @@ -110,7 +112,9 @@ class DomAgentImpl : public DomAgent { int last_node_id_; ListHashSet<RefPtr<WebCore::Document> > documents_; RefPtr<WebCore::EventListener> event_listener_; - bool document_element_requested_; + // Captures pending document element request's call id. + // Defaults to 0 meaning no pending request. + int document_element_call_id_; DISALLOW_COPY_AND_ASSIGN(DomAgentImpl); }; diff --git a/webkit/glue/devtools/dom_agent_unittest.cc b/webkit/glue/devtools/dom_agent_unittest.cc index ef92f8a..ce2f544 100644 --- a/webkit/glue/devtools/dom_agent_unittest.cc +++ b/webkit/glue/devtools/dom_agent_unittest.cc @@ -78,6 +78,13 @@ class DomAgentTests : public TestShellTest { static const int kHtmlElemId = 1; static const int kBodyElemId = 2; + enum { + kCallIdAny = 0, + kCallId1, + kCallId2, + kCallId3, + kCallId4 + }; RefPtr<Document> document_; RefPtr<Element> body_; @@ -88,32 +95,30 @@ class DomAgentTests : public TestShellTest { // Requests document node and tests that the callback with the serialized // version is called. -TEST_F(DomAgentTests, DocumentElementUpdated) { - OwnPtr<Value> v(DevToolsRpc::ParseMessage("[1,1,\"HTML\",\"\",[],1]")); - mock_delegate_->DocumentElementUpdated(*v.get()); +TEST_F(DomAgentTests, GetDocumentElement) { + mock_delegate_->GetDocumentElementResult(kCallId1, "[1,1,\"HTML\",\"\",[],1]"); mock_delegate_->Replay(); - dom_agent_->GetDocumentElement(); + dom_agent_->GetDocumentElement(kCallId1); mock_delegate_->Verify(); } // Requests element's children and tests that the callback with the serialized // version is called. -TEST_F(DomAgentTests, ChildNodesUpdated) { - dom_agent_->GetDocumentElement(); +TEST_F(DomAgentTests, GetChildNodes) { + dom_agent_->GetDocumentElement(kCallId1); mock_delegate_->Reset(); - OwnPtr<Value> v(DevToolsRpc::ParseMessage("[[2,1,\"BODY\",\"\",[],0]]")); - mock_delegate_->ChildNodesUpdated(1, *v.get()); + mock_delegate_->GetChildNodesResult(kCallId2, "[[2,1,\"BODY\",\"\",[],0]]"); mock_delegate_->Replay(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Verify(); } // Tests that "child node inserted" event is being fired. TEST_F(DomAgentTests, ChildNodeInsertedUnknownParent) { - dom_agent_->GetDocumentElement(); + dom_agent_->GetDocumentElement(1); mock_delegate_->Reset(); // There should be no events fired until parent node is known to client. @@ -125,8 +130,8 @@ TEST_F(DomAgentTests, ChildNodeInsertedUnknownParent) { // Tests that "child node inserted" event is being fired. TEST_F(DomAgentTests, ChildNodeInsertedKnownParent) { - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -141,9 +146,9 @@ TEST_F(DomAgentTests, ChildNodeInsertedKnownParent) { // Tests that "child node inserted" event is being fired. TEST_F(DomAgentTests, ChildNodeInsertedKnownChildren) { - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -163,9 +168,9 @@ TEST_F(DomAgentTests, ChildNodePrepend) { RefPtr<Element> div = document_->createElement("DIV", ec_); body_->appendChild(div, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -185,9 +190,9 @@ TEST_F(DomAgentTests, ChildNodeAppend) { RefPtr<Element> div = document_->createElement("DIV", ec_); body_->appendChild(div, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -209,9 +214,9 @@ TEST_F(DomAgentTests, ChildNodeInsert) { RefPtr<Element> div2 = document_->createElement("DIV", ec_); body_->appendChild(div2, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -231,7 +236,7 @@ TEST_F(DomAgentTests, ChildNodeRemovedUnknownParent) { RefPtr<Element> div = document_->createElement("DIV", ec_); body_->appendChild(div, ec_); - dom_agent_->GetDocumentElement(); + dom_agent_->GetDocumentElement(kCallId1); mock_delegate_->Reset(); // There should be no events fired until parent node is known to client. @@ -245,8 +250,8 @@ TEST_F(DomAgentTests, ChildNodeRemovedKnownParent) { RefPtr<Element> div = document_->createElement("DIV", ec_); body_->appendChild(div, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -263,9 +268,9 @@ TEST_F(DomAgentTests, ChildNodeRemovedKnownChildren) { RefPtr<Element> div = document_->createElement("DIV", ec_); body_->appendChild(div, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, @@ -282,9 +287,9 @@ TEST_F(DomAgentTests, GetPathToKnownNode) { RefPtr<Element> div1 = document_->createElement("DIV", ec_); body_->appendChild(div1, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // We expect no messages - node is already known. @@ -300,8 +305,8 @@ TEST_F(DomAgentTests, GetPathToKnownParent) { RefPtr<Element> div1 = document_->createElement("DIV", ec_); body_->appendChild(div1, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Reset(); OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[3,1,\"DIV\",\"\",[],0]]")); @@ -324,8 +329,8 @@ TEST_F(DomAgentTests, GetPathToUnknownNode) { div2->appendChild(div3, ec_); div3->appendChild(div4, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Reset(); OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[3,1,\"DIV\",\"\",[],1]]")); @@ -348,17 +353,16 @@ TEST_F(DomAgentTests, GetChildNodesOfFrameOwner) { RefPtr<Element> iframe = document_->createElement("IFRAME", ec_); body_->appendChild(iframe, ec_); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); + dom_agent_->GetChildNodes(kCallId3, kBodyElemId); mock_delegate_->Reset(); // Expecting HTML child with single (body) child. - OwnPtr<Value> v(DevToolsRpc::ParseMessage("[[4,1,\"HTML\",\"\",[],1]]")); - mock_delegate_->ChildNodesUpdated(3, *v.get()); + mock_delegate_->GetChildNodesResult(kCallId4, "[[4,1,\"HTML\",\"\",[],1]]"); mock_delegate_->Replay(); - dom_agent_->GetChildNodes(3); + dom_agent_->GetChildNodes(kCallId4, 3); mock_delegate_->Verify(); } @@ -371,8 +375,8 @@ TEST_F(DomAgentTests, GetPathToNodeOverFrameOwner) { Node* inner_body = frame_owner->contentDocument()->firstChild()-> firstChild(); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); + dom_agent_->GetDocumentElement(kCallId1); + dom_agent_->GetChildNodes(kCallId2, kHtmlElemId); mock_delegate_->Reset(); OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[3,1,\"IFRAME\",\"\",[],1]]")); @@ -381,7 +385,6 @@ TEST_F(DomAgentTests, GetPathToNodeOverFrameOwner) { mock_delegate_->ChildNodesUpdated(2, *v1.get()); mock_delegate_->ChildNodesUpdated(3, *v2.get()); mock_delegate_->ChildNodesUpdated(4, *v3.get()); - mock_delegate_->Replay(); dom_agent_->GetPathToNode(inner_body); @@ -397,12 +400,12 @@ TEST_F(DomAgentTests, ChildNodeInsertUnderFrameOwner) { Node* inner_body = frame_owner->contentDocument()->firstChild()-> firstChild(); - dom_agent_->GetDocumentElement(); - dom_agent_->GetChildNodes(kHtmlElemId); - dom_agent_->GetChildNodes(kBodyElemId); - dom_agent_->GetChildNodes(3); // IFrame children - dom_agent_->GetChildNodes(4); // IFrame html's children - dom_agent_->GetChildNodes(5); // IFrame body's children + dom_agent_->GetDocumentElement(kCallIdAny); + dom_agent_->GetChildNodes(kCallIdAny, kHtmlElemId); + dom_agent_->GetChildNodes(kCallIdAny, kBodyElemId); + dom_agent_->GetChildNodes(kCallIdAny, 3); // IFrame children + dom_agent_->GetChildNodes(kCallIdAny, 4); // IFrame html's children + dom_agent_->GetChildNodes(kCallIdAny, 5); // IFrame body's children mock_delegate_->Reset(); // There should be an event fired in case parent node is known to client, diff --git a/webkit/glue/devtools/net_agent.h b/webkit/glue/devtools/net_agent.h index 00db4af0..0921c26 100644 --- a/webkit/glue/devtools/net_agent.h +++ b/webkit/glue/devtools/net_agent.h @@ -14,7 +14,8 @@ #define NET_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3) \ /* Requests that the agent sends content of the resource with given id to the delegate. */ \ - METHOD2(GetResourceContent, int /* identifier */, String /* url */) + METHOD3(GetResourceContent, int /* call_id */, int /* identifier */, \ + String /* url */) DEFINE_RPC_CLASS(NetAgent, NET_AGENT_STRUCT) @@ -32,8 +33,8 @@ DEFINE_RPC_CLASS(NetAgent, NET_AGENT_STRUCT) /* Notifies the delegate that resource loading has failed. */ \ METHOD2(DidFailLoading, int /* identifier */, Value /* response */) \ \ - /* Calls delegate back with requested resource content. */ \ - METHOD2(SetResourceContent, int /* identifier */, String /* content */) + /* Response to the async call. */ \ + METHOD2(GetResourceContentResult, int /* call_id */, std::string /* content */) DEFINE_RPC_CLASS(NetAgentDelegate, NET_AGENT_DELEGATE_STRUCT) diff --git a/webkit/glue/devtools/net_agent_impl.cc b/webkit/glue/devtools/net_agent_impl.cc index 08a64fb..2202bd0 100644 --- a/webkit/glue/devtools/net_agent_impl.cc +++ b/webkit/glue/devtools/net_agent_impl.cc @@ -131,6 +131,7 @@ void NetAgentImpl::DidLoadResourceFromMemoryCache( } void NetAgentImpl::GetResourceContent( + int call_id, int identifier, const String& url) { if (!document_) { @@ -189,7 +190,8 @@ void NetAgentImpl::GetResourceContent( break; } } - delegate_->SetResourceContent(identifier, source); + delegate_->GetResourceContentResult(call_id, + webkit_glue::StringToStdString(source)); } Value* NetAgentImpl::BuildValueForHeaders(const HTTPHeaderMap& headers) { diff --git a/webkit/glue/devtools/net_agent_impl.h b/webkit/glue/devtools/net_agent_impl.h index b9d56fc..661ecb5 100644 --- a/webkit/glue/devtools/net_agent_impl.h +++ b/webkit/glue/devtools/net_agent_impl.h @@ -36,7 +36,8 @@ class NetAgentImpl : public NetAgent { void SetDocument(WebCore::Document* document); // NetAgent implementation. - void GetResourceContent(int identifier, const WebCore::String& request_url); + void GetResourceContent(int call_id, int identifier, + const WebCore::String& request_url); void AssignIdentifierToRequest( WebCore::DocumentLoader* loader, int identifier, |