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

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

Issue 869393005: Perform ClientHello padding if the field trial is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@net_connection_error_uma
Patch Set: Re-implementation Created 5 years, 10 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 #include "chrome/browser/net/ssl_config_service_manager.h" 4 #include "chrome/browser/net/ssl_config_service_manager.h"
5 5
6 #include <algorithm> 6 #include <algorithm>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/prefs/pref_member.h" 14 #include "base/prefs/pref_member.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "components/content_settings/core/browser/content_settings_utils.h" 20 #include "components/content_settings/core/browser/content_settings_utils.h"
21 #include "components/content_settings/core/common/content_settings.h" 21 #include "components/content_settings/core/common/content_settings.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "net/base/host_port_pair.h"
23 #include "net/socket/ssl_client_socket.h" 24 #include "net/socket/ssl_client_socket.h"
24 #include "net/ssl/ssl_cipher_suite_names.h" 25 #include "net/ssl/ssl_cipher_suite_names.h"
25 #include "net/ssl/ssl_config_service.h" 26 #include "net/ssl/ssl_config_service.h"
26 27
27 using content::BrowserThread; 28 using content::BrowserThread;
28 29
29 namespace { 30 namespace {
30 31
32 // Field trial for ClientHello padding.
33 const char kClientHelloFieldTrialName[] = "FastRadioPadding";
34 const char kClientHelloFieldTrialEnabledGroupName[] = "Enabled";
35 const char* kGoogleDomain = ".google.com";
36
31 // Converts a ListValue of StringValues into a vector of strings. Any Values 37 // Converts a ListValue of StringValues into a vector of strings. Any Values
32 // which cannot be converted will be skipped. 38 // which cannot be converted will be skipped.
33 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { 39 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) {
34 std::vector<std::string> results; 40 std::vector<std::string> results;
35 results.reserve(value->GetSize()); 41 results.reserve(value->GetSize());
36 std::string s; 42 std::string s;
37 for (base::ListValue::const_iterator it = value->begin(); it != value->end(); 43 for (base::ListValue::const_iterator it = value->begin(); it != value->end();
38 ++it) { 44 ++it) {
39 if (!(*it)->GetAsString(&s)) 45 if (!(*it)->GetAsString(&s))
40 continue; 46 continue;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // An SSLConfigService which stores a cached version of the current SSLConfig 95 // An SSLConfigService which stores a cached version of the current SSLConfig
90 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs 96 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs
91 // change. 97 // change.
92 class SSLConfigServicePref : public net::SSLConfigService { 98 class SSLConfigServicePref : public net::SSLConfigService {
93 public: 99 public:
94 SSLConfigServicePref() {} 100 SSLConfigServicePref() {}
95 101
96 // Store SSL config settings in |config|. Must only be called from IO thread. 102 // Store SSL config settings in |config|. Must only be called from IO thread.
97 void GetSSLConfig(net::SSLConfig* config) override; 103 void GetSSLConfig(net::SSLConfig* config) override;
98 104
105 bool SupportsFastradioPadding(
106 const net::HostPortPair& host_and_port) override;
107
99 private: 108 private:
100 // Allow the pref watcher to update our internal state. 109 // Allow the pref watcher to update our internal state.
101 friend class SSLConfigServiceManagerPref; 110 friend class SSLConfigServiceManagerPref;
102 111
103 ~SSLConfigServicePref() override {} 112 ~SSLConfigServicePref() override {}
104 113
105 // This method is posted to the IO thread from the browser thread to carry the 114 // This method is posted to the IO thread from the browser thread to carry the
106 // new config information. 115 // new config information.
107 void SetNewSSLConfig(const net::SSLConfig& new_config); 116 void SetNewSSLConfig(const net::SSLConfig& new_config);
108 117
109 // Cached value of prefs, should only be accessed from IO thread. 118 // Cached value of prefs, should only be accessed from IO thread.
110 net::SSLConfig cached_config_; 119 net::SSLConfig cached_config_;
111 120
112 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); 121 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref);
113 }; 122 };
114 123
115 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { 124 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) {
116 *config = cached_config_; 125 *config = cached_config_;
117 } 126 }
118 127
128 bool SSLConfigServicePref::SupportsFastradioPadding(
129 const net::HostPortPair& host_and_port) {
130 const std::string& host = host_and_port.host();
131 bool is_google =
132 host == kGoogleDomain ||
133 (host.size() > 11 && host.rfind(kGoogleDomain) == host.size() - 11);
134 return is_google;
135 }
136
119 void SSLConfigServicePref::SetNewSSLConfig( 137 void SSLConfigServicePref::SetNewSSLConfig(
120 const net::SSLConfig& new_config) { 138 const net::SSLConfig& new_config) {
121 net::SSLConfig orig_config = cached_config_; 139 net::SSLConfig orig_config = cached_config_;
122 cached_config_ = new_config; 140 cached_config_ = new_config;
123 ProcessConfigUpdate(orig_config, new_config); 141 ProcessConfigUpdate(orig_config, new_config);
124 } 142 }
125 143
126 //////////////////////////////////////////////////////////////////////////////// 144 ////////////////////////////////////////////////////////////////////////////////
127 // SSLConfigServiceManagerPref 145 // SSLConfigServiceManagerPref
128 146
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (version_max) { 297 if (version_max) {
280 uint16 supported_version_max = config->version_max; 298 uint16 supported_version_max = config->version_max;
281 config->version_max = std::min(supported_version_max, version_max); 299 config->version_max = std::min(supported_version_max, version_max);
282 } 300 }
283 if (version_fallback_min) { 301 if (version_fallback_min) {
284 config->version_fallback_min = version_fallback_min; 302 config->version_fallback_min = version_fallback_min;
285 } 303 }
286 config->disabled_cipher_suites = disabled_cipher_suites_; 304 config->disabled_cipher_suites = disabled_cipher_suites_;
287 // disabling False Start also happens to disable record splitting. 305 // disabling False Start also happens to disable record splitting.
288 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); 306 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue();
307
308 base::StringPiece group =
309 base::FieldTrialList::FindFullName(kClientHelloFieldTrialName);
310 if (group.starts_with(kClientHelloFieldTrialEnabledGroupName)) {
311 config->enable_fastradio_padding = true;
312 }
289 } 313 }
290 314
291 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( 315 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange(
292 PrefService* local_state) { 316 PrefService* local_state) {
293 const base::ListValue* value = 317 const base::ListValue* value =
294 local_state->GetList(prefs::kCipherSuiteBlacklist); 318 local_state->GetList(prefs::kCipherSuiteBlacklist);
295 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); 319 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value));
296 } 320 }
297 321
298 //////////////////////////////////////////////////////////////////////////////// 322 ////////////////////////////////////////////////////////////////////////////////
299 // SSLConfigServiceManager 323 // SSLConfigServiceManager
300 324
301 // static 325 // static
302 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( 326 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager(
303 PrefService* local_state) { 327 PrefService* local_state) {
304 return new SSLConfigServiceManagerPref(local_state); 328 return new SSLConfigServiceManagerPref(local_state);
305 } 329 }
306 330
307 // static 331 // static
308 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { 332 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) {
309 SSLConfigServiceManagerPref::RegisterPrefs(registry); 333 SSLConfigServiceManagerPref::RegisterPrefs(registry);
310 } 334 }
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl_job.cc » ('j') | net/http/http_stream_factory_impl_job.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698