diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 16:44:39 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-07 16:44:39 +0000 |
commit | f6134ff2597f45c240b1fc2a493d38b51aa8a884 (patch) | |
tree | beddc103816d95a1f73a586eb523251154f84e6b /webkit/glue/image_resource_fetcher.cc | |
parent | 62c9a8e3985009ee3503497cb4e1ab18d8cecc97 (diff) | |
download | chromium_src-f6134ff2597f45c240b1fc2a493d38b51aa8a884.zip chromium_src-f6134ff2597f45c240b1fc2a493d38b51aa8a884.tar.gz chromium_src-f6134ff2597f45c240b1fc2a493d38b51aa8a884.tar.bz2 |
Modify ResourceFetcher to use WebURLLoader instead of ResourceHandle.
This is step 1 of moving ResourceFetcher usage out of WebFrame. This
CL adds a new method to WebFrame, named DispatchWillSendRequest, which
may be used to associate a WebURLRequest with the WebFrame. This
triggers the WebViewDelegate's WillSendRequest method among other things.
ResourceFetcher and friends have been modified to use callbacks instead
of delegates. I just find this approach a bit cleaner and easier to
work with.
BUG=15648
TEST=none
R=brettw
Review URL: http://codereview.chromium.org/149172
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20031 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/image_resource_fetcher.cc')
-rw-r--r-- | webkit/glue/image_resource_fetcher.cc | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/webkit/glue/image_resource_fetcher.cc b/webkit/glue/image_resource_fetcher.cc index 5320468c..8c63cc5 100644 --- a/webkit/glue/image_resource_fetcher.cc +++ b/webkit/glue/image_resource_fetcher.cc @@ -2,34 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "config.h" - -#include "base/compiler_specific.h" - -MSVC_PUSH_WARNING_LEVEL(0); -#include "ImageSourceSkia.h" -MSVC_POP_WARNING(); -#undef LOG - #include "webkit/glue/image_resource_fetcher.h" #include "base/gfx/size.h" #include "webkit/glue/image_decoder.h" -#include "webkit/glue/webview_impl.h" +#include "webkit/glue/webframe.h" #include "third_party/skia/include/core/SkBitmap.h" +namespace webkit_glue { + ImageResourceFetcher::ImageResourceFetcher( - WebViewImpl* web_view, - int id, const GURL& image_url, - int image_size) - : web_view_(web_view), + WebFrame* frame, + int id, + int image_size, + Callback* callback) + : callback_(callback), id_(id), image_url_(image_url), image_size_(image_size) { - fetcher_.reset(new ResourceFetcher(image_url, - web_view->main_frame()->frame(), - this)); + fetcher_.reset(new ResourceFetcher( + image_url, frame, + NewCallback(this, &ImageResourceFetcher::OnURLFetchComplete))); } ImageResourceFetcher::~ImageResourceFetcher() { @@ -38,21 +32,19 @@ ImageResourceFetcher::~ImageResourceFetcher() { } void ImageResourceFetcher::OnURLFetchComplete( - const WebCore::ResourceResponse& response, + const WebKit::WebURLResponse& response, const std::string& data) { - SkBitmap image; - bool errored = false; - if (response.isNull()) { - errored = true; - } else if (response.httpStatusCode() == 200) { + SkBitmap bitmap; + if (!response.isNull() && response.httpStatusCode() == 200) { // Request succeeded, try to convert it to an image. - webkit_glue::ImageDecoder decoder(gfx::Size(image_size_, image_size_)); - image = decoder.Decode( + ImageDecoder decoder(gfx::Size(image_size_, image_size_)); + bitmap = decoder.Decode( reinterpret_cast<const unsigned char*>(data.data()), data.size()); } // else case: // If we get here, it means no image from server or couldn't decode the - // response as an image. Need to notify the webview though, otherwise the - // browser will keep trying to download favicon (when this is used to - // download the favicon). - web_view_->ImageResourceDownloadDone(this, errored, image); + // response as an image. The delegate will see a null image, indicating + // that an error occurred. + callback_->Run(this, bitmap); } + +} // namespace webkit_glue |