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

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: add WebURLLoaderClientImpl 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
« no previous file with comments | « content/renderer/fetchers/manifest_fetcher.h ('k') | content/renderer/fetchers/resource_fetcher_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7d42d1798ab0f45eea1fb0c6df51bf8949f6349f
--- /dev/null
+++ b/content/renderer/fetchers/manifest_fetcher.cc
@@ -0,0 +1,59 @@
+// 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/logging.h"
+#include "third_party/WebKit/public/platform/WebURLError.h"
+#include "third_party/WebKit/public/platform/WebURLLoader.h"
+#include "third_party/WebKit/public/platform/WebURLRequest.h"
+#include "third_party/WebKit/public/web/WebDocument.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+
+namespace content {
+
+ManifestFetcher::ManifestFetcher(const GURL& url)
+ : request_(url) {
+}
+
+ManifestFetcher::~ManifestFetcher() {
+ if (!completed() && loader_)
+ Cancel();
+}
+
+void ManifestFetcher::Start(blink::WebFrame* frame, const Callback& callback) {
+ DCHECK(!loader_);
+ DCHECK(!request_.isNull());
+ DCHECK(callback_.is_null());
+ DCHECK(!completed());
+ if (!request_.httpBody().isNull())
+ DCHECK_NE("GET", request_.httpMethod().utf8()) << "GETs can't have bodies.";
+
+ callback_ = callback;
+
+ request_.setRequestContext(blink::WebURLRequest::RequestContextManifest);
Mike West 2014/09/10 14:00:12 Perhaps this could be deduped by adding ::Start me
+ request_.setFrameType(blink::WebURLRequest::FrameTypeNone);
+ request_.setFirstPartyForCookies(frame->document().firstPartyForCookies());
+ frame->dispatchWillSendRequest(request_);
+ loader_.reset(frame->createAssociatedURLLoader());
+ loader_->loadAsynchronously(request_, this);
+
+ request_.reset();
+}
+
+void ManifestFetcher::Cancel() {
+ loader_->cancel();
+ WebURLLoaderClientImpl::Cancel();
+}
+
+void ManifestFetcher::OnLoadComplete() {
+ if (callback_.is_null())
+ return;
+
+ Callback callback = callback_;
+ callback.Run(status() == LOAD_FAILED ? blink::WebURLResponse() : response(),
+ status() == LOAD_FAILED ? std::string() : data());
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/fetchers/manifest_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