diff options
-rw-r--r-- | base/callback.h | 6 | ||||
-rw-r--r-- | base/callback.h.pump | 6 | ||||
-rw-r--r-- | chrome/browser/chrome_benchmarking_message_filter.cc | 45 |
3 files changed, 21 insertions, 36 deletions
diff --git a/base/callback.h b/base/callback.h index 001dd07..967677e 100644 --- a/base/callback.h +++ b/base/callback.h @@ -124,7 +124,7 @@ // There are three main components to the system: // 1) The Callback classes. // 2) The Bind() functions. -// 3) The arguments wrappers (eg., Unretained() and ConstRef()). +// 3) The arguments wrappers (e.g., Unretained() and ConstRef()). // // The Callback classes represent a generic function pointer. Internally, // it stores a refcounted piece of state that represents the target function @@ -160,7 +160,7 @@ // to refcount a target object if the function being bound is a class method. // // To change this behavior, we introduce a set of argument wrappers -// (eg. Unretained(), and ConstRef()). These are simple container templates +// (e.g., Unretained(), and ConstRef()). These are simple container templates // that are passed by value, and wrap a pointer to argument. See the // file-level comment in base/bind_helpers.h for more info. // @@ -197,7 +197,7 @@ // Lastly, tr1::function and tr1::bind has a more general and flexible API. // This includes things like argument reordering by use of // tr1::bind::placeholder, support for non-const reference parameters, and some -// limited amount of subtyping of the tr1::function object (eg., +// limited amount of subtyping of the tr1::function object (e.g., // tr1::function<int(int)> is convertible to tr1::function<void(int)>). // // These are not features that are required in Chromium. Some of them, such as diff --git a/base/callback.h.pump b/base/callback.h.pump index 82660f3..882cae9 100644 --- a/base/callback.h.pump +++ b/base/callback.h.pump @@ -129,7 +129,7 @@ $var MAX_ARITY = 7 // There are three main components to the system: // 1) The Callback classes. // 2) The Bind() functions. -// 3) The arguments wrappers (eg., Unretained() and ConstRef()). +// 3) The arguments wrappers (e.g., Unretained() and ConstRef()). // // The Callback classes represent a generic function pointer. Internally, // it stores a refcounted piece of state that represents the target function @@ -165,7 +165,7 @@ $var MAX_ARITY = 7 // to refcount a target object if the function being bound is a class method. // // To change this behavior, we introduce a set of argument wrappers -// (eg. Unretained(), and ConstRef()). These are simple container templates +// (e.g., Unretained(), and ConstRef()). These are simple container templates // that are passed by value, and wrap a pointer to argument. See the // file-level comment in base/bind_helpers.h for more info. // @@ -202,7 +202,7 @@ $var MAX_ARITY = 7 // Lastly, tr1::function and tr1::bind has a more general and flexible API. // This includes things like argument reordering by use of // tr1::bind::placeholder, support for non-const reference parameters, and some -// limited amount of subtyping of the tr1::function object (eg., +// limited amount of subtyping of the tr1::function object (e.g., // tr1::function<int(int)> is convertible to tr1::function<void(int)>). // // These are not features that are required in Chromium. Some of them, such as diff --git a/chrome/browser/chrome_benchmarking_message_filter.cc b/chrome/browser/chrome_benchmarking_message_filter.cc index 3421192..f1ef69c 100644 --- a/chrome/browser/chrome_benchmarking_message_filter.cc +++ b/chrome/browser/chrome_benchmarking_message_filter.cc @@ -22,23 +22,12 @@ namespace { -class ClearCacheHelper { - public: - ClearCacheHelper(ChromeBenchmarkingMessageFilter* filter, - IPC::Message* reply_msg) - : filter_(filter), - reply_msg_(reply_msg) { - } - - void Run(int result) { - ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg_, result); - filter_->Send(reply_msg_); - } - - private: - scoped_refptr<ChromeBenchmarkingMessageFilter> filter_; - IPC::Message* reply_msg_; -}; +void ClearCacheCallback(ChromeBenchmarkingMessageFilter* filter, + IPC::Message* reply_msg, + int result) { + ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result); + 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. @@ -50,13 +39,11 @@ class DoomEntriesHelper { iter_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(callback_( base::Bind(&DoomEntriesHelper::CacheCallback, - base::Unretained(this)))), - clear_cache_helper_(NULL) { + base::Unretained(this)))) { } - // Takes ownership of |callback|. - void ClearCache(ClearCacheHelper* helper) { - clear_cache_helper_.reset(helper); + void ClearCache(const net::CompletionCallback& callback) { + clear_cache_callback_ = callback; return CacheCallback(net::OK); // Start clearing the cache. } @@ -66,7 +53,7 @@ class DoomEntriesHelper { void CacheCallback(int result) { do { if (result != net::OK) { - clear_cache_helper_->Run(result); + clear_cache_callback_.Run(result); delete this; return; } @@ -90,7 +77,7 @@ class DoomEntriesHelper { disk_cache::Entry* entry_; void* iter_; net::CompletionCallback callback_; - scoped_ptr<ClearCacheHelper> clear_cache_helper_; + net::CompletionCallback clear_cache_callback_; }; } // namespace @@ -138,16 +125,14 @@ void ChromeBenchmarkingMessageFilter::OnClearCache(bool preserve_ssl_host_info, disk_cache::Backend* backend = request_context_->GetURLRequestContext()-> http_transaction_factory()->GetCache()->GetCurrentBackend(); if (backend) { - scoped_ptr<ClearCacheHelper> clear_cache_helper( - new ClearCacheHelper(this, reply_msg)); + net::CompletionCallback callback = + base::Bind(&ClearCacheCallback, make_scoped_refptr(this), reply_msg); if (preserve_ssl_host_info) { DoomEntriesHelper* helper = new DoomEntriesHelper(backend); - helper->ClearCache(clear_cache_helper.release()); // Will self clean. + helper->ClearCache(callback); // Will self clean. return; } else { - rv = backend->DoomAllEntries( - base::Bind(&ClearCacheHelper::Run, - base::Owned(clear_cache_helper.release()))); + rv = backend->DoomAllEntries(callback); if (rv == net::ERR_IO_PENDING) { // The callback will send the reply. return; |