| 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 SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ |
| 6 #define SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ | 6 #define SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ |
| 7 | 7 |
| 8 #include "shell/application_manager/fetcher.h" | 8 #include "shell/application_manager/fetcher.h" |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader.mojom.h" | 12 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader.mojom.h" |
| 13 #include "mojo/services/authenticating_url_loader/public/interfaces/authenticati
ng_url_loader_factory.mojom.h" | 13 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
| 15 #include "mojo/services/url_response_disk_cache/public/interfaces/url_response_d
isk_cache.mojom.h" | 15 #include "mojo/services/url_response_disk_cache/public/interfaces/url_response_d
isk_cache.mojom.h" |
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 17 | 17 |
| 18 namespace shell { | 18 namespace shell { |
| 19 | 19 |
| 20 // Implements Fetcher for http[s] files. | 20 // Implements Fetcher for http[s] files. |
| 21 class NetworkFetcher : public Fetcher { | 21 class NetworkFetcher : public Fetcher { |
| 22 public: | 22 public: |
| 23 NetworkFetcher(bool disable_cache, | 23 NetworkFetcher(bool disable_cache, |
| 24 bool predictable_app_filenames, | 24 bool predictable_app_filenames, |
| 25 const GURL& url, | 25 const GURL& url, |
| 26 mojo::URLResponseDiskCache* url_response_disk_cache, | 26 mojo::URLResponseDiskCache* url_response_disk_cache, |
| 27 mojo::AuthenticatingURLLoaderFactory* url_loader_factory, | 27 mojo::NetworkService* network_service, |
| 28 const FetchCallback& loader_callback); | 28 const FetchCallback& loader_callback); |
| 29 | 29 |
| 30 ~NetworkFetcher() override; | 30 ~NetworkFetcher() override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // TODO(hansmuller): Revisit this when a real peek operation is available. | 33 // TODO(hansmuller): Revisit this when a real peek operation is available. |
| 34 static const MojoDeadline kPeekTimeout = MOJO_DEADLINE_INDEFINITE; | 34 static const MojoDeadline kPeekTimeout = MOJO_DEADLINE_INDEFINITE; |
| 35 | 35 |
| 36 const GURL& GetURL() const override; | 36 const GURL& GetURL() const override; |
| 37 GURL GetRedirectURL() const override; | 37 GURL GetRedirectURL() const override; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 59 void AsPath( | 59 void AsPath( |
| 60 base::TaskRunner* task_runner, | 60 base::TaskRunner* task_runner, |
| 61 base::Callback<void(const base::FilePath&, bool)> callback) override; | 61 base::Callback<void(const base::FilePath&, bool)> callback) override; |
| 62 | 62 |
| 63 std::string MimeType() override; | 63 std::string MimeType() override; |
| 64 | 64 |
| 65 bool HasMojoMagic() override; | 65 bool HasMojoMagic() override; |
| 66 | 66 |
| 67 bool PeekFirstLine(std::string* line) override; | 67 bool PeekFirstLine(std::string* line) override; |
| 68 | 68 |
| 69 void StartNetworkRequest( | 69 void StartNetworkRequest(const GURL& url, |
| 70 const GURL& url, | 70 mojo::NetworkService* network_service); |
| 71 mojo::AuthenticatingURLLoaderFactory* url_loader_factory); | |
| 72 | 71 |
| 73 void OnLoadComplete(mojo::URLResponsePtr response); | 72 void OnLoadComplete(mojo::URLResponsePtr response); |
| 74 | 73 |
| 75 const bool disable_cache_; | 74 const bool disable_cache_; |
| 76 const bool predictable_app_filenames_; | 75 const bool predictable_app_filenames_; |
| 77 const GURL url_; | 76 const GURL url_; |
| 78 mojo::URLResponseDiskCache* url_response_disk_cache_; | 77 mojo::URLResponseDiskCache* url_response_disk_cache_; |
| 79 mojo::AuthenticatingURLLoaderPtr url_loader_; | 78 mojo::URLLoaderPtr url_loader_; |
| 80 mojo::URLResponsePtr response_; | 79 mojo::URLResponsePtr response_; |
| 81 base::FilePath path_; | 80 base::FilePath path_; |
| 82 base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_; | 81 base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_; |
| 83 | 82 |
| 84 DISALLOW_COPY_AND_ASSIGN(NetworkFetcher); | 83 DISALLOW_COPY_AND_ASSIGN(NetworkFetcher); |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // namespace shell | 86 } // namespace shell |
| 88 | 87 |
| 89 #endif // SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ | 88 #endif // SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ |
| OLD | NEW |