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

Side by Side Diff: content/renderer/fetchers/manifest_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/manifest_fetcher.h" 5 #include "content/renderer/fetchers/manifest_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/public/renderer/resource_fetcher.h" 9 #include "content/public/renderer/associated_resource_fetcher.h"
10 #include "third_party/WebKit/public/platform/WebURLRequest.h" 10 #include "third_party/WebKit/public/platform/WebURLRequest.h"
11 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderOptions.h"
11 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 ManifestFetcher::ManifestFetcher(const GURL& url) 16 ManifestFetcher::ManifestFetcher(const GURL& url)
16 : completed_(false) { 17 : completed_(false) {
17 fetcher_.reset(ResourceFetcher::Create(url)); 18 fetcher_.reset(AssociatedResourceFetcher::Create(url));
18 } 19 }
19 20
20 ManifestFetcher::~ManifestFetcher() { 21 ManifestFetcher::~ManifestFetcher() {
21 if (!completed_) 22 if (!completed_)
22 Cancel(); 23 Cancel();
23 } 24 }
24 25
25 void ManifestFetcher::Start(blink::WebFrame* frame, 26 void ManifestFetcher::Start(blink::WebFrame* frame,
26 bool use_credentials, 27 bool use_credentials,
27 const Callback& callback) { 28 const Callback& callback) {
28 callback_ = callback; 29 callback_ = callback;
29 30
30 blink::WebURLLoaderOptions options; 31 blink::WebAssociatedURLLoaderOptions options;
31 options.allowCredentials = use_credentials; 32 options.allowCredentials = use_credentials;
32 options.crossOriginRequestPolicy = 33 options.crossOriginRequestPolicy = blink::WebAssociatedURLLoaderOptions::
33 blink::WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl; 34 CrossOriginRequestPolicyUseAccessControl;
34 fetcher_->SetLoaderOptions(options); 35 fetcher_->SetLoaderOptions(options);
35 36
36 fetcher_->Start(frame, 37 fetcher_->Start(frame,
37 blink::WebURLRequest::RequestContextManifest, 38 blink::WebURLRequest::RequestContextManifest,
38 blink::WebURLRequest::FrameTypeNone, 39 blink::WebURLRequest::FrameTypeNone,
39 ResourceFetcher::FRAME_ASSOCIATED_LOADER,
40 base::Bind(&ManifestFetcher::OnLoadComplete, 40 base::Bind(&ManifestFetcher::OnLoadComplete,
41 base::Unretained(this))); 41 base::Unretained(this)));
42 } 42 }
43 43
44 void ManifestFetcher::Cancel() { 44 void ManifestFetcher::Cancel() {
45 DCHECK(!completed_); 45 DCHECK(!completed_);
46 fetcher_->Cancel(); 46 fetcher_->Cancel();
47 } 47 }
48 48
49 void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response, 49 void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response,
50 const std::string& data) { 50 const std::string& data) {
51 DCHECK(!completed_); 51 DCHECK(!completed_);
52 completed_ = true; 52 completed_ = true;
53 53
54 Callback callback = callback_; 54 Callback callback = callback_;
55 callback.Run(response, data); 55 callback.Run(response, data);
56 } 56 }
57 57
58 } // namespace content 58 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/fetchers/manifest_fetcher.h ('k') | content/renderer/fetchers/multi_resolution_image_resource_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698