diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-31 20:30:28 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-14 20:31:41 -0700 |
commit | 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801 (patch) | |
tree | 382278a54ce7a744d62fa510a9a80688cc12434b /webkit/glue/resource_fetcher.cc | |
parent | c4becdd46e31d261b930e4b5a539cbc1d45c23a6 (diff) | |
download | external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.zip external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.gz external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.bz2 |
Merge Chromium.org at r11.0.672.0: Initial merge by git.
Change-Id: I8b4aaf611a2a405fe3fe10e8a94ea7658645c192
Diffstat (limited to 'webkit/glue/resource_fetcher.cc')
-rw-r--r-- | webkit/glue/resource_fetcher.cc | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/webkit/glue/resource_fetcher.cc b/webkit/glue/resource_fetcher.cc index 9b00805..39cc59c 100644 --- a/webkit/glue/resource_fetcher.cc +++ b/webkit/glue/resource_fetcher.cc @@ -5,13 +5,13 @@ #include "webkit/glue/resource_fetcher.h" #include "base/logging.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" -#include "third_party/WebKit/WebKit/chromium/public/WebKit.h" -#include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURLLoader.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" using base::TimeDelta; using WebKit::WebFrame; @@ -25,8 +25,8 @@ namespace webkit_glue { ResourceFetcher::ResourceFetcher(const GURL& url, WebFrame* frame, Callback* c) : url_(url), - callback_(c), - completed_(false) { + completed_(false), + callback_(c) { // Can't do anything without a frame. However, delegate can be NULL (so we // can do a http request and ignore the results). DCHECK(frame); @@ -53,6 +53,18 @@ void ResourceFetcher::Start(WebFrame* frame) { loader_->loadAsynchronously(request, this); } +void ResourceFetcher::RunCallback(const WebURLResponse& response, + const std::string& data) { + if (!callback_.get()) + return; + + // Take care to clear callback_ before running the callback as it may lead to + // our destruction. + scoped_ptr<Callback> callback; + callback.swap(callback_); + callback->Run(response, data); +} + ///////////////////////////////////////////////////////////////////////////// // WebURLLoaderClient methods @@ -93,10 +105,7 @@ void ResourceFetcher::didFinishLoading( DCHECK(!completed_); completed_ = true; - if (callback_.get()) { - callback_->Run(response_, data_); - callback_.reset(); - } + RunCallback(response_, data_); } void ResourceFetcher::didFail(WebURLLoader* loader, const WebURLError& error) { @@ -104,10 +113,7 @@ void ResourceFetcher::didFail(WebURLLoader* loader, const WebURLError& error) { completed_ = true; // Go ahead and tell our delegate that we're done. - if (callback_.get()) { - callback_->Run(WebURLResponse(), std::string()); - callback_.reset(); - } + RunCallback(WebURLResponse(), std::string()); } ///////////////////////////////////////////////////////////////////////////// |