OLD | NEW |
(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 #ifndef CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ |
| 6 #define CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 14 |
| 15 class GURL; |
| 16 |
| 17 namespace blink { |
| 18 class WebFrame; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 |
| 23 class ResourceFetcher; |
| 24 |
| 25 // Helper class to download a Web Manifest. When an instance is created, the |
| 26 // caller need to call Start() and wait for the passed callback to be executed. |
| 27 // If the fetch fails, the callback will be called with two empty objects. |
| 28 class ManifestFetcher { |
| 29 public: |
| 30 // This will be called asynchronously after the URL has been fetched, |
| 31 // successfully or not. If there is a failure, response and data will both be |
| 32 // empty. |response| and |data| are both valid until the URLFetcher instance |
| 33 // is destroyed. |
| 34 typedef base::Callback<void(const blink::WebURLResponse& response, |
| 35 const std::string& data)> Callback; |
| 36 |
| 37 explicit ManifestFetcher(const GURL& url); |
| 38 virtual ~ManifestFetcher(); |
| 39 |
| 40 void Start(blink::WebFrame* frame, const Callback& callback); |
| 41 void Cancel(); |
| 42 |
| 43 private: |
| 44 void OnLoadComplete(const blink::WebURLResponse& response, |
| 45 const std::string& data); |
| 46 |
| 47 bool completed_; |
| 48 Callback callback_; |
| 49 scoped_ptr<ResourceFetcher> fetcher_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(ManifestFetcher); |
| 52 }; |
| 53 |
| 54 } // namespace content |
| 55 |
| 56 #endif // CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_ |
OLD | NEW |