summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/render_message_filter.cc68
-rw-r--r--chrome/browser/renderer_host/render_message_filter.h2
-rw-r--r--chrome/common/render_messages_internal.h10
-rw-r--r--chrome/renderer/render_thread.cc4
-rw-r--r--chrome/renderer/render_thread.h4
-rw-r--r--chrome/renderer/renderer_glue.cc4
-rw-r--r--webkit/extensions/v8/benchmarking_extension.cc9
-rw-r--r--webkit/glue/webkit_glue.h4
8 files changed, 86 insertions, 19 deletions
diff --git a/chrome/browser/renderer_host/render_message_filter.cc b/chrome/browser/renderer_host/render_message_filter.cc
index f4f8514..4ae24e0 100644
--- a/chrome/browser/renderer_host/render_message_filter.cc
+++ b/chrome/browser/renderer_host/render_message_filter.cc
@@ -269,6 +269,55 @@ class OpenChannelToPpapiPluginCallback : public RenderMessageCompletionCallback,
}
};
+// Class to assist with clearing out the cache when we want to preserve
+// the sslhostinfo entries. It's not very efficient, but its just for debug.
+class DoomEntriesHelper {
+ public:
+ explicit DoomEntriesHelper(disk_cache::Backend* backend)
+ : backend_(backend),
+ entry_(NULL),
+ iter_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_(this,
+ &DoomEntriesHelper::CacheCallback)),
+ user_callback_(NULL) {
+ }
+
+ void ClearCache(ClearCacheCompletion* callback) {
+ user_callback_ = callback;
+ return CacheCallback(net::OK); // Start clearing the cache.
+ }
+
+ private:
+ void CacheCallback(int result) {
+ do {
+ if (result != net::OK) {
+ user_callback_->RunWithParams(Tuple1<int>(result));
+ delete this;
+ return;
+ }
+
+ if (entry_) {
+ // Doom all entries except those with snapstart information.
+ std::string key = entry_->GetKey();
+ if (key.find("sslhostinfo:") != 0) {
+ entry_->Doom();
+ backend_->EndEnumeration(&iter_);
+ iter_ = NULL; // We invalidated our iterator - start from the top!
+ }
+ entry_->Close();
+ entry_ = NULL;
+ }
+ result = backend_->OpenNextEntry(&iter_, &entry_, &callback_);
+ } while (result != net::ERR_IO_PENDING);
+ }
+
+ disk_cache::Backend* backend_;
+ disk_cache::Entry* entry_;
+ void* iter_;
+ net::CompletionCallbackImpl<DoomEntriesHelper> callback_;
+ ClearCacheCompletion* user_callback_;
+};
+
} // namespace
RenderMessageFilter::RenderMessageFilter(
@@ -1324,7 +1373,8 @@ void RenderMessageFilter::OnSetCacheMode(bool enabled) {
http_cache->set_mode(mode);
}
-void RenderMessageFilter::OnClearCache(IPC::Message* reply_msg) {
+void RenderMessageFilter::OnClearCache(bool preserve_ssl_host_info,
+ IPC::Message* reply_msg) {
// This function is disabled unless the user has enabled
// benchmarking extensions.
int rv = -1;
@@ -1334,13 +1384,19 @@ void RenderMessageFilter::OnClearCache(IPC::Message* reply_msg) {
if (backend) {
ClearCacheCompletion* callback =
new ClearCacheCompletion(this, reply_msg);
- rv = backend->DoomAllEntries(callback);
- if (rv == net::ERR_IO_PENDING) {
- // The callback will send the reply.
+ if (preserve_ssl_host_info) {
+ DoomEntriesHelper* helper = new DoomEntriesHelper(backend);
+ helper->ClearCache(callback); // Will self clean.
return;
+ } else {
+ rv = backend->DoomAllEntries(callback);
+ if (rv == net::ERR_IO_PENDING) {
+ // The callback will send the reply.
+ return;
+ }
+ // Completed synchronously, no need for the callback.
+ delete callback;
}
- // Completed synchronously, no need for the callback.
- delete callback;
}
}
ViewHostMsg_ClearCache::WriteReplyParams(reply_msg, rv);
diff --git a/chrome/browser/renderer_host/render_message_filter.h b/chrome/browser/renderer_host/render_message_filter.h
index a0339de..ff50fab 100644
--- a/chrome/browser/renderer_host/render_message_filter.h
+++ b/chrome/browser/renderer_host/render_message_filter.h
@@ -308,7 +308,7 @@ class RenderMessageFilter : public BrowserMessageFilter,
void OnCloseCurrentConnections();
void OnSetCacheMode(bool enabled);
- void OnClearCache(IPC::Message* reply_msg);
+ void OnClearCache(bool preserve_ssl_host_info, IPC::Message* reply_msg);
void OnCacheableMetadataAvailable(const GURL& url,
double expected_response_time,
const std::vector<char>& data);
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index d48dbd5..49ab928 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -108,7 +108,7 @@ IPC_MESSAGE_CONTROL3(ViewMsg_SetCacheCapacities,
size_t /* max_dead_capacity */,
size_t /* capacity */)
-// Tells the renderer to cleat the cache.
+// Tells the renderer to clear the cache.
IPC_MESSAGE_CONTROL0(ViewMsg_ClearCache)
// Reply in response to ViewHostMsg_ShowView or ViewHostMsg_ShowWidget.
@@ -2241,8 +2241,12 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_SetCacheMode,
// Message sent from the renderer to the browser to request that the browser
// clear the cache. Used for debugging/testing.
-IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_ClearCache,
- int /* result */)
+// |preserve_ssl_host_info| controls whether clearing the cache will preserve
+// persisted SSL information stored in the cache.
+// |result| is the returned status from the operation.
+IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_ClearCache,
+ bool /* preserve_ssl_host_info */,
+ int /* result */)
// Message sent from the renderer to the browser to request that the browser
// enable or disable spdy. Used for debugging/testing/benchmarking.
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index fc74a39..85bcddc 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -768,9 +768,9 @@ void RenderThread::SetCacheMode(bool enabled) {
Send(new ViewHostMsg_SetCacheMode(enabled));
}
-void RenderThread::ClearCache() {
+void RenderThread::ClearCache(bool preserve_ssl_host_info) {
int rv;
- Send(new ViewHostMsg_ClearCache(&rv));
+ Send(new ViewHostMsg_ClearCache(preserve_ssl_host_info, &rv));
}
void RenderThread::EnableSpdy(bool enable) {
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index bfb9e55..97bb0ef 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -215,7 +215,9 @@ class RenderThread : public RenderThreadBase,
void SetCacheMode(bool enabled);
// Sends a message to the browser to clear the disk cache.
- void ClearCache();
+ // |preserve_ssl_host_info| is a flag indicating if the cache should purge
+ // entries related to cached SSL information.
+ void ClearCache(bool preserve_ssl_host_info);
// Sends a message to the browser to enable/disable spdy.
void EnableSpdy(bool enable);
diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc
index ecbf7f5..7ba91ff 100644
--- a/chrome/renderer/renderer_glue.cc
+++ b/chrome/renderer/renderer_glue.cc
@@ -256,8 +256,8 @@ void SetCacheMode(bool enabled) {
RenderThread::current()->SetCacheMode(enabled);
}
-void ClearCache() {
- RenderThread::current()->ClearCache();
+void ClearCache(bool preserve_ssl_host_info) {
+ RenderThread::current()->ClearCache(preserve_ssl_host_info);
}
std::string GetProductVersion() {
diff --git a/webkit/extensions/v8/benchmarking_extension.cc b/webkit/extensions/v8/benchmarking_extension.cc
index 2fa56eb0..600eafa 100644
--- a/webkit/extensions/v8/benchmarking_extension.cc
+++ b/webkit/extensions/v8/benchmarking_extension.cc
@@ -27,9 +27,9 @@ class BenchmarkingWrapper : public v8::Extension {
"if (typeof(chrome.benchmarking) == 'undefined') {"
" chrome.benchmarking = {};"
"};"
- "chrome.benchmarking.clearCache = function() {"
+ "chrome.benchmarking.clearCache = function(preserve_ssl_entries) {"
" native function ClearCache();"
- " ClearCache();"
+ " ClearCache(preserve_ssl_entries);"
"};"
"chrome.benchmarking.closeConnections = function() {"
" native function CloseConnections();"
@@ -94,7 +94,10 @@ class BenchmarkingWrapper : public v8::Extension {
}
static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) {
- webkit_glue::ClearCache();
+ bool preserve_ssl_host_entries = false;
+ if (args.Length() && args[0]->IsBoolean())
+ preserve_ssl_host_entries = args[0]->BooleanValue();
+ webkit_glue::ClearCache(preserve_ssl_host_entries);
WebCache::clear();
return v8::Undefined();
}
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 5df2aea..c742c09 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -265,7 +265,9 @@ void CloseCurrentConnections();
void SetCacheMode(bool enabled);
// Clear the disk cache. Used for debugging.
-void ClearCache();
+// |preserve_ssl_host_info| indicates whether disk cache entries related to
+// SSL information should be purged.
+void ClearCache(bool preserve_ssl_host_info);
// Returns the product version. E.g., Chrome/4.1.333.0
std::string GetProductVersion();