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.
5 #ifndef CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_
6 #define CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/content_export.h"
14 #include "third_party/WebKit/public/platform/WebURLResponse.h"
24 class ResourceFetcher
;
26 // Helper class to download a Web Manifest. When an instance is created, the
27 // caller need to call Start() and wait for the passed callback to be executed.
28 // If the fetch fails, the callback will be called with two empty objects.
29 class CONTENT_EXPORT ManifestFetcher
{
31 // This will be called asynchronously after the URL has been fetched,
32 // successfully or not. If there is a failure, response and data will both be
33 // empty. |response| and |data| are both valid until the URLFetcher instance
35 typedef base::Callback
<void(const blink::WebURLResponse
& response
,
36 const std::string
& data
)> Callback
;
38 explicit ManifestFetcher(const GURL
& url
);
39 virtual ~ManifestFetcher();
41 void Start(blink::WebFrame
* frame
,
43 const Callback
& callback
);
47 void OnLoadComplete(const blink::WebURLResponse
& response
,
48 const std::string
& data
);
52 scoped_ptr
<ResourceFetcher
> fetcher_
;
54 DISALLOW_COPY_AND_ASSIGN(ManifestFetcher
);
57 } // namespace content
59 #endif // CONTENT_RENDERER_FETCHERS_MANIFEST_FETCHER_H_