Chromium Code Reviews| 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 |
| } |
| + |
| next_handler_->OnRequestClosed(); |
| } |
| void OfflineResourceHandler::OnCanHandleOfflineComplete(int rv) { |
| - CHECK(appcache_completion_callback_); |
|
awong
2011/11/30 00:52:55
Do we no longer need an equivalent check? Maybe C
James Hawkins
2011/11/30 01:44:58
IMO the check is superfluous (we're in the callbac
|
| - appcache_completion_callback_ = NULL; |
| if (deferred_request_id_ == -1) { |
| - LOG(WARNING) << "OnCanHandleOfflineComplete called after completion: " |
| - << " this=" << this; |
| - NOTREACHED(); |
| - return; |
| + DLOG(FATAL) << "OnCanHandleOfflineComplete called after completion: " |
| + << " this=" << this; |
|
awong
2011/11/30 00:52:55
You need a return; still.
James Hawkins
2011/11/30 01:44:58
Done.
|
| } |
| + |
| 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 |
| - DCHECK(!appcache_completion_callback_); |
| - appcache_completion_callback_ = |
| - new net::CancelableOldCompletionCallback<OfflineResourceHandler>( |
| - this, &OfflineResourceHandler::OnCanHandleOfflineComplete); |
| + |
| + DCHECK(appcache_completion_callback_.IsCancelled()); |
|
awong
2011/11/30 00:52:55
I think you still need to retain the manual AddRef
James Hawkins
2011/11/30 01:44:58
Per-offline, made the callback own |this|.
|
| + 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; |