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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // We are now commited to doing the async preconnection call. | 53 // We are now commited to doing the async preconnection call. |
54 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectMotivation", motivation, | 54 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectMotivation", motivation, |
55 UrlInfo::MAX_MOTIVATED); | 55 UrlInfo::MAX_MOTIVATED); |
56 | 56 |
57 net::URLRequestContext* context = getter->GetURLRequestContext(); | 57 net::URLRequestContext* context = getter->GetURLRequestContext(); |
58 net::HttpTransactionFactory* factory = context->http_transaction_factory(); | 58 net::HttpTransactionFactory* factory = context->http_transaction_factory(); |
59 net::HttpNetworkSession* session = factory->GetSession(); | 59 net::HttpNetworkSession* session = factory->GetSession(); |
60 | 60 |
61 std::string user_agent; | 61 std::string user_agent; |
62 if (context->http_user_agent_settings()) | 62 if (context->http_user_agent_settings()) |
63 user_agent = context->http_user_agent_settings()->GetUserAgent(url); | 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::kPrivacyModeEnabled; | 72 request_info.privacy_mode = net::kPrivacyModeEnabled; |
73 | 73 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |