OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_FETCHER_LOCAL_FETCHER_H_ | 5 #ifndef MOJO_FETCHER_LOCAL_FETCHER_H_ |
6 #define MOJO_FETCHER_LOCAL_FETCHER_H_ | 6 #define MOJO_FETCHER_LOCAL_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "mojo/shell/fetcher.h" | 11 #include "mojo/shell/fetcher.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 | 15 |
16 class NetworkService; | 16 class NetworkService; |
17 | 17 |
18 namespace fetcher { | 18 namespace fetcher { |
19 | 19 |
20 // Implements Fetcher for file:// URLs. | 20 // Implements Fetcher for file:// URLs. |
21 class LocalFetcher : public shell::Fetcher { | 21 class LocalFetcher : public shell::Fetcher { |
22 public: | 22 public: |
23 LocalFetcher(NetworkService* network_service, | 23 LocalFetcher(NetworkService* network_service, |
24 const GURL& url, | 24 const GURL& url, |
25 const GURL& url_without_query, | 25 const GURL& url_without_query, |
| 26 const base::FilePath& shell_file_root, |
26 const FetchCallback& loader_callback); | 27 const FetchCallback& loader_callback); |
27 | 28 |
| 29 ~LocalFetcher() override; |
| 30 |
28 void GetMimeTypeFromFileCallback(const mojo::String& mime_type); | 31 void GetMimeTypeFromFileCallback(const mojo::String& mime_type); |
29 | 32 |
30 private: | 33 private: |
31 const GURL& GetURL() const override; | 34 const GURL& GetURL() const override; |
32 GURL GetRedirectURL() const override; | 35 GURL GetRedirectURL() const override; |
33 GURL GetRedirectReferer() const override; | 36 GURL GetRedirectReferer() const override; |
34 | 37 |
35 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner, | 38 URLResponsePtr AsURLResponse(base::TaskRunner* task_runner, |
36 uint32_t skip) override; | 39 uint32_t skip) override; |
37 | 40 |
38 void AsPath( | 41 void AsPath( |
39 base::TaskRunner* task_runner, | 42 base::TaskRunner* task_runner, |
40 base::Callback<void(const base::FilePath&, bool)> callback) override; | 43 base::Callback<void(const base::FilePath&, bool)> callback) override; |
41 | 44 |
42 std::string MimeType() override; | 45 std::string MimeType() override; |
43 | 46 |
44 bool HasMojoMagic() override; | 47 bool HasMojoMagic() override; |
45 | 48 |
46 bool PeekFirstLine(std::string* line) override; | 49 bool PeekFirstLine(std::string* line) override; |
47 | 50 |
48 GURL url_; | 51 GURL url_; |
49 base::FilePath path_; | 52 base::FilePath path_; |
| 53 base::FilePath shell_file_root_; |
50 std::string mime_type_; | 54 std::string mime_type_; |
51 | 55 |
52 DISALLOW_COPY_AND_ASSIGN(LocalFetcher); | 56 DISALLOW_COPY_AND_ASSIGN(LocalFetcher); |
53 }; | 57 }; |
54 | 58 |
55 } // namespace fetcher | 59 } // namespace fetcher |
56 } // namespace mojo | 60 } // namespace mojo |
57 | 61 |
58 #endif // MOJO_FETCHER_LOCAL_FETCHER_H_ | 62 #endif // MOJO_FETCHER_LOCAL_FETCHER_H_ |
OLD | NEW |