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

Unified Diff: chrome/browser/net/preconnect.h

Issue 3050040: Reland 54771 (and 54795) To enable TCP Preconnection by default... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/net/preconnect.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/preconnect.h
===================================================================
--- chrome/browser/net/preconnect.h (revision 55108)
+++ chrome/browser/net/preconnect.h (working copy)
@@ -19,7 +19,8 @@
namespace chrome_browser_net {
-class Preconnect : public net::CompletionCallback {
+class Preconnect : public net::CompletionCallback,
+ public base::RefCountedThreadSafe<Preconnect> {
public:
// Try to preconnect. Typically motivated by OMNIBOX to reach search service.
static void PreconnectOnUIThread(const GURL& url,
@@ -35,12 +36,16 @@
}
private:
- Preconnect() {}
+ friend class base::RefCountedThreadSafe<Preconnect>;
- // Supply an instance that could have been used in an IO callback, but will
- // never actually be used (because we reset the connection so quickly).
- static Preconnect* callback_instance_;
+ explicit Preconnect(UrlInfo::ResolutionMotivation motivation)
+ : motivation_(motivation) {
+ }
+ ~Preconnect();
+ // Request actual connection.
+ void Connect(const GURL& url);
+
// IO Callback which whould be performed when the connection is established.
virtual void RunWithParams(const Tuple1<int>& params);
@@ -50,6 +55,15 @@
// much work anway).
static bool preconnect_despite_proxy_;
+ // The handle holding the request. We need this so that we can mark the
+ // request as speculative when an actual socket is bound to it.
+ net::ClientSocketHandle handle_;
+
+ // Generally either LEARNED_REFERAL_MOTIVATED or OMNIBOX_MOTIVATED to indicate
+ // why we were trying to do a preconnection.
+ const UrlInfo::ResolutionMotivation motivation_;
+
+
DISALLOW_COPY_AND_ASSIGN(Preconnect);
};
} // chrome_browser_net
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/net/preconnect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698