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"
17 // Implements Fetcher for data: URLs.
18 class DataFetcher
: public shell::Fetcher
{
20 static void Start(const GURL
& url
, const FetchCallback
& loader_callback
);
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
;
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
;
42 URLResponsePtr response_
;
44 DISALLOW_COPY_AND_ASSIGN(DataFetcher
);
47 } // namespace fetcher
50 #endif // MOJO_FETCHER_DATA_FETCHER_H_