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

Side by Side Diff: chrome/browser/net/timed_cache.h

Issue 15675002: Add the UMA recording recall of URLRequests preconnected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing files Created 7 years, 7 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 | « chrome/browser/net/predictor.cc ('k') | chrome/browser/net/timed_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_TIMED_CACHE_H_
6 #define CHROME_BROWSER_NET_TIMED_CACHE_H_
7
8 #include "base/basictypes.h"
9 #include "base/containers/mru_cache.h"
10 #include "base/time.h"
11
12 class GURL;
13
14 namespace chrome_browser_net {
15
16 // Define a LRU cache that recalls all navigations within the last N seconds.
17 // When we learn about subresources to possibly preconnect to, it would be a
18 // waste to preconnect when the original navigation was too long ago. Any
19 // connected, but unused TCP/IP connection, will generally be reset by the
20 // server if it is not used quickly (i.e., GET or POST is sent).
21 class TimedCache {
22 public:
23 explicit TimedCache(const base::TimeDelta& max_duration);
24 ~TimedCache();
25
26 // Evicts any entries that have been in the FIFO "too long," and then checks
27 // to see if the given url is (still) in the FIFO cache.
28 bool WasRecentlySeen(const GURL& url);
29
30 // Adds the given url to the cache, where it will remain for max_duration_.
31 void SetRecentlySeen(const GURL& url);
32
33 private:
34 // Our cache will be keyed on a URL (actually, just a scheme/host/port).
35 // We will always track the time it was last added to the FIFO cache by
36 // remembering a TimeTicks value.
37 typedef base::MRUCache<GURL, base::TimeTicks> UrlMruTimedCache;
38 UrlMruTimedCache mru_cache_;
39
40 // The longest time an entry can persist in the cache, and still be found.
41 const base::TimeDelta max_duration_;
42
43 DISALLOW_COPY_AND_ASSIGN(TimedCache);
44 };
45
46 } // namespace chrome_browser_net
47
48 #endif // CHROME_BROWSER_NET_TIMED_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | chrome/browser/net/timed_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698