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

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

Issue 15675002: Add the UMA recording recall of URLRequests preconnected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style fix 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/preconnect.h" 5 #include "chrome/browser/net/preconnect.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 net::HttpRequestInfo request_info; 60 net::HttpRequestInfo request_info;
61 request_info.url = url; 61 request_info.url = url;
62 request_info.method = "GET"; 62 request_info.method = "GET";
63 request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kUserAgent, 63 request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kUserAgent,
64 context->GetUserAgent(url)); 64 context->GetUserAgent(url));
65 65
66 net::NetworkDelegate* delegate = context->network_delegate(); 66 net::NetworkDelegate* delegate = context->network_delegate();
67 if (delegate->CanEnablePrivacyMode(url, first_party_for_cookies)) 67 if (delegate->CanEnablePrivacyMode(url, first_party_for_cookies))
68 request_info.privacy_mode = net::kPrivacyModeEnabled; 68 request_info.privacy_mode = net::kPrivacyModeEnabled;
69 69
70 delegate->NotifyBeforePreconnect(url);
71
70 // It almost doesn't matter whether we use net::LOWEST or net::HIGHEST 72 // It almost doesn't matter whether we use net::LOWEST or net::HIGHEST
71 // priority here, as we won't make a request, and will surrender the created 73 // priority here, as we won't make a request, and will surrender the created
72 // socket to the pool as soon as we can. However, we would like to mark the 74 // socket to the pool as soon as we can. However, we would like to mark the
73 // speculative socket as such, and IF we use a net::LOWEST priority, and if 75 // speculative socket as such, and IF we use a net::LOWEST priority, and if
74 // a navigation asked for a socket (after us) then it would get our socket, 76 // a navigation asked for a socket (after us) then it would get our socket,
75 // and we'd get its later-arriving socket, which might make us record that 77 // and we'd get its later-arriving socket, which might make us record that
76 // the speculation didn't help :-/. By using net::HIGHEST, we ensure that 78 // the speculation didn't help :-/. By using net::HIGHEST, we ensure that
77 // a socket is given to us if "we asked first" and this allows us to mark it 79 // a socket is given to us if "we asked first" and this allows us to mark it
78 // as speculative, and better detect stats (if it gets used). 80 // as speculative, and better detect stats (if it gets used).
79 // TODO(jar): histogram to see how often we accidentally use a previously- 81 // TODO(jar): histogram to see how often we accidentally use a previously-
(...skipping 27 matching lines...) Expand all
107 109
108 // All preconnects should perform EV certificate verification. 110 // All preconnects should perform EV certificate verification.
109 ssl_config.verify_ev_cert = true; 111 ssl_config.verify_ev_cert = true;
110 112
111 net::HttpStreamFactory* http_stream_factory = session->http_stream_factory(); 113 net::HttpStreamFactory* http_stream_factory = session->http_stream_factory();
112 http_stream_factory->PreconnectStreams(count, request_info, priority, 114 http_stream_factory->PreconnectStreams(count, request_info, priority,
113 ssl_config, ssl_config); 115 ssl_config, ssl_config);
114 } 116 }
115 117
116 } // namespace chrome_browser_net 118 } // namespace chrome_browser_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698