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

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

Issue 7397008: Deprecate RegisterProtocolFactory/(Un)RegisterInterceptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent. Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/net/connect_interceptor.h" 5 #include "chrome/browser/net/connect_interceptor.h"
6 6
7 #include "chrome/browser/net/predictor_api.h" 7 #include "chrome/browser/net/predictor_api.h"
8 #include "net/base/load_flags.h" 8 #include "net/base/load_flags.h"
9 9
10 namespace chrome_browser_net { 10 namespace chrome_browser_net {
11 11
12 // We don't bother learning to preconnect via a GET if the original URL 12 // We don't bother learning to preconnect via a GET if the original URL
13 // navigation was so long ago, that a preconnection would have been dropped 13 // navigation was so long ago, that a preconnection would have been dropped
14 // anyway. We believe most servers will drop the connection in 10 seconds, so 14 // anyway. We believe most servers will drop the connection in 10 seconds, so
15 // we currently estimate this time-till-drop at 10 seconds. 15 // we currently estimate this time-till-drop at 10 seconds.
16 // TODO(jar): We should do a persistent field trial to validate/optimize this. 16 // TODO(jar): We should do a persistent field trial to validate/optimize this.
17 static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10; 17 static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10;
18 18
19 ConnectInterceptor::ConnectInterceptor() 19 ConnectInterceptor::ConnectInterceptor()
20 : timed_cache_(base::TimeDelta::FromSeconds( 20 : timed_cache_(base::TimeDelta::FromSeconds(
21 kMaxUnusedSocketLifetimeSecondsWithoutAGet)) { 21 kMaxUnusedSocketLifetimeSecondsWithoutAGet)) {
22 net::URLRequest::RegisterRequestInterceptor(this); 22 net::URLRequest::Deprecated::RegisterRequestInterceptor(this);
23 } 23 }
24 24
25 ConnectInterceptor::~ConnectInterceptor() { 25 ConnectInterceptor::~ConnectInterceptor() {
26 net::URLRequest::UnregisterRequestInterceptor(this); 26 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this);
27 } 27 }
28 28
29 net::URLRequestJob* ConnectInterceptor::MaybeIntercept( 29 net::URLRequestJob* ConnectInterceptor::MaybeIntercept(
30 net::URLRequest* request) { 30 net::URLRequest* request) {
31 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url())); 31 GURL request_scheme_host(Predictor::CanonicalizeUrl(request->url()));
32 if (request_scheme_host == GURL::EmptyGURL()) 32 if (request_scheme_host == GURL::EmptyGURL())
33 return NULL; 33 return NULL;
34 34
35 // Learn what URLs are likely to be needed during next startup. 35 // Learn what URLs are likely to be needed during next startup.
36 LearnAboutInitialNavigation(request_scheme_host); 36 LearnAboutInitialNavigation(request_scheme_host);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 return mru_cache_.end() != mru_cache_.Peek(url); 117 return mru_cache_.end() != mru_cache_.Peek(url);
118 } 118 }
119 119
120 void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) { 120 void ConnectInterceptor::TimedCache::SetRecentlySeen(const GURL& url) {
121 DCHECK_EQ(url.GetWithEmptyPath(), url); 121 DCHECK_EQ(url.GetWithEmptyPath(), url);
122 mru_cache_.Put(url, base::TimeTicks::Now()); 122 mru_cache_.Put(url, base::TimeTicks::Now());
123 } 123 }
124 124
125 } // namespace chrome_browser_net 125 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698