Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / mojo / fetcher / data_fetcher.h
blobb94b796489f2d7f5aaeea4f44b67c76cfdc6cd82
1 // Copyright 2015 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 MOJO_FETCHER_DATA_FETCHER_H_
6 #define MOJO_FETCHER_DATA_FETCHER_H_
8 #include "mojo/shell/fetcher.h"
10 #include "base/macros.h"
11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
12 #include "url/gurl.h"
14 namespace mojo {
15 namespace fetcher {
17 // Implements Fetcher for data: URLs.
18 class DataFetcher : public shell::Fetcher {
19 public:
20 static void Start(const GURL& url, const FetchCallback& loader_callback);
22 private:
23 DataFetcher(const GURL& url, const FetchCallback& loader_callback);
24 ~DataFetcher() override;
26 void BuildAndDispatchResponse();
28 // shell::Fetcher implementation.
29 const GURL& GetURL() const override;
30 GURL GetRedirectURL() const override;
31 GURL GetRedirectReferer() const override;
32 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner,
33 uint32_t skip) override;
34 void AsPath(
35 base::TaskRunner* task_runner,
36 base::Callback<void(const base::FilePath&, bool)> callback) override;
37 std::string MimeType() override;
38 bool HasMojoMagic() override;
39 bool PeekFirstLine(std::string* line) override;
41 const GURL url_;
42 URLResponsePtr response_;
44 DISALLOW_COPY_AND_ASSIGN(DataFetcher);
47 } // namespace fetcher
48 } // namespace mojo
50 #endif // MOJO_FETCHER_DATA_FETCHER_H_