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 <deque> | 10 #include <deque> |
11 #include <list> | 11 #include <list> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "components/precache/core/fetcher_pool.h" | 22 #include "components/precache/core/fetcher_pool.h" |
| 23 #include "components/precache/core/proto/precache.pb.h" |
23 #include "components/precache/core/proto/quota.pb.h" | 24 #include "components/precache/core/proto/quota.pb.h" |
24 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
25 #include "net/url_request/url_fetcher_delegate.h" | 26 #include "net/url_request/url_fetcher_delegate.h" |
26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
27 | 28 |
28 namespace base { | 29 namespace base { |
29 class SingleThreadTaskRunner; | 30 class SingleThreadTaskRunner; |
30 } | 31 } |
31 | 32 |
32 namespace net { | 33 namespace net { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 // Daily quota. | 265 // Daily quota. |
265 PrecacheQuota quota_; | 266 PrecacheQuota quota_; |
266 | 267 |
267 // The fieldtrial experiment ID. | 268 // The fieldtrial experiment ID. |
268 uint32_t experiment_id_; | 269 uint32_t experiment_id_; |
269 | 270 |
270 DISALLOW_COPY_AND_ASSIGN(PrecacheFetcher); | 271 DISALLOW_COPY_AND_ASSIGN(PrecacheFetcher); |
271 }; | 272 }; |
272 | 273 |
| 274 // Visible for testing. |
| 275 double ResourceWeight( |
| 276 PrecacheConfigurationSettings::ResourceWeightFunction function, |
| 277 double resource_weight_ratio, |
| 278 int64_t host_visits); |
| 279 |
273 // Class that fetches a URL, and runs the specified callback when the fetch is | 280 // Class that fetches a URL, and runs the specified callback when the fetch is |
274 // complete. This class exists so that a different method can be run in | 281 // complete. This class exists so that a different method can be run in |
275 // response to different kinds of fetches, e.g. OnConfigFetchComplete when | 282 // response to different kinds of fetches, e.g. OnConfigFetchComplete when |
276 // configuration settings are fetched, OnManifestFetchComplete when a manifest | 283 // configuration settings are fetched, OnManifestFetchComplete when a manifest |
277 // is fetched, etc. | 284 // is fetched, etc. |
278 // | 285 // |
279 // This class tries to increase freshness while limiting network usage, by using | 286 // This class tries to increase freshness while limiting network usage, by using |
280 // the following strategy: | 287 // the following strategy: |
281 // 1. Fetch the URL from the cache. | 288 // 1. Fetch the URL from the cache. |
282 // 2a. If it's present and lacks revalidation headers, then stop. | 289 // 2a. If it's present and lacks revalidation headers, then stop. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 int64_t response_bytes_; | 343 int64_t response_bytes_; |
337 int64_t network_response_bytes_; | 344 int64_t network_response_bytes_; |
338 bool was_cached_; | 345 bool was_cached_; |
339 | 346 |
340 DISALLOW_COPY_AND_ASSIGN(Fetcher); | 347 DISALLOW_COPY_AND_ASSIGN(Fetcher); |
341 }; | 348 }; |
342 | 349 |
343 } // namespace precache | 350 } // namespace precache |
344 | 351 |
345 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ | 352 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ |
OLD | NEW |