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

Unified Diff: chrome/browser/renderer_host/offline_resource_handler.cc

Issue 8662047: base::Bind: Implement a 1-arity CancelableCallback and use this to implement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/renderer_host/offline_resource_handler.cc
diff --git a/chrome/browser/renderer_host/offline_resource_handler.cc b/chrome/browser/renderer_host/offline_resource_handler.cc
index 536e27cc800110f3a89d906560d34cb4b2e9f054..4d2b9ebea77840fe51a79200184d765314421206 100644
--- a/chrome/browser/renderer_host/offline_resource_handler.cc
+++ b/chrome/browser/renderer_host/offline_resource_handler.cc
@@ -45,7 +45,7 @@ OfflineResourceHandler::OfflineResourceHandler(
OfflineResourceHandler::~OfflineResourceHandler() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!appcache_completion_callback_.get());
+ DCHECK(appcache_completion_callback_.IsCancelled());
}
bool OfflineResourceHandler::OnUploadProgress(int request_id,
@@ -77,26 +77,22 @@ bool OfflineResourceHandler::OnResponseCompleted(
}
void OfflineResourceHandler::OnRequestClosed() {
- if (appcache_completion_callback_) {
- appcache_completion_callback_->Cancel();
- appcache_completion_callback_.release();
+ if (!appcache_completion_callback_.IsCancelled()) {
+ appcache_completion_callback_.Cancel();
Release(); // Balanced with OnWillStart
michaeln 2011/11/30 01:18:21 looks like another balancing call to Release() tha
James Hawkins 2011/11/30 01:44:58 Done.
}
+
next_handler_->OnRequestClosed();
}
void OfflineResourceHandler::OnCanHandleOfflineComplete(int rv) {
- CHECK(appcache_completion_callback_);
- appcache_completion_callback_ = NULL;
if (deferred_request_id_ == -1) {
- LOG(WARNING) << "OnCanHandleOfflineComplete called after completion: "
- << " this=" << this;
- NOTREACHED();
- return;
michaeln 2011/11/30 01:18:21 assuming DLOG() is a noop in release builds, it'd
James Hawkins 2011/11/30 01:44:58 Done.
+ DLOG(FATAL) << "OnCanHandleOfflineComplete called after completion: "
+ << " this=" << this;
}
+
if (rv == net::OK) {
Resume();
- Release(); // Balanced with OnWillStart
} else {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -112,14 +108,13 @@ bool OfflineResourceHandler::OnWillStart(int request_id,
deferred_url_ = url;
DVLOG(1) << "OnWillStart: this=" << this << ", request id=" << request_id
<< ", url=" << url;
- AddRef(); // Balanced with OnCanHandleOfflineComplete
michaeln 2011/11/30 01:18:21 just checking... does the base::Bind do the AddRef
James Hawkins 2011/11/30 01:44:58 Yes.
- DCHECK(!appcache_completion_callback_);
- appcache_completion_callback_ =
- new net::CancelableOldCompletionCallback<OfflineResourceHandler>(
- this, &OfflineResourceHandler::OnCanHandleOfflineComplete);
+
+ DCHECK(appcache_completion_callback_.IsCancelled());
+ appcache_completion_callback_.Reset(
+ base::Bind(&OfflineResourceHandler::OnCanHandleOfflineComplete, this));
appcache_service_->CanHandleMainResourceOffline(
url, request_->first_party_for_cookies(),
- appcache_completion_callback_);
+ appcache_completion_callback_.callback());
*defer = true;
return true;

Powered by Google App Engine
This is Rietveld 408576698