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

Unified Diff: chrome/browser/net/connect_interceptor.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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/connect_interceptor.h ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/connect_interceptor.cc
diff --git a/chrome/browser/net/connect_interceptor.cc b/chrome/browser/net/connect_interceptor.cc
index 5555d866695665a58022d01f308475906951cb68..4770fba96690a0e49319d6b8652882e02ef22e76 100644
--- a/chrome/browser/net/connect_interceptor.cc
+++ b/chrome/browser/net/connect_interceptor.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,16 +10,9 @@
namespace chrome_browser_net {
-// We don't bother learning to preconnect via a GET if the original URL
-// navigation was so long ago, that a preconnection would have been dropped
-// anyway. We believe most servers will drop the connection in 10 seconds, so
-// we currently estimate this time-till-drop at 10 seconds.
-// TODO(jar): We should do a persistent field trial to validate/optimize this.
-static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10;
-
ConnectInterceptor::ConnectInterceptor(Predictor* predictor)
: timed_cache_(base::TimeDelta::FromSeconds(
- kMaxUnusedSocketLifetimeSecondsWithoutAGet)),
+ Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet)),
predictor_(predictor) {
DCHECK(predictor);
}
@@ -78,6 +71,8 @@ void ConnectInterceptor::WitnessURLRequest(net::URLRequest* request) {
}
timed_cache_.SetRecentlySeen(request_scheme_host);
+ predictor_->RecordPreconnectNavigationStats(request_scheme_host);
+
// Subresources for main frames usually get predicted when we detected the
// main frame request - way back in RenderViewHost::Navigate. So only handle
// predictions now for subresources or for redirected hosts.
@@ -87,31 +82,4 @@ void ConnectInterceptor::WitnessURLRequest(net::URLRequest* request) {
return;
}
-ConnectInterceptor::TimedCache::TimedCache(const base::TimeDelta& max_duration)
- : mru_cache_(UrlMruTimedCache::NO_AUTO_EVICT),
- max_duration_(max_duration) {
-}
-
-// Make Clang compilation happy with explicit destructor.
-ConnectInterceptor::TimedCache::~TimedCache() {}
-
-bool ConnectInterceptor::TimedCache::WasRecentlySeen(const GURL& url) {
- DCHECK_EQ(url.GetWithEmptyPath(), url);
- // Evict any overly old entries.
- base::TimeTicks now = base::TimeTicks::Now();
- UrlMruTimedCache::reverse_iterator eldest = mru_cache_.rbegin();
- while (!mru_cache_.empty()) {
- DCHECK(eldest == mru_cache_.rbegin());
- if (now - eldest->second < max_duration_)
- break;
- eldest = mru_cache_.Erase(eldest);
- }
- return mru_cache_.end() != mru_cache_.Peek(url);
-}
-
-void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) {
- DCHECK_EQ(url.GetWithEmptyPath(), url);
- mru_cache_.Put(url, base::TimeTicks::Now());
-}
-
} // namespace chrome_browser_net
« no previous file with comments | « chrome/browser/net/connect_interceptor.h ('k') | chrome/browser/net/predictor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698