| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ | 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ |
| 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ | 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Starts fetching resources to precache. URLs are fetched sequentially. Can | 117 // Starts fetching resources to precache. URLs are fetched sequentially. Can |
| 118 // be called from any thread. Start should only be called once on a | 118 // be called from any thread. Start should only be called once on a |
| 119 // PrecacheFetcher instance. | 119 // PrecacheFetcher instance. |
| 120 void Start(); | 120 void Start(); |
| 121 | 121 |
| 122 // Stops all precaching work. The PreacheFetcher should not be used after | 122 // Stops all precaching work. The PreacheFetcher should not be used after |
| 123 // calling this method. | 123 // calling this method. |
| 124 std::unique_ptr<PrecacheUnfinishedWork> CancelPrecaching(); | 124 std::unique_ptr<PrecacheUnfinishedWork> CancelPrecaching(); |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 friend class PrecacheFetcherTest; |
| 128 FRIEND_TEST_ALL_PREFIXES(PrecacheFetcherTest, FetcherPoolMaxLimitReached); |
| 129 |
| 127 // Notifies the precache delete that precaching is done, and report | 130 // Notifies the precache delete that precaching is done, and report |
| 128 // completion statistics. | 131 // completion statistics. |
| 129 void NotifyDone(size_t remaining_manifest_urls_to_fetch, | 132 void NotifyDone(size_t remaining_manifest_urls_to_fetch, |
| 130 size_t remaining_resource_urls_to_fetch); | 133 size_t remaining_resource_urls_to_fetch); |
| 131 | 134 |
| 132 // Fetches the next resource or manifest URL, if any remain. Fetching is done | 135 // Fetches the next resource or manifest URL, if any remain. Fetching is done |
| 133 // sequentially and depth-first: all resources are fetched for a manifest | 136 // sequentially and depth-first: all resources are fetched for a manifest |
| 134 // before the next manifest is fetched. This is done to limit the length of | 137 // before the next manifest is fetched. This is done to limit the length of |
| 135 // the |resource_urls_to_fetch_| list, reducing the memory usage. | 138 // the |resource_urls_to_fetch_| list, reducing the memory usage. |
| 136 void StartNextFetch(); | 139 void StartNextFetch(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 std::unique_ptr<net::URLFetcher> network_url_fetcher_; | 248 std::unique_ptr<net::URLFetcher> network_url_fetcher_; |
| 246 int64_t response_bytes_; | 249 int64_t response_bytes_; |
| 247 int64_t network_response_bytes_; | 250 int64_t network_response_bytes_; |
| 248 | 251 |
| 249 DISALLOW_COPY_AND_ASSIGN(Fetcher); | 252 DISALLOW_COPY_AND_ASSIGN(Fetcher); |
| 250 }; | 253 }; |
| 251 | 254 |
| 252 } // namespace precache | 255 } // namespace precache |
| 253 | 256 |
| 254 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ | 257 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ |
| OLD | NEW |