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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/fetchers/manifest_fetcher.cc
diff --git a/content/renderer/fetchers/manifest_fetcher.cc b/content/renderer/fetchers/manifest_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c6a64c84f87d10094c4a4836352d504cccd445ca
--- /dev/null
+++ b/content/renderer/fetchers/manifest_fetcher.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/fetchers/manifest_fetcher.h"
+
+#include "base/bind.h"
+#include "base/logging.h"
+#include "content/public/renderer/resource_fetcher.h"
+#include "third_party/WebKit/public/platform/WebURLRequest.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+
+namespace content {
+
+ManifestFetcher::ManifestFetcher(const GURL& url)
+ : completed_(false) {
+ fetcher_.reset(ResourceFetcher::Create(url));
+}
+
+ManifestFetcher::~ManifestFetcher() {
+ if (!completed_)
+ Cancel();
+}
+
+void ManifestFetcher::Start(blink::WebFrame* frame, const Callback& callback) {
+ callback_ = callback;
+ fetcher_->Start(frame,
+ blink::WebURLRequest::RequestContextManifest,
+ blink::WebURLRequest::FrameTypeNone,
+ ResourceFetcher::FRAME_ASSOCIATED_LOADER,
+ base::Bind(&ManifestFetcher::OnLoadComplete,
+ base::Unretained(this)));
+}
+
+void ManifestFetcher::Cancel() {
+ DCHECK(!completed_);
+ fetcher_->Cancel();
+}
+
+void ManifestFetcher::OnLoadComplete(const blink::WebURLResponse& response,
+ const std::string& data) {
+ DCHECK(!completed_);
+ completed_ = true;
+
+ Callback callback = callback_;
+ callback.Run(response, data);
+}
+
+} // namespace content
« 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