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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 std::string MimeType() override; | 42 std::string MimeType() override; |
43 | 43 |
44 bool HasMojoMagic() override; | 44 bool HasMojoMagic() override; |
45 | 45 |
46 bool PeekFirstLine(std::string* line) override; | 46 bool PeekFirstLine(std::string* line) override; |
47 | 47 |
48 // Returns whether the content can be loaded directly from cache. Local hosts | 48 // Returns whether the content can be loaded directly from cache. Local hosts |
49 // are not loaded from cache to allow effective development. | 49 // are not loaded from cache to allow effective development. |
50 bool CanLoadDirectlyFromCache(); | 50 bool CanLoadDirectlyFromCache(); |
51 | 51 |
52 void LoadFromCache(bool schedule_update); | 52 // Tries to load the URL directly from the offline cache. |
| 53 void LoadFromCache(); |
53 | 54 |
54 void OnCachedResponseReceived(bool schedule_update, | 55 // Callback from the offline cache. |
55 mojo::URLResponsePtr response, | 56 void OnResponseReceived(bool schedule_update, |
56 mojo::Array<uint8_t> path_as_array, | 57 mojo::URLResponsePtr response, |
57 mojo::Array<uint8_t> cache_dir); | 58 mojo::Array<uint8_t> path_as_array, |
| 59 mojo::Array<uint8_t> cache_dir); |
58 | 60 |
| 61 // Start a network request to load the URL. |
59 void StartNetworkRequest(); | 62 void StartNetworkRequest(); |
60 | 63 |
| 64 // Callback from the network stack. |
61 void OnLoadComplete(mojo::URLResponsePtr response); | 65 void OnLoadComplete(mojo::URLResponsePtr response); |
62 | 66 |
63 void OnFileSavedToCache(mojo::Array<uint8_t> path_as_array, | 67 // Callback from the offline cache when the response is saved by the cache. |
| 68 void OnFileSavedToCache(mojo::URLResponsePtr response, |
| 69 mojo::Array<uint8_t> path_as_array, |
64 mojo::Array<uint8_t> cache_dir); | 70 mojo::Array<uint8_t> cache_dir); |
65 | 71 |
| 72 // Record the mapping from URLs to files. |
66 static void RecordCacheToURLMapping(const base::FilePath& path, | 73 static void RecordCacheToURLMapping(const base::FilePath& path, |
67 const GURL& url); | 74 const GURL& url); |
68 | 75 |
69 const bool disable_cache_; | 76 const bool disable_cache_; |
70 const bool force_offline_by_default_; | 77 const bool force_offline_by_default_; |
71 const GURL url_; | 78 const GURL url_; |
72 mojo::URLResponseDiskCache* url_response_disk_cache_; | 79 mojo::URLResponseDiskCache* url_response_disk_cache_; |
73 mojo::NetworkService* network_service_; | 80 mojo::NetworkService* network_service_; |
74 mojo::URLLoaderPtr url_loader_; | 81 mojo::URLLoaderPtr url_loader_; |
75 mojo::URLResponsePtr response_; | 82 mojo::URLResponsePtr response_; |
76 base::FilePath path_; | 83 base::FilePath path_; |
77 base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_; | 84 base::WeakPtrFactory<NetworkFetcher> weak_ptr_factory_; |
78 | 85 |
79 DISALLOW_COPY_AND_ASSIGN(NetworkFetcher); | 86 DISALLOW_COPY_AND_ASSIGN(NetworkFetcher); |
80 }; | 87 }; |
81 | 88 |
82 } // namespace shell | 89 } // namespace shell |
83 | 90 |
84 #endif // SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ | 91 #endif // SHELL_APPLICATION_MANAGER_NETWORK_FETCHER_H_ |
OLD | NEW |