From dd91c889e8098c44bca6f5a01c53a217852d8950 Mon Sep 17 00:00:00 2001 From: "pfeldman@chromium.org" Date: Tue, 19 May 2009 11:35:29 +0000 Subject: DevTools: do not cache xmlhttp when client is not attached; reduce agent cache size. Review URL: http://codereview.chromium.org/115508 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16364 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/devtools/net_agent_impl.cc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'webkit') diff --git a/webkit/glue/devtools/net_agent_impl.cc b/webkit/glue/devtools/net_agent_impl.cc index 184ca68..d1c45e6 100644 --- a/webkit/glue/devtools/net_agent_impl.cc +++ b/webkit/glue/devtools/net_agent_impl.cc @@ -60,6 +60,8 @@ void NetAgentImpl::Attach() { void NetAgentImpl::Detach() { attached_ = false; + xml_http_sources_.clear(); + ExpireFinishedResourcesCache(); } void NetAgentImpl::DidCommitMainResourceLoad() { @@ -151,19 +153,12 @@ void NetAgentImpl::DidFinishLoading( pending_resources_.remove(identifier); finished_resources_.append(std::make_pair(identifier, resource)); - // 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); - } - if (attached_) { DictionaryValue value; Serialize(*resource, &value); delegate_->DidFinishLoading(identifier, value); + } else { + ExpireFinishedResourcesCache(); } } @@ -191,7 +186,10 @@ void NetAgentImpl::DidLoadResourceFromMemoryCache( void NetAgentImpl::DidLoadResourceByXMLHttpRequest( int identifier, const WebCore::ScriptString& source) { - xml_http_sources_.set(identifier, source); + if (attached_) { + // Only store XmlHttpRequests data when client is attached. + xml_http_sources_.set(identifier, source); + } } void NetAgentImpl::GetResourceContent( @@ -311,3 +309,12 @@ void NetAgentImpl::Serialize(const Resource& resource, webkit_glue::StringToStdString(resource.error_description)); } } + +void NetAgentImpl::ExpireFinishedResourcesCache() { + if (finished_resources_.size() > 100) { + for (int i = 0; i < 20; ++i) { + delete finished_resources_[i].second; + } + finished_resources_.remove(0, 20); + } +} -- cgit v1.1