Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2865)

Unified Diff: chrome/browser/chrome_net_benchmarking_message_filter.cc

Issue 135373002: Added SSLHostInfo. Storing of server host info to our standard disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed wtc's comments Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_net_benchmarking_message_filter.cc
diff --git a/chrome/browser/chrome_net_benchmarking_message_filter.cc b/chrome/browser/chrome_net_benchmarking_message_filter.cc
index 04bc990c65ad3e684f0bbd124853c22d25de7006..4707e1523e47ea69ce35ee17f2b7e780b4e70e31 100644
--- a/chrome/browser/chrome_net_benchmarking_message_filter.cc
+++ b/chrome/browser/chrome_net_benchmarking_message_filter.cc
@@ -30,6 +30,57 @@ void ClearCacheCallback(ChromeNetBenchmarkingMessageFilter* filter,
filter->Send(reply_msg);
}
+// 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),
+ callback_(
+ base::Bind(&DoomEntriesHelper::CacheCallback,
+ base::Unretained(this))) {
+ }
+
+ void ClearCache(const net::CompletionCallback& callback) {
+ clear_cache_callback_ = callback;
+ return CacheCallback(net::OK); // Start clearing the cache.
+ }
+
+ const net::CompletionCallback& callback() { return callback_; }
+
+ private:
+ void CacheCallback(int result) {
+ do {
+ if (result != net::OK) {
+ clear_cache_callback_.Run(result);
+ delete this;
+ return;
+ }
+
+ if (entry_) {
+ // Doom all entries except those with sslhostinfo information.
wtc 2014/01/18 01:02:01 Nit: delete "information".
ramant (doing other things) 2014/01/18 01:28:53 Done.
+ 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::CompletionCallback callback_;
+ net::CompletionCallback clear_cache_callback_;
+};
+
} // namespace
ChromeNetBenchmarkingMessageFilter::ChromeNetBenchmarkingMessageFilter(
@@ -62,7 +113,9 @@ bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived(
return handled;
}
-void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) {
+void ChromeNetBenchmarkingMessageFilter::OnClearCache(
+ bool preserve_ssl_host_info,
+ IPC::Message* reply_msg) {
// This function is disabled unless the user has enabled
// benchmarking extensions.
if (!CheckBenchmarkingEnabled()) {
@@ -76,6 +129,11 @@ void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) {
if (backend) {
net::CompletionCallback callback =
base::Bind(&ClearCacheCallback, make_scoped_refptr(this), reply_msg);
+ if (preserve_ssl_host_info) {
+ DoomEntriesHelper* helper = new DoomEntriesHelper(backend);
+ helper->ClearCache(callback); // Will self clean.
+ return;
+ }
rv = backend->DoomAllEntries(callback);
if (rv == net::ERR_IO_PENDING) {
// The callback will send the reply.

Powered by Google App Engine
This is Rietveld 408576698