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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 result_images.push_back(data_image); | 47 result_images.push_back(data_image); |
48 } else { | 48 } else { |
49 if (DownloadImage(id, image_url, is_favicon, image_size)) { | 49 if (DownloadImage(id, image_url, is_favicon, image_size)) { |
50 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage | 50 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage |
51 return; | 51 return; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 Send(new ImageHostMsg_DidDownloadImage(routing_id(), | 55 Send(new ImageHostMsg_DidDownloadImage(routing_id(), |
56 id, | 56 id, |
57 0, | |
sky
2013/05/03 20:24:54
Is 0 right here?
mef
2013/05/03 21:45:59
I think it is more correct than 200, as no request
| |
57 image_url, | 58 image_url, |
58 image_size, | 59 image_size, |
59 result_images)); | 60 result_images)); |
60 } | 61 } |
61 | 62 |
62 bool ImageLoadingHelper::DownloadImage(int id, | 63 bool ImageLoadingHelper::DownloadImage(int id, |
63 const GURL& image_url, | 64 const GURL& image_url, |
64 bool is_favicon, | 65 bool is_favicon, |
65 int image_size) { | 66 int image_size) { |
66 // Make sure webview was not shut down. | 67 // Make sure webview was not shut down. |
(...skipping 11 matching lines...) Expand all Loading... | |
78 return true; | 79 return true; |
79 } | 80 } |
80 | 81 |
81 void ImageLoadingHelper::DidDownloadImage( | 82 void ImageLoadingHelper::DidDownloadImage( |
82 int requested_size, | 83 int requested_size, |
83 MultiResolutionImageResourceFetcher* fetcher, | 84 MultiResolutionImageResourceFetcher* fetcher, |
84 const std::vector<SkBitmap>& images) { | 85 const std::vector<SkBitmap>& images) { |
85 // Notify requester of image download status. | 86 // Notify requester of image download status. |
86 Send(new ImageHostMsg_DidDownloadImage(routing_id(), | 87 Send(new ImageHostMsg_DidDownloadImage(routing_id(), |
87 fetcher->id(), | 88 fetcher->id(), |
89 fetcher->http_status_code(), | |
88 fetcher->image_url(), | 90 fetcher->image_url(), |
89 requested_size, | 91 requested_size, |
90 images)); | 92 images)); |
91 | 93 |
92 // Remove the image fetcher from our pending list. We're in the callback from | 94 // Remove the image fetcher from our pending list. We're in the callback from |
93 // MultiResolutionImageResourceFetcher, best to delay deletion. | 95 // MultiResolutionImageResourceFetcher, best to delay deletion. |
94 ImageResourceFetcherList::iterator iter = | 96 ImageResourceFetcherList::iterator iter = |
95 std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher); | 97 std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher); |
96 if (iter != image_fetchers_.end()) { | 98 if (iter != image_fetchers_.end()) { |
97 image_fetchers_.weak_erase(iter); | 99 image_fetchers_.weak_erase(iter); |
(...skipping 20 matching lines...) Expand all Loading... | |
118 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) | 120 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) |
119 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) | 121 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) |
120 IPC_MESSAGE_UNHANDLED(handled = false) | 122 IPC_MESSAGE_UNHANDLED(handled = false) |
121 IPC_END_MESSAGE_MAP() | 123 IPC_END_MESSAGE_MAP() |
122 | 124 |
123 return handled; | 125 return handled; |
124 } | 126 } |
125 | 127 |
126 } // namespace content | 128 } // namespace content |
127 | 129 |
OLD | NEW |