summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 11:35:29 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-19 11:35:29 +0000
commitdd91c889e8098c44bca6f5a01c53a217852d8950 (patch)
tree578759ea5fb42c320b1b92ad6931dce3e52f8d12 /webkit
parent21d53fa970f4faff7cf9bc2460adbeae3a8452c2 (diff)
downloadchromium_src-dd91c889e8098c44bca6f5a01c53a217852d8950.zip
chromium_src-dd91c889e8098c44bca6f5a01c53a217852d8950.tar.gz
chromium_src-dd91c889e8098c44bca6f5a01c53a217852d8950.tar.bz2
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
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/devtools/net_agent_impl.cc27
1 files changed, 17 insertions, 10 deletions
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);
+ }
+}