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

Side by Side Diff: content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc

Issue 2399463007: AssociatedURLLoader shouldn't derive from WebURLLoader (Closed)
Patch Set: Rebase Created 4 years, 2 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 (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 "content/child/image_decoder.h"
10 #include "content/public/renderer/resource_fetcher.h" 10 #include "content/public/renderer/associated_resource_fetcher.h"
11 #include "third_party/WebKit/public/platform/WebURLResponse.h" 11 #include "third_party/WebKit/public/platform/WebURLResponse.h"
12 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderOptions.h"
12 #include "third_party/WebKit/public/web/WebFrame.h" 13 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
16 16
17 using blink::WebFrame; 17 using blink::WebFrame;
18 using blink::WebURLLoaderOptions; 18 using blink::WebAssociatedURLLoaderOptions;
19 using blink::WebURLRequest; 19 using blink::WebURLRequest;
20 using blink::WebURLResponse; 20 using blink::WebURLResponse;
21 21
22 namespace content { 22 namespace content {
23 23
24 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( 24 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher(
25 const GURL& image_url, 25 const GURL& image_url,
26 WebFrame* frame, 26 WebFrame* frame,
27 int id, 27 int id,
28 WebURLRequest::RequestContext request_context, 28 WebURLRequest::RequestContext request_context,
29 blink::WebCachePolicy cache_policy, 29 blink::WebCachePolicy cache_policy,
30 const Callback& callback) 30 const Callback& callback)
31 : callback_(callback), 31 : callback_(callback),
32 id_(id), 32 id_(id),
33 http_status_code_(0), 33 http_status_code_(0),
34 image_url_(image_url) { 34 image_url_(image_url) {
35 fetcher_.reset(ResourceFetcher::Create(image_url)); 35 fetcher_.reset(AssociatedResourceFetcher::Create(image_url));
36 36
37 WebURLLoaderOptions options; 37 WebAssociatedURLLoaderOptions options;
38 options.allowCredentials = true; 38 options.allowCredentials = true;
39 options.crossOriginRequestPolicy = 39 options.crossOriginRequestPolicy =
40 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; 40 WebAssociatedURLLoaderOptions::CrossOriginRequestPolicyAllow;
41 fetcher_->SetLoaderOptions(options); 41 fetcher_->SetLoaderOptions(options);
42 42
43 // To prevent cache tainting, the favicon requests have to by-pass the service 43 // To prevent cache tainting, the favicon requests have to by-pass the service
44 // workers. This should ideally not happen or at least not all the time. 44 // workers. This should ideally not happen or at least not all the time.
45 // See https://crbug.com/448427 45 // See https://crbug.com/448427
46 if (request_context == WebURLRequest::RequestContextFavicon) 46 if (request_context == WebURLRequest::RequestContextFavicon)
47 fetcher_->SetSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); 47 fetcher_->SetSkipServiceWorker(WebURLRequest::SkipServiceWorker::All);
48 48
49 fetcher_->SetCachePolicy(cache_policy); 49 fetcher_->SetCachePolicy(cache_policy);
50 50
51 fetcher_->Start( 51 fetcher_->Start(
52 frame, 52 frame,
53 request_context, 53 request_context,
54 WebURLRequest::FrameTypeNone, 54 WebURLRequest::FrameTypeNone,
55 ResourceFetcher::FRAME_ASSOCIATED_LOADER,
56 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete, 55 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete,
57 base::Unretained(this))); 56 base::Unretained(this)));
58 } 57 }
59 58
60 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() { 59 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() {
61 } 60 }
62 61
63 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( 62 void MultiResolutionImageResourceFetcher::OnURLFetchComplete(
64 const WebURLResponse& response, 63 const WebURLResponse& response,
65 const std::string& data) { 64 const std::string& data) {
(...skipping 10 matching lines...) Expand all
76 // If we get here, it means no image from server or couldn't decode the 75 // If we get here, it means no image from server or couldn't decode the
77 // response as an image. The delegate will see an empty vector. 76 // response as an image. The delegate will see an empty vector.
78 77
79 // Take a reference to the callback as running the callback may lead to our 78 // Take a reference to the callback as running the callback may lead to our
80 // destruction. 79 // destruction.
81 Callback callback = callback_; 80 Callback callback = callback_;
82 callback.Run(this, bitmaps); 81 callback.Run(this, bitmaps);
83 } 82 }
84 83
85 } // namespace content 84 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/fetchers/multi_resolution_image_resource_fetcher.h ('k') | content/renderer/fetchers/resource_fetcher_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698