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

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

Issue 840553003: Use a FrameAssociatedLoader when downloading image resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/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/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/gfx/geometry/size.h" 15 #include "ui/gfx/geometry/size.h"
15 16
16 using blink::WebFrame; 17 using blink::WebFrame;
18 using blink::WebURLLoaderOptions;
17 using blink::WebURLRequest; 19 using blink::WebURLRequest;
18 using blink::WebURLResponse; 20 using blink::WebURLResponse;
19 21
20 namespace content { 22 namespace content {
21 23
22 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher( 24 MultiResolutionImageResourceFetcher::MultiResolutionImageResourceFetcher(
23 const GURL& image_url, 25 const GURL& image_url,
24 WebFrame* frame, 26 WebFrame* frame,
25 int id, 27 int id,
26 WebURLRequest::RequestContext request_context, 28 WebURLRequest::RequestContext request_context,
27 const Callback& callback) 29 const Callback& callback)
28 : callback_(callback), 30 : callback_(callback),
29 id_(id), 31 id_(id),
30 http_status_code_(0), 32 http_status_code_(0),
31 image_url_(image_url) { 33 image_url_(image_url) {
32 fetcher_.reset(ResourceFetcher::Create(image_url)); 34 fetcher_.reset(ResourceFetcher::Create(image_url));
35
36 WebURLLoaderOptions options;
37 options.allowCredentials = true;
Nate Chapin 2015/01/06 18:18:42 I don't feel qualified to approve a change to favi
mlamouri (slow - plz ping) 2015/01/07 10:08:06 This is actually not changing any behaviour. The p
38 options.crossOriginRequestPolicy =
39 WebURLLoaderOptions::CrossOriginRequestPolicyAllow;
40 fetcher_->SetLoaderOptions(options);
41
33 fetcher_->Start( 42 fetcher_->Start(
34 frame, 43 frame,
35 request_context, 44 request_context,
36 WebURLRequest::FrameTypeNone, 45 WebURLRequest::FrameTypeNone,
37 ResourceFetcher::PLATFORM_LOADER, 46 ResourceFetcher::FRAME_ASSOCIATED_LOADER,
mlamouri (slow - plz ping) 2015/01/06 17:32:50 If exposing all image loading in the devtools can
38 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete, 47 base::Bind(&MultiResolutionImageResourceFetcher::OnURLFetchComplete,
39 base::Unretained(this))); 48 base::Unretained(this)));
40 } 49 }
41 50
42 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() { 51 MultiResolutionImageResourceFetcher::~MultiResolutionImageResourceFetcher() {
43 } 52 }
44 53
45 void MultiResolutionImageResourceFetcher::OnURLFetchComplete( 54 void MultiResolutionImageResourceFetcher::OnURLFetchComplete(
46 const WebURLResponse& response, 55 const WebURLResponse& response,
47 const std::string& data) { 56 const std::string& data) {
(...skipping 10 matching lines...) Expand all
58 // If we get here, it means no image from server or couldn't decode the 67 // If we get here, it means no image from server or couldn't decode the
59 // response as an image. The delegate will see an empty vector. 68 // response as an image. The delegate will see an empty vector.
60 69
61 // Take a reference to the callback as running the callback may lead to our 70 // Take a reference to the callback as running the callback may lead to our
62 // destruction. 71 // destruction.
63 Callback callback = callback_; 72 Callback callback = callback_;
64 callback.Run(this, bitmaps); 73 callback.Run(this, bitmaps);
65 } 74 }
66 75
67 } // namespace content 76 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/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