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

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

Issue 3032014: Support both preconnection, and pre-resolution for subresources... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/browser/net/connect_interceptor.cc ('k') | chrome/browser/net/preconnect.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 (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 // A Preconnect instance maintains state while a TCP/IP connection is made, and 5 // A Preconnect instance maintains state while a TCP/IP connection is made, and
6 // and then released into the pool of available connections for future use. 6 // and then released into the pool of available connections for future use.
7 7
8 #ifndef CHROME_BROWSER_NET_PRECONNECT_H_ 8 #ifndef CHROME_BROWSER_NET_PRECONNECT_H_
9 #define CHROME_BROWSER_NET_PRECONNECT_H_ 9 #define CHROME_BROWSER_NET_PRECONNECT_H_
10 #pragma once 10 #pragma once
11 11
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "chrome/browser/net/url_info.h"
13 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
14 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
15 #include "net/socket/client_socket_handle.h" 16 #include "net/socket/client_socket_handle.h"
16 #include "net/socket/tcp_client_socket_pool.h" 17 #include "net/socket/tcp_client_socket_pool.h"
17 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
18 19
19 namespace chrome_browser_net { 20 namespace chrome_browser_net {
20 21
21 class Preconnect : public net::CompletionCallback { 22 class Preconnect : public net::CompletionCallback {
22 public: 23 public:
23 static bool PreconnectOnUIThread(const GURL& url); 24 // Try to preconnect. Typically motivated by OMNIBOX to reach search service.
25 static void PreconnectOnUIThread(const GURL& url,
26 UrlInfo::ResolutionMotivation motivation);
24 27
25 static void PreconnectOnIOThread(const GURL& url); 28 // Try to preconnect. Typically used by predictor when a subresource probably
29 // needs a connection.
30 static void PreconnectOnIOThread(const GURL& url,
31 UrlInfo::ResolutionMotivation motivation);
26 32
27 static void SetPreconnectDespiteProxy(bool status) { 33 static void SetPreconnectDespiteProxy(bool status) {
28 preconnect_despite_proxy_ = status; 34 preconnect_despite_proxy_ = status;
29 } 35 }
30 36
31 private: 37 private:
32 Preconnect() {} 38 Preconnect() {}
33 39
34 // Supply an instance that could have been used in an IO callback, but will 40 // Supply an instance that could have been used in an IO callback, but will
35 // never actually be used (because we reset the connection so quickly). 41 // never actually be used (because we reset the connection so quickly).
36 static Preconnect* callback_instance_; 42 static Preconnect* callback_instance_;
37 43
38 // IO Callback which whould be performed when the connection is established. 44 // IO Callback which whould be performed when the connection is established.
39 virtual void RunWithParams(const Tuple1<int>& params); 45 virtual void RunWithParams(const Tuple1<int>& params);
40 46
41 // Preconnections are currently conservative, and do nothing if there is a 47 // Preconnections are currently conservative, and do nothing if there is a
42 // chance that a proxy may be used. This boolean allows proxy settings to 48 // chance that a proxy may be used. This boolean allows proxy settings to
43 // be ignored (presumably because a user knows that the proxy won't be doing 49 // be ignored (presumably because a user knows that the proxy won't be doing
44 // much work anway). 50 // much work anway).
45 static bool preconnect_despite_proxy_; 51 static bool preconnect_despite_proxy_;
46 52
47 DISALLOW_COPY_AND_ASSIGN(Preconnect); 53 DISALLOW_COPY_AND_ASSIGN(Preconnect);
48 }; 54 };
49 } // chrome_browser_net 55 } // chrome_browser_net
50 56
51 #endif // CHROME_BROWSER_NET_PRECONNECT_H_ 57 #endif // CHROME_BROWSER_NET_PRECONNECT_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/connect_interceptor.cc ('k') | chrome/browser/net/preconnect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698