diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 09:22:32 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 09:22:32 +0000 |
commit | 4cc874f542d307a0c24469ffc8e89ed4e3650eb6 (patch) | |
tree | 50167bffbe5235684cbfcb43c8cf73dc5de15e42 /webkit/glue | |
parent | 2808c92a233971bf6c4ce19ddb87cd3ce3eb5858 (diff) | |
download | chromium_src-4cc874f542d307a0c24469ffc8e89ed4e3650eb6.zip chromium_src-4cc874f542d307a0c24469ffc8e89ed4e3650eb6.tar.gz chromium_src-4cc874f542d307a0c24469ffc8e89ed4e3650eb6.tar.bz2 |
DevTools: Support XmlHTTPRequests sniffing.
Review URL: http://codereview.chromium.org/100262
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/devtools/net_agent_impl.cc | 13 | ||||
-rw-r--r-- | webkit/glue/devtools/net_agent_impl.h | 9 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 9 |
3 files changed, 28 insertions, 3 deletions
diff --git a/webkit/glue/devtools/net_agent_impl.cc b/webkit/glue/devtools/net_agent_impl.cc index 5aba9bb..5b04662 100644 --- a/webkit/glue/devtools/net_agent_impl.cc +++ b/webkit/glue/devtools/net_agent_impl.cc @@ -18,6 +18,7 @@ #include "ResourceError.h" #include "ResourceRequest.h" #include "ResourceResponse.h" +#include "ScriptString.h" #include "TextEncoding.h" #include <wtf/CurrentTime.h> #undef LOG @@ -155,6 +156,7 @@ void NetAgentImpl::DidFinishLoading( // Start removing resources from the cache once there are too many of them. if (finished_resources_.size() > 200) { for (int i = 0; i < 50; ++i) { + xml_http_sources_.remove(finished_resources_[i].first); delete finished_resources_[i].second; } finished_resources_.remove(0, 50); @@ -187,6 +189,12 @@ void NetAgentImpl::DidLoadResourceFromMemoryCache( int identifier = last_cached_identifier_--; } +void NetAgentImpl::DidLoadResourceByXMLHttpRequest( + int identifier, + const WebCore::ScriptString& source) { + xml_http_sources_.set(identifier, source); +} + void NetAgentImpl::GetResourceContent( int call_id, int identifier, @@ -197,7 +205,10 @@ void NetAgentImpl::GetResourceContent( String source; - if (main_loader_.get() && main_loader_->requestURL() == url) { + WebCore::ScriptString script = xml_http_sources_.get(identifier); + if (!script.isNull()) { + source = String(script); + } else if (main_loader_.get() && main_loader_->requestURL() == url) { RefPtr<SharedBuffer> buffer = main_loader_->mainResourceData(); String text_encoding_name = document_->inputEncoding(); if (buffer) { diff --git a/webkit/glue/devtools/net_agent_impl.h b/webkit/glue/devtools/net_agent_impl.h index 893c4b5..e1d882b 100644 --- a/webkit/glue/devtools/net_agent_impl.h +++ b/webkit/glue/devtools/net_agent_impl.h @@ -20,6 +20,7 @@ class DocumentLoader; class HTTPHeaderMap; class ResourceError; class ResourceResponse; +class ScriptString; class String; struct ResourceRequest; } @@ -78,6 +79,10 @@ class NetAgentImpl : public NetAgent { const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, int length); + void DidLoadResourceByXMLHttpRequest( + int identifier, + const WebCore::ScriptString& source); + private: // Serializes headers map into a value. @@ -89,8 +94,12 @@ class NetAgentImpl : public NetAgent { typedef HashMap<int, DictionaryValue*, DefaultHash<int>::Hash, WTF::UnsignedWithZeroKeyHashTraits<int> > ResourcesMap; typedef Vector<std::pair<int, DictionaryValue*> > FinishedResources; + typedef HashMap<int, WebCore::ScriptString, DefaultHash<int>::Hash, + WTF::UnsignedWithZeroKeyHashTraits<int> > XmlHttpSources; + ResourcesMap pending_resources_; FinishedResources finished_resources_; + XmlHttpSources xml_http_sources_; int last_cached_identifier_; bool attached_; DISALLOW_COPY_AND_ASSIGN(NetAgentImpl); diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 24843ba..b2cdae9 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -468,8 +468,13 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( unsigned long identifier, - const ScriptString&) { - //TODO(pfeldman): Wire to net_agent. + const ScriptString& source) { + NetAgentImpl* net_agent = GetNetAgentImpl(); + if (net_agent) { + net_agent->DidLoadResourceByXMLHttpRequest( + identifier, + source); + } } void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { |