OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" | 5 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "content/child/image_decoder.h" |
9 #include "third_party/WebKit/public/web/WebFrame.h" | 10 #include "third_party/WebKit/public/web/WebFrame.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
12 #include "webkit/glue/image_decoder.h" | |
13 | 13 |
14 using WebKit::WebFrame; | 14 using WebKit::WebFrame; |
15 using WebKit::WebURLRequest; | 15 using WebKit::WebURLRequest; |
16 using WebKit::WebURLResponse; | 16 using WebKit::WebURLResponse; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( | 20 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( |
21 const GURL& image_url, | 21 const GURL& image_url, |
22 WebFrame* frame, | 22 WebFrame* frame, |
(...skipping 16 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( | 41 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( |
42 const WebURLResponse& response, | 42 const WebURLResponse& response, |
43 const std::string& data) { | 43 const std::string& data) { |
44 std::vector<SkBitmap> bitmaps; | 44 std::vector<SkBitmap> bitmaps; |
45 if (!response.isNull()) { | 45 if (!response.isNull()) { |
46 http_status_code_ = response.httpStatusCode(); | 46 http_status_code_ = response.httpStatusCode(); |
47 if (http_status_code_ == 200) { | 47 if (http_status_code_ == 200) { |
48 // Request succeeded, try to convert it to an image. | 48 // Request succeeded, try to convert it to an image. |
49 bitmaps = webkit_glue::ImageDecoder::DecodeAll( | 49 bitmaps = ImageDecoder::DecodeAll( |
50 reinterpret_cast<const unsigned char*>(data.data()), data.size()); | 50 reinterpret_cast<const unsigned char*>(data.data()), data.size()); |
51 } | 51 } |
52 } // else case: | 52 } // else case: |
53 // If we get here, it means no image from server or couldn't decode the | 53 // If we get here, it means no image from server or couldn't decode the |
54 // response as an image. The delegate will see an empty vector. | 54 // response as an image. The delegate will see an empty vector. |
55 | 55 |
56 // Take a reference to the callback as running the callback may lead to our | 56 // Take a reference to the callback as running the callback may lead to our |
57 // destruction. | 57 // destruction. |
58 Callback callback = callback_; | 58 Callback callback = callback_; |
59 callback.Run(this, bitmaps); | 59 callback.Run(this, bitmaps); |
60 } | 60 } |
61 | 61 |
62 } // namespace content | 62 } // namespace content |
OLD | NEW |