OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/image_loading_helper.h" | 5 #include "content/renderer/image_loading_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "content/common/image_messages.h" | 9 #include "content/common/image_messages.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 result_images.push_back(data_image); | 46 result_images.push_back(data_image); |
47 } else { | 47 } else { |
48 if (DownloadImage(id, image_url, is_favicon, image_size)) { | 48 if (DownloadImage(id, image_url, is_favicon, image_size)) { |
49 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage | 49 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage |
50 return; | 50 return; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 Send(new ImageHostMsg_DidDownloadImage(routing_id(), | 54 Send(new ImageHostMsg_DidDownloadImage(routing_id(), |
55 id, | 55 id, |
| 56 0, |
56 image_url, | 57 image_url, |
57 image_size, | 58 image_size, |
58 result_images)); | 59 result_images)); |
59 } | 60 } |
60 | 61 |
61 bool ImageLoadingHelper::DownloadImage(int id, | 62 bool ImageLoadingHelper::DownloadImage(int id, |
62 const GURL& image_url, | 63 const GURL& image_url, |
63 bool is_favicon, | 64 bool is_favicon, |
64 int image_size) { | 65 int image_size) { |
65 // Make sure webview was not shut down. | 66 // Make sure webview was not shut down. |
(...skipping 11 matching lines...) Expand all Loading... |
77 return true; | 78 return true; |
78 } | 79 } |
79 | 80 |
80 void ImageLoadingHelper::DidDownloadImage( | 81 void ImageLoadingHelper::DidDownloadImage( |
81 int requested_size, | 82 int requested_size, |
82 MultiResolutionImageResourceFetcher* fetcher, | 83 MultiResolutionImageResourceFetcher* fetcher, |
83 const std::vector<SkBitmap>& images) { | 84 const std::vector<SkBitmap>& images) { |
84 // Notify requester of image download status. | 85 // Notify requester of image download status. |
85 Send(new ImageHostMsg_DidDownloadImage(routing_id(), | 86 Send(new ImageHostMsg_DidDownloadImage(routing_id(), |
86 fetcher->id(), | 87 fetcher->id(), |
| 88 fetcher->http_status_code(), |
87 fetcher->image_url(), | 89 fetcher->image_url(), |
88 requested_size, | 90 requested_size, |
89 images)); | 91 images)); |
90 | 92 |
91 // Remove the image fetcher from our pending list. We're in the callback from | 93 // Remove the image fetcher from our pending list. We're in the callback from |
92 // MultiResolutionImageResourceFetcher, best to delay deletion. | 94 // MultiResolutionImageResourceFetcher, best to delay deletion. |
93 ImageResourceFetcherList::iterator iter = | 95 ImageResourceFetcherList::iterator iter = |
94 std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher); | 96 std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher); |
95 if (iter != image_fetchers_.end()) { | 97 if (iter != image_fetchers_.end()) { |
96 image_fetchers_.weak_erase(iter); | 98 image_fetchers_.weak_erase(iter); |
(...skipping 20 matching lines...) Expand all Loading... |
117 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) | 119 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) |
118 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) | 120 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) |
119 IPC_MESSAGE_UNHANDLED(handled = false) | 121 IPC_MESSAGE_UNHANDLED(handled = false) |
120 IPC_END_MESSAGE_MAP() | 122 IPC_END_MESSAGE_MAP() |
121 | 123 |
122 return handled; | 124 return handled; |
123 } | 125 } |
124 | 126 |
125 } // namespace content | 127 } // namespace content |
126 | 128 |
OLD | NEW |