Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: components/precache/core/precache_fetcher.h

Issue 2623553003: precache: Add geometric resource weight function. (Closed)
Patch Set: Add default case, needed by some compilers. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 int64_t response_bytes_; 356 int64_t response_bytes_;
350 int64_t network_response_bytes_; 357 int64_t network_response_bytes_;
351 bool was_cached_; 358 bool was_cached_;
352 359
353 DISALLOW_COPY_AND_ASSIGN(Fetcher); 360 DISALLOW_COPY_AND_ASSIGN(Fetcher);
354 }; 361 };
355 362
356 } // namespace precache 363 } // namespace precache
357 364
358 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_ 365 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | components/precache/core/precache_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698