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

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

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, 6 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/timed_cache.h ('k') | chrome/chrome_browser.gypi » ('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 #include "chrome/browser/net/timed_cache.h"
6
7 #include "googleurl/src/gurl.h"
8
9 namespace chrome_browser_net {
10
11 TimedCache::TimedCache(const base::TimeDelta& max_duration)
12 : mru_cache_(UrlMruTimedCache::NO_AUTO_EVICT),
13 max_duration_(max_duration) {
14 }
15
16 // Make Clang compilation happy with explicit destructor.
17 TimedCache::~TimedCache() {}
18
19 bool TimedCache::WasRecentlySeen(const GURL& url) {
20 DCHECK_EQ(url.GetWithEmptyPath(), url);
21 // Evict any overly old entries.
22 base::TimeTicks now = base::TimeTicks::Now();
23 UrlMruTimedCache::reverse_iterator eldest = mru_cache_.rbegin();
24 while (!mru_cache_.empty()) {
25 DCHECK(eldest == mru_cache_.rbegin());
26 if (now - eldest->second < max_duration_)
27 break;
28 eldest = mru_cache_.Erase(eldest);
29 }
30 return mru_cache_.end() != mru_cache_.Peek(url);
31 }
32
33 void TimedCache::SetRecentlySeen(const GURL& url) {
34 DCHECK_EQ(url.GetWithEmptyPath(), url);
35 mru_cache_.Put(url, base::TimeTicks::Now());
36 }
37
38 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/timed_cache.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698