OLD | NEW |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (context->http_user_agent_settings()) | 62 if (context->http_user_agent_settings()) |
63 user_agent = context->http_user_agent_settings()->GetUserAgent(); | 63 user_agent = context->http_user_agent_settings()->GetUserAgent(); |
64 net::HttpRequestInfo request_info; | 64 net::HttpRequestInfo request_info; |
65 request_info.url = url; | 65 request_info.url = url; |
66 request_info.method = "GET"; | 66 request_info.method = "GET"; |
67 request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kUserAgent, | 67 request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kUserAgent, |
68 user_agent); | 68 user_agent); |
69 | 69 |
70 net::NetworkDelegate* delegate = context->network_delegate(); | 70 net::NetworkDelegate* delegate = context->network_delegate(); |
71 if (delegate->CanEnablePrivacyMode(url, first_party_for_cookies)) | 71 if (delegate->CanEnablePrivacyMode(url, first_party_for_cookies)) |
72 request_info.privacy_mode = net::PRIVACY_MODE_ENABLED; | 72 request_info.privacy_mode = net::kPrivacyModeEnabled; |
73 | 73 |
74 // It almost doesn't matter whether we use net::LOWEST or net::HIGHEST | 74 // It almost doesn't matter whether we use net::LOWEST or net::HIGHEST |
75 // priority here, as we won't make a request, and will surrender the created | 75 // priority here, as we won't make a request, and will surrender the created |
76 // socket to the pool as soon as we can. However, we would like to mark the | 76 // socket to the pool as soon as we can. However, we would like to mark the |
77 // speculative socket as such, and IF we use a net::LOWEST priority, and if | 77 // speculative socket as such, and IF we use a net::LOWEST priority, and if |
78 // a navigation asked for a socket (after us) then it would get our socket, | 78 // a navigation asked for a socket (after us) then it would get our socket, |
79 // and we'd get its later-arriving socket, which might make us record that | 79 // and we'd get its later-arriving socket, which might make us record that |
80 // the speculation didn't help :-/. By using net::HIGHEST, we ensure that | 80 // the speculation didn't help :-/. By using net::HIGHEST, we ensure that |
81 // a socket is given to us if "we asked first" and this allows us to mark it | 81 // a socket is given to us if "we asked first" and this allows us to mark it |
82 // as speculative, and better detect stats (if it gets used). | 82 // as speculative, and better detect stats (if it gets used). |
(...skipping 29 matching lines...) Expand all Loading... |
112 | 112 |
113 // All preconnects should perform EV certificate verification. | 113 // All preconnects should perform EV certificate verification. |
114 ssl_config.verify_ev_cert = true; | 114 ssl_config.verify_ev_cert = true; |
115 | 115 |
116 net::HttpStreamFactory* http_stream_factory = session->http_stream_factory(); | 116 net::HttpStreamFactory* http_stream_factory = session->http_stream_factory(); |
117 http_stream_factory->PreconnectStreams(count, request_info, priority, | 117 http_stream_factory->PreconnectStreams(count, request_info, priority, |
118 ssl_config, ssl_config); | 118 ssl_config, ssl_config); |
119 } | 119 } |
120 | 120 |
121 } // namespace chrome_browser_net | 121 } // namespace chrome_browser_net |
OLD | NEW |