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

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

Issue 1247063004: Unwind fastradio experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | net/http/http_network_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/google/core/browser/google_util.h"
23 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
24 #include "net/socket/ssl_client_socket.h" 23 #include "net/socket/ssl_client_socket.h"
25 #include "net/ssl/ssl_cipher_suite_names.h" 24 #include "net/ssl/ssl_cipher_suite_names.h"
26 #include "net/ssl/ssl_config_service.h" 25 #include "net/ssl/ssl_config_service.h"
27 #include "url/gurl.h"
28 26
29 using content::BrowserThread; 27 using content::BrowserThread;
30 28
31 namespace { 29 namespace {
32 30
33 // Field trial for ClientHello padding.
34 const char kClientHelloFieldTrialName[] = "FastRadioPadding";
35 const char kClientHelloFieldTrialEnabledGroupName[] = "Enabled";
36
37 // Converts a ListValue of StringValues into a vector of strings. Any Values 31 // Converts a ListValue of StringValues into a vector of strings. Any Values
38 // which cannot be converted will be skipped. 32 // which cannot be converted will be skipped.
39 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { 33 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) {
40 std::vector<std::string> results; 34 std::vector<std::string> results;
41 results.reserve(value->GetSize()); 35 results.reserve(value->GetSize());
42 std::string s; 36 std::string s;
43 for (base::ListValue::const_iterator it = value->begin(); it != value->end(); 37 for (base::ListValue::const_iterator it = value->begin(); it != value->end();
44 ++it) { 38 ++it) {
45 if (!(*it)->GetAsString(&s)) 39 if (!(*it)->GetAsString(&s))
46 continue; 40 continue;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // An SSLConfigService which stores a cached version of the current SSLConfig 87 // An SSLConfigService which stores a cached version of the current SSLConfig
94 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs 88 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs
95 // change. 89 // change.
96 class SSLConfigServicePref : public net::SSLConfigService { 90 class SSLConfigServicePref : public net::SSLConfigService {
97 public: 91 public:
98 SSLConfigServicePref() {} 92 SSLConfigServicePref() {}
99 93
100 // Store SSL config settings in |config|. Must only be called from IO thread. 94 // Store SSL config settings in |config|. Must only be called from IO thread.
101 void GetSSLConfig(net::SSLConfig* config) override; 95 void GetSSLConfig(net::SSLConfig* config) override;
102 96
103 bool SupportsFastradioPadding(const GURL& url) override;
104
105 private: 97 private:
106 // Allow the pref watcher to update our internal state. 98 // Allow the pref watcher to update our internal state.
107 friend class SSLConfigServiceManagerPref; 99 friend class SSLConfigServiceManagerPref;
108 100
109 ~SSLConfigServicePref() override {} 101 ~SSLConfigServicePref() override {}
110 102
111 // This method is posted to the IO thread from the browser thread to carry the 103 // This method is posted to the IO thread from the browser thread to carry the
112 // new config information. 104 // new config information.
113 void SetNewSSLConfig(const net::SSLConfig& new_config); 105 void SetNewSSLConfig(const net::SSLConfig& new_config);
114 106
115 // Cached value of prefs, should only be accessed from IO thread. 107 // Cached value of prefs, should only be accessed from IO thread.
116 net::SSLConfig cached_config_; 108 net::SSLConfig cached_config_;
117 109
118 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); 110 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref);
119 }; 111 };
120 112
121 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { 113 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) {
122 DCHECK_CURRENTLY_ON(BrowserThread::IO); 114 DCHECK_CURRENTLY_ON(BrowserThread::IO);
123 *config = cached_config_; 115 *config = cached_config_;
124 } 116 }
125 117
126 bool SSLConfigServicePref::SupportsFastradioPadding(const GURL& url) {
127 return google_util::IsGoogleHostname(url.host(),
128 google_util::ALLOW_SUBDOMAIN);
129 }
130
131 void SSLConfigServicePref::SetNewSSLConfig( 118 void SSLConfigServicePref::SetNewSSLConfig(
132 const net::SSLConfig& new_config) { 119 const net::SSLConfig& new_config) {
133 net::SSLConfig orig_config = cached_config_; 120 net::SSLConfig orig_config = cached_config_;
134 cached_config_ = new_config; 121 cached_config_ = new_config;
135 ProcessConfigUpdate(orig_config, new_config); 122 ProcessConfigUpdate(orig_config, new_config);
136 } 123 }
137 124
138 //////////////////////////////////////////////////////////////////////////////// 125 ////////////////////////////////////////////////////////////////////////////////
139 // SSLConfigServiceManagerPref 126 // SSLConfigServiceManagerPref
140 127
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (version_max) { 273 if (version_max) {
287 uint16 supported_version_max = config->version_max; 274 uint16 supported_version_max = config->version_max;
288 config->version_max = std::min(supported_version_max, version_max); 275 config->version_max = std::min(supported_version_max, version_max);
289 } 276 }
290 if (version_fallback_min) { 277 if (version_fallback_min) {
291 config->version_fallback_min = version_fallback_min; 278 config->version_fallback_min = version_fallback_min;
292 } 279 }
293 config->disabled_cipher_suites = disabled_cipher_suites_; 280 config->disabled_cipher_suites = disabled_cipher_suites_;
294 // disabling False Start also happens to disable record splitting. 281 // disabling False Start also happens to disable record splitting.
295 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); 282 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue();
296
297 base::StringPiece group =
298 base::FieldTrialList::FindFullName(kClientHelloFieldTrialName);
299 if (group.starts_with(kClientHelloFieldTrialEnabledGroupName)) {
300 config->fastradio_padding_enabled = true;
301 }
302 } 283 }
303 284
304 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( 285 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange(
305 PrefService* local_state) { 286 PrefService* local_state) {
306 const base::ListValue* value = 287 const base::ListValue* value =
307 local_state->GetList(prefs::kCipherSuiteBlacklist); 288 local_state->GetList(prefs::kCipherSuiteBlacklist);
308 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); 289 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value));
309 } 290 }
310 291
311 //////////////////////////////////////////////////////////////////////////////// 292 ////////////////////////////////////////////////////////////////////////////////
312 // SSLConfigServiceManager 293 // SSLConfigServiceManager
313 294
314 // static 295 // static
315 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( 296 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager(
316 PrefService* local_state) { 297 PrefService* local_state) {
317 return new SSLConfigServiceManagerPref(local_state); 298 return new SSLConfigServiceManagerPref(local_state);
318 } 299 }
319 300
320 // static 301 // static
321 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { 302 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) {
322 SSLConfigServiceManagerPref::RegisterPrefs(registry); 303 SSLConfigServiceManagerPref::RegisterPrefs(registry);
323 } 304 }
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698