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

Unified Diff: content/renderer/fetchers/manifest_fetcher.h

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
« no previous file with comments | « content/renderer/fetchers/image_resource_fetcher.cc ('k') | content/renderer/fetchers/manifest_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/fetchers/manifest_fetcher.h
diff --git a/content/renderer/fetchers/manifest_fetcher.h b/content/renderer/fetchers/manifest_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..a3afaa3e5a893da680ef8dd4b9179622e0e9af25
--- /dev/null
+++ b/content/renderer/fetchers/manifest_fetcher.h
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_
+#define CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/WebKit/public/platform/WebURLResponse.h"
+
+class GURL;
+
+namespace blink {
+class WebFrame;
+}
+
+namespace content {
+
+class ResourceFetcher;
+
+// Helper class to download a Web Manifest. When an instance is created, the
+// caller need to call Start() and wait for the passed callback to be executed.
+// If the fetch fails, the callback will be called with two empty objects.
+class ManifestFetcher {
+ public:
+ // This will be called asynchronously after the URL has been fetched,
+ // successfully or not. If there is a failure, response and data will both be
+ // empty. |response| and |data| are both valid until the URLFetcher instance
+ // is destroyed.
+ typedef base::Callback<void(const blink::WebURLResponse& response,
+ const std::string& data)> Callback;
+
+ explicit ManifestFetcher(const GURL& url);
+ virtual ~ManifestFetcher();
+
+ void Start(blink::WebFrame* frame, const Callback& callback);
+ void Cancel();
+
+ private:
+ void OnLoadComplete(const blink::WebURLResponse& response,
+ const std::string& data);
+
+ bool completed_;
+ Callback callback_;
+ scoped_ptr<ResourceFetcher> fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManifestFetcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_
« no previous file with comments | « content/renderer/fetchers/image_resource_fetcher.cc ('k') | content/renderer/fetchers/manifest_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698