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

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: CR updates 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/socket/ssl_client_socket.h" 23 #include "net/socket/ssl_client_socket.h"
24 #include "net/ssl/ssl_cipher_suite_names.h" 24 #include "net/ssl/ssl_cipher_suite_names.h"
25 #include "net/ssl/ssl_config_service.h" 25 #include "net/ssl/ssl_config_service.h"
26 #include "url/gurl.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(const GURL& url) override;
106
99 private: 107 private:
100 // Allow the pref watcher to update our internal state. 108 // Allow the pref watcher to update our internal state.
101 friend class SSLConfigServiceManagerPref; 109 friend class SSLConfigServiceManagerPref;
102 110
103 ~SSLConfigServicePref() override {} 111 ~SSLConfigServicePref() override {}
104 112
105 // This method is posted to the IO thread from the browser thread to carry the 113 // This method is posted to the IO thread from the browser thread to carry the
106 // new config information. 114 // new config information.
107 void SetNewSSLConfig(const net::SSLConfig& new_config); 115 void SetNewSSLConfig(const net::SSLConfig& new_config);
108 116
109 // Cached value of prefs, should only be accessed from IO thread. 117 // Cached value of prefs, should only be accessed from IO thread.
110 net::SSLConfig cached_config_; 118 net::SSLConfig cached_config_;
111 119
112 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); 120 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref);
113 }; 121 };
114 122
115 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { 123 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) {
116 *config = cached_config_; 124 *config = cached_config_;
117 } 125 }
118 126
127 bool SSLConfigServicePref::SupportsFastradioPadding(const GURL& url) {
128 const std::string& host = url.host();
129 bool is_google =
130 host == kGoogleDomain ||
davidben 2015/02/04 01:04:47 ".google.com" isn't a valid hostname. I assume you
jeremyim 2015/02/04 17:26:32 Done.
131 (host.size() > 11 && host.rfind(kGoogleDomain) == host.size() - 11);
132 return is_google;
133 }
134
119 void SSLConfigServicePref::SetNewSSLConfig( 135 void SSLConfigServicePref::SetNewSSLConfig(
120 const net::SSLConfig& new_config) { 136 const net::SSLConfig& new_config) {
121 net::SSLConfig orig_config = cached_config_; 137 net::SSLConfig orig_config = cached_config_;
122 cached_config_ = new_config; 138 cached_config_ = new_config;
123 ProcessConfigUpdate(orig_config, new_config); 139 ProcessConfigUpdate(orig_config, new_config);
124 } 140 }
125 141
126 //////////////////////////////////////////////////////////////////////////////// 142 ////////////////////////////////////////////////////////////////////////////////
127 // SSLConfigServiceManagerPref 143 // SSLConfigServiceManagerPref
128 144
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (version_max) { 295 if (version_max) {
280 uint16 supported_version_max = config->version_max; 296 uint16 supported_version_max = config->version_max;
281 config->version_max = std::min(supported_version_max, version_max); 297 config->version_max = std::min(supported_version_max, version_max);
282 } 298 }
283 if (version_fallback_min) { 299 if (version_fallback_min) {
284 config->version_fallback_min = version_fallback_min; 300 config->version_fallback_min = version_fallback_min;
285 } 301 }
286 config->disabled_cipher_suites = disabled_cipher_suites_; 302 config->disabled_cipher_suites = disabled_cipher_suites_;
287 // disabling False Start also happens to disable record splitting. 303 // disabling False Start also happens to disable record splitting.
288 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); 304 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue();
305
306 base::StringPiece group =
307 base::FieldTrialList::FindFullName(kClientHelloFieldTrialName);
308 if (group.starts_with(kClientHelloFieldTrialEnabledGroupName)) {
309 config->enable_fastradio_padding = true;
310 }
289 } 311 }
290 312
291 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( 313 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange(
292 PrefService* local_state) { 314 PrefService* local_state) {
293 const base::ListValue* value = 315 const base::ListValue* value =
294 local_state->GetList(prefs::kCipherSuiteBlacklist); 316 local_state->GetList(prefs::kCipherSuiteBlacklist);
295 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); 317 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value));
296 } 318 }
297 319
298 //////////////////////////////////////////////////////////////////////////////// 320 ////////////////////////////////////////////////////////////////////////////////
299 // SSLConfigServiceManager 321 // SSLConfigServiceManager
300 322
301 // static 323 // static
302 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( 324 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager(
303 PrefService* local_state) { 325 PrefService* local_state) {
304 return new SSLConfigServiceManagerPref(local_state); 326 return new SSLConfigServiceManagerPref(local_state);
305 } 327 }
306 328
307 // static 329 // static
308 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { 330 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) {
309 SSLConfigServiceManagerPref::RegisterPrefs(registry); 331 SSLConfigServiceManagerPref::RegisterPrefs(registry);
310 } 332 }
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_transaction.cc » ('j') | net/http/http_network_transaction.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698