Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: content/renderer/image_downloader/image_downloader_impl.cc

Issue 1858533002: Introduce WebCachePolicy to merge cache policy enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review, minor fixes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_downloader/image_downloader_impl.h" 5 #include "content/renderer/image_downloader/image_downloader_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "content/child/image_decoder.h" 12 #include "content/child/image_decoder.h"
13 #include "content/public/renderer/render_frame.h" 13 #include "content/public/renderer/render_frame.h"
14 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" 14 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h"
15 #include "mojo/common/url_type_converters.h" 15 #include "mojo/common/url_type_converters.h"
16 #include "mojo/converters/geometry/geometry_type_converters.h" 16 #include "mojo/converters/geometry/geometry_type_converters.h"
17 #include "net/base/data_url.h" 17 #include "net/base/data_url.h"
18 #include "skia/ext/image_operations.h" 18 #include "skia/ext/image_operations.h"
19 #include "skia/public/type_converters.h" 19 #include "skia/public/type_converters.h"
20 #include "third_party/WebKit/public/platform/WebURLRequest.h" 20 #include "third_party/WebKit/public/platform/WebURLRequest.h"
21 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/web/WebLocalFrame.h" 22 #include "third_party/WebKit/public/web/WebLocalFrame.h"
23 #include "third_party/WebKit/public/web/WebView.h" 23 #include "third_party/WebKit/public/web/WebView.h"
24 #include "ui/gfx/favicon_size.h" 24 #include "ui/gfx/favicon_size.h"
25 #include "ui/gfx/geometry/size.h" 25 #include "ui/gfx/geometry/size.h"
26 #include "ui/gfx/skbitmap_operations.h" 26 #include "ui/gfx/skbitmap_operations.h"
27 #include "url/url_constants.h" 27 #include "url/url_constants.h"
28 28
29 using blink::WebCachePolicy;
29 using blink::WebFrame; 30 using blink::WebFrame;
30 using blink::WebVector; 31 using blink::WebVector;
31 using blink::WebURL; 32 using blink::WebURL;
32 using blink::WebURLRequest; 33 using blink::WebURLRequest;
33 34
34 namespace { 35 namespace {
35 36
36 // Decodes a data: URL image or returns an empty image in case of failure. 37 // Decodes a data: URL image or returns an empty image in case of failure.
37 SkBitmap ImageFromDataUrl(const GURL& url) { 38 SkBitmap ImageFromDataUrl(const GURL& url) {
38 std::string mime_type, char_set, data; 39 std::string mime_type, char_set, data;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 uint32_t max_image_size, 170 uint32_t max_image_size,
170 bool bypass_cache, 171 bool bypass_cache,
171 const DownloadImageCallback& callback) { 172 const DownloadImageCallback& callback) {
172 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); 173 blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
173 DCHECK(frame); 174 DCHECK(frame);
174 175
175 // Create an image resource fetcher and assign it with a call back object. 176 // Create an image resource fetcher and assign it with a call back object.
176 image_fetchers_.push_back(new MultiResolutionImageResourceFetcher( 177 image_fetchers_.push_back(new MultiResolutionImageResourceFetcher(
177 image_url, frame, 0, is_favicon ? WebURLRequest::RequestContextFavicon 178 image_url, frame, 0, is_favicon ? WebURLRequest::RequestContextFavicon
178 : WebURLRequest::RequestContextImage, 179 : WebURLRequest::RequestContextImage,
179 bypass_cache ? WebURLRequest::BypassingCache 180 bypass_cache ? WebCachePolicy::BypassingCache
180 : WebURLRequest::UseProtocolCachePolicy, 181 : WebCachePolicy::UseProtocolCachePolicy,
181 base::Bind(&ImageDownloaderImpl::DidFetchImage, base::Unretained(this), 182 base::Bind(&ImageDownloaderImpl::DidFetchImage, base::Unretained(this),
182 max_image_size, callback))); 183 max_image_size, callback)));
183 return true; 184 return true;
184 } 185 }
185 186
186 void ImageDownloaderImpl::DidFetchImage( 187 void ImageDownloaderImpl::DidFetchImage(
187 uint32_t max_image_size, 188 uint32_t max_image_size,
188 const DownloadImageCallback& callback, 189 const DownloadImageCallback& callback,
189 MultiResolutionImageResourceFetcher* fetcher, 190 MultiResolutionImageResourceFetcher* fetcher,
190 const std::vector<SkBitmap>& images) { 191 const std::vector<SkBitmap>& images) {
(...skipping 19 matching lines...) Expand all
210 int32_t http_status_code, 211 int32_t http_status_code,
211 const std::vector<SkBitmap>& result_images, 212 const std::vector<SkBitmap>& result_images,
212 const std::vector<gfx::Size>& result_original_image_sizes, 213 const std::vector<gfx::Size>& result_original_image_sizes,
213 const DownloadImageCallback& callback) { 214 const DownloadImageCallback& callback) {
214 callback.Run(http_status_code, 215 callback.Run(http_status_code,
215 mojo::Array<skia::mojom::BitmapPtr>::From(result_images), 216 mojo::Array<skia::mojom::BitmapPtr>::From(result_images),
216 mojo::Array<mojo::SizePtr>::From(result_original_image_sizes)); 217 mojo::Array<mojo::SizePtr>::From(result_original_image_sizes));
217 } 218 }
218 219
219 } // namespace content 220 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698