From df16ed24d3cdb487fa37b7b8cb5d6c74926a95dd Mon Sep 17 00:00:00 2001 From: "willchan@chromium.org" Date: Tue, 7 Dec 2010 05:15:44 +0000 Subject: Fix webkit URLRequestJob subtypes to handle Kill() correctly. Kill() should prevent calling back into the delegate. So we cancel pending callbacks. BUG=63692 TEST=existing Review URL: http://codereview.chromium.org/5545003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68445 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/appcache/appcache_request_handler.h | 1 - webkit/appcache/appcache_url_request_job.cc | 12 ++++++++---- webkit/appcache/appcache_url_request_job.h | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'webkit/appcache') diff --git a/webkit/appcache/appcache_request_handler.h b/webkit/appcache/appcache_request_handler.h index e07a77c..b1cb331 100644 --- a/webkit/appcache/appcache_request_handler.h +++ b/webkit/appcache/appcache_request_handler.h @@ -124,4 +124,3 @@ class AppCacheRequestHandler : public net::URLRequest::UserData, } // namespace appcache #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ - diff --git a/webkit/appcache/appcache_url_request_job.cc b/webkit/appcache/appcache_url_request_job.cc index c70cd7a..6a61674 100644 --- a/webkit/appcache/appcache_url_request_job.cc +++ b/webkit/appcache/appcache_url_request_job.cc @@ -6,6 +6,7 @@ #include "webkit/appcache/appcache_url_request_job.h" +#include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -27,7 +28,8 @@ AppCacheURLRequestJob::AppCacheURLRequestJob( cache_id_(kNoCacheId), is_fallback_(false), cache_entry_not_found_(false), ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( - this, &AppCacheURLRequestJob::OnReadComplete)) { + this, &AppCacheURLRequestJob::OnReadComplete)), + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { DCHECK(storage_); } @@ -67,8 +69,10 @@ void AppCacheURLRequestJob::MaybeBeginDelivery() { if (has_been_started() && has_delivery_orders()) { // Start asynchronously so that all error reporting and data // callbacks happen as they would for network requests. - MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &AppCacheURLRequestJob::BeginDelivery)); + MessageLoop::current()->PostTask( + FROM_HERE, + method_factory_.NewRunnableMethod( + &AppCacheURLRequestJob::BeginDelivery)); } } @@ -210,6 +214,7 @@ void AppCacheURLRequestJob::Kill() { storage_ = NULL; } URLRequestJob::Kill(); + method_factory_.RevokeAll(); } } @@ -278,4 +283,3 @@ void AppCacheURLRequestJob::SetExtraRequestHeaders( } } // namespace appcache - diff --git a/webkit/appcache/appcache_url_request_job.h b/webkit/appcache/appcache_url_request_job.h index 8630815..7491e71 100644 --- a/webkit/appcache/appcache_url_request_job.h +++ b/webkit/appcache/appcache_url_request_job.h @@ -7,6 +7,7 @@ #include +#include "base/task.h" #include "net/http/http_byte_range.h" #include "net/url_request/url_request_job.h" #include "webkit/appcache/appcache_entry.h" @@ -20,8 +21,7 @@ namespace appcache { class AppCacheURLRequestJob : public net::URLRequestJob, public AppCacheStorage::Delegate { public: - explicit AppCacheURLRequestJob(net::URLRequest* request, - AppCacheStorage* storage); + AppCacheURLRequestJob(net::URLRequest* request, AppCacheStorage* storage); virtual ~AppCacheURLRequestJob(); // Informs the job of what response it should deliver. Only one of these @@ -143,9 +143,9 @@ class AppCacheURLRequestJob : public net::URLRequestJob, scoped_ptr range_response_info_; scoped_ptr reader_; net::CompletionCallbackImpl read_callback_; + ScopedRunnableMethodFactory method_factory_; }; } // namespace appcache #endif // WEBKIT_APPCACHE_APPCACHE_REQUEST_HANDLER_H_ - -- cgit v1.1