| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 static void RecordCompletionStatistics( | 99 static void RecordCompletionStatistics( |
| 100 const PrecacheUnfinishedWork& unfinished_work, | 100 const PrecacheUnfinishedWork& unfinished_work, |
| 101 size_t remaining_manifest_urls_to_fetch, | 101 size_t remaining_manifest_urls_to_fetch, |
| 102 size_t remaining_resource_urls_to_fetch); | 102 size_t remaining_resource_urls_to_fetch); |
| 103 | 103 |
| 104 // Constructs a new PrecacheFetcher. The |starting_hosts| parameter is a | 104 // Constructs a new PrecacheFetcher. The |starting_hosts| parameter is a |
| 105 // prioritized list of hosts that the user commonly visits. These hosts are | 105 // prioritized list of hosts that the user commonly visits. These hosts are |
| 106 // used by a server side component to construct a list of resource URLs that | 106 // used by a server side component to construct a list of resource URLs that |
| 107 // the user is likely to fetch. Takes ownership of |unfinished_work|. | 107 // the user is likely to fetch. Takes ownership of |unfinished_work|. |
| 108 PrecacheFetcher( | 108 PrecacheFetcher(net::URLRequestContextGetter* request_context, |
| 109 net::URLRequestContextGetter* request_context, | 109 const GURL& config_url, |
| 110 const GURL& config_url, | 110 const std::string& manifest_url_prefix, |
| 111 const std::string& manifest_url_prefix, | 111 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work, |
| 112 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work, | 112 uint32_t experiment_id, |
| 113 PrecacheDelegate* precache_delegate); | 113 PrecacheDelegate* precache_delegate); |
| 114 | 114 |
| 115 virtual ~PrecacheFetcher(); | 115 virtual ~PrecacheFetcher(); |
| 116 | 116 |
| 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. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Non-owning pointer. Should not be NULL. | 172 // Non-owning pointer. Should not be NULL. |
| 173 PrecacheDelegate* precache_delegate_; | 173 PrecacheDelegate* precache_delegate_; |
| 174 | 174 |
| 175 std::list<GURL> manifest_urls_to_fetch_; | 175 std::list<GURL> manifest_urls_to_fetch_; |
| 176 std::list<GURL> resource_urls_to_fetch_; | 176 std::list<GURL> resource_urls_to_fetch_; |
| 177 | 177 |
| 178 FetcherPool<Fetcher> pool_; | 178 FetcherPool<Fetcher> pool_; |
| 179 | 179 |
| 180 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; | 180 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; |
| 181 | 181 |
| 182 // The fieldtrial experiment ID. |
| 183 uint32_t experiment_id_; |
| 184 |
| 182 DISALLOW_COPY_AND_ASSIGN(PrecacheFetcher); | 185 DISALLOW_COPY_AND_ASSIGN(PrecacheFetcher); |
| 183 }; | 186 }; |
| 184 | 187 |
| 185 // Class that fetches a URL, and runs the specified callback when the fetch is | 188 // Class that fetches a URL, and runs the specified callback when the fetch is |
| 186 // complete. This class exists so that a different method can be run in | 189 // complete. This class exists so that a different method can be run in |
| 187 // response to different kinds of fetches, e.g. OnConfigFetchComplete when | 190 // response to different kinds of fetches, e.g. OnConfigFetchComplete when |
| 188 // configuration settings are fetched, OnManifestFetchComplete when a manifest | 191 // configuration settings are fetched, OnManifestFetchComplete when a manifest |
| 189 // is fetched, etc. | 192 // is fetched, etc. |
| 190 // | 193 // |
| 191 // This class tries to increase freshness while limiting network usage, by using | 194 // This class tries to increase freshness while limiting network usage, by using |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 std::unique_ptr<net::URLFetcher> network_url_fetcher_; | 245 std::unique_ptr<net::URLFetcher> network_url_fetcher_; |
| 243 int64_t response_bytes_; | 246 int64_t response_bytes_; |
| 244 int64_t network_response_bytes_; | 247 int64_t network_response_bytes_; |
| 245 | 248 |
| 246 DISALLOW_COPY_AND_ASSIGN(Fetcher); | 249 DISALLOW_COPY_AND_ASSIGN(Fetcher); |
| 247 }; | 250 }; |
| 248 | 251 |
| 249 } // namespace precache | 252 } // namespace precache |
| 250 | 253 |
| 251 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ | 254 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ |
| OLD | NEW |