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

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

Issue 532773002: Implement ManifestFetcher, helper to fetch Web Manifests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/fetchers/manifest_fetcher.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "content/public/renderer/resource_fetcher.h"
10 #include "third_party/WebKit/public/platform/WebURLRequest.h"
11 #include "third_party/WebKit/public/web/WebFrame.h"
12
13 namespace content {
14
15 ManifestFetcher::ManifestFetcher(const GURL& url)
16 : completed_(false) {
17 fetcher_.reset(ResourceFetcher::Create(url));
18 }
19
20 ManifestFetcher::~ManifestFetcher() {
21 if (!completed_)
22 Cancel();
23 }
24
25 void ManifestFetcher::Start(blink::WebFrame* frame, const Callback& callback) {
26 callback_ = callback;
27 fetcher_->Start(frame,
28 blink::WebURLRequest::RequestContextManifest,
29 blink::WebURLRequest::FrameTypeNone,
30 ResourceFetcher::FRAME_ASSOCIATED_LOADER,
31 base::Bind(&ManifestFetcher::OnLoadComplete,
32 base::Unretained(this)));
33 }
34
35 void ManifestFetcher::Cancel() {
36 DCHECK(!completed_);
37 fetcher_->Cancel();
38 }
39
40 void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response,
41 const std::string& data) {
42 DCHECK(!completed_);
43 completed_ = true;
44
45 Callback callback = callback_;
46 callback.Run(response, data);
47 }
48
49 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/fetchers/manifest_fetcher.h ('k') | content/renderer/fetchers/multi_resolution_image_resource_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698