OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/base/ssl_config_service_win.h" | 5 #include "net/base/ssl_config_service_win.h" |
6 | 6 |
| 7 #include "base/thread_restrictions.h" |
7 #include "base/win/registry.h" | 8 #include "base/win/registry.h" |
8 | 9 |
9 using base::TimeDelta; | 10 using base::TimeDelta; |
10 using base::TimeTicks; | 11 using base::TimeTicks; |
11 using base::win::RegKey; | 12 using base::win::RegKey; |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 static const int kConfigUpdateInterval = 10; // seconds | 16 static const int kConfigUpdateInterval = 10; // seconds |
16 | 17 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 53 |
53 void SSLConfigServiceWin::GetSSLConfigAt(SSLConfig* config, TimeTicks now) { | 54 void SSLConfigServiceWin::GetSSLConfigAt(SSLConfig* config, TimeTicks now) { |
54 if (!ever_updated_ || | 55 if (!ever_updated_ || |
55 now - config_time_ > TimeDelta::FromSeconds(kConfigUpdateInterval)) | 56 now - config_time_ > TimeDelta::FromSeconds(kConfigUpdateInterval)) |
56 UpdateConfig(now); | 57 UpdateConfig(now); |
57 *config = config_info_; | 58 *config = config_info_; |
58 } | 59 } |
59 | 60 |
60 // static | 61 // static |
61 bool SSLConfigServiceWin::GetSSLConfigNow(SSLConfig* config) { | 62 bool SSLConfigServiceWin::GetSSLConfigNow(SSLConfig* config) { |
| 63 // This registry access goes to disk and will slow down the IO thread. |
| 64 // http://crbug.com/61455 |
| 65 base::ThreadRestrictions::ScopedAllowIO allow_io; |
62 RegKey internet_settings; | 66 RegKey internet_settings; |
63 if (!internet_settings.Open(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, | 67 if (!internet_settings.Open(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, |
64 KEY_READ)) | 68 KEY_READ)) |
65 return false; | 69 return false; |
66 | 70 |
67 DWORD revocation; | 71 DWORD revocation; |
68 if (!internet_settings.ReadValueDW(kRevocationValueName, &revocation)) | 72 if (!internet_settings.ReadValueDW(kRevocationValueName, &revocation)) |
69 revocation = REVOCATION_DEFAULT; | 73 revocation = REVOCATION_DEFAULT; |
70 | 74 |
71 DWORD protocols; | 75 DWORD protocols; |
72 if (!internet_settings.ReadValueDW(kProtocolsValueName, &protocols)) | 76 if (!internet_settings.ReadValueDW(kProtocolsValueName, &protocols)) |
73 protocols = PROTOCOLS_DEFAULT; | 77 protocols = PROTOCOLS_DEFAULT; |
74 | 78 |
75 config->rev_checking_enabled = (revocation != 0); | 79 config->rev_checking_enabled = (revocation != 0); |
76 config->ssl2_enabled = ((protocols & SSL2) != 0); | 80 config->ssl2_enabled = ((protocols & SSL2) != 0); |
77 config->ssl3_enabled = ((protocols & SSL3) != 0); | 81 config->ssl3_enabled = ((protocols & SSL3) != 0); |
78 config->tls1_enabled = ((protocols & TLS1) != 0); | 82 config->tls1_enabled = ((protocols & TLS1) != 0); |
79 SSLConfigService::SetSSLConfigFlags(config); | 83 SSLConfigService::SetSSLConfigFlags(config); |
80 | 84 |
81 return true; | 85 return true; |
82 } | 86 } |
83 | 87 |
84 // static | 88 // static |
85 void SSLConfigServiceWin::SetRevCheckingEnabled(bool enabled) { | 89 void SSLConfigServiceWin::SetRevCheckingEnabled(bool enabled) { |
| 90 // This registry access goes to disk and will slow down the IO thread. |
| 91 // http://crbug.com/61455 |
86 DWORD value = enabled; | 92 DWORD value = enabled; |
87 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, | 93 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, |
88 KEY_WRITE); | 94 KEY_WRITE); |
89 internet_settings.WriteValue(kRevocationValueName, value); | 95 internet_settings.WriteValue(kRevocationValueName, value); |
90 // TODO(mattm): We should call UpdateConfig after updating settings, but these | 96 // TODO(mattm): We should call UpdateConfig after updating settings, but these |
91 // methods are static. | 97 // methods are static. |
92 } | 98 } |
93 | 99 |
94 // static | 100 // static |
95 void SSLConfigServiceWin::SetSSL2Enabled(bool enabled) { | 101 void SSLConfigServiceWin::SetSSL2Enabled(bool enabled) { |
96 SetSSLVersionEnabled(SSL2, enabled); | 102 SetSSLVersionEnabled(SSL2, enabled); |
97 } | 103 } |
98 | 104 |
99 // static | 105 // static |
100 void SSLConfigServiceWin::SetSSL3Enabled(bool enabled) { | 106 void SSLConfigServiceWin::SetSSL3Enabled(bool enabled) { |
101 SetSSLVersionEnabled(SSL3, enabled); | 107 SetSSLVersionEnabled(SSL3, enabled); |
102 } | 108 } |
103 | 109 |
104 // static | 110 // static |
105 void SSLConfigServiceWin::SetTLS1Enabled(bool enabled) { | 111 void SSLConfigServiceWin::SetTLS1Enabled(bool enabled) { |
106 SetSSLVersionEnabled(TLS1, enabled); | 112 SetSSLVersionEnabled(TLS1, enabled); |
107 } | 113 } |
108 | 114 |
109 // static | 115 // static |
110 void SSLConfigServiceWin::SetSSLVersionEnabled(int version, bool enabled) { | 116 void SSLConfigServiceWin::SetSSLVersionEnabled(int version, bool enabled) { |
| 117 // This registry access goes to disk and will slow down the IO thread. |
| 118 // http://crbug.com/61455 |
111 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, | 119 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, |
112 KEY_READ | KEY_WRITE); | 120 KEY_READ | KEY_WRITE); |
113 DWORD value; | 121 DWORD value; |
114 if (!internet_settings.ReadValueDW(kProtocolsValueName, &value)) | 122 if (!internet_settings.ReadValueDW(kProtocolsValueName, &value)) |
115 value = PROTOCOLS_DEFAULT; | 123 value = PROTOCOLS_DEFAULT; |
116 if (enabled) | 124 if (enabled) |
117 value |= version; | 125 value |= version; |
118 else | 126 else |
119 value &= ~version; | 127 value &= ~version; |
120 internet_settings.WriteValue(kProtocolsValueName, value); | 128 internet_settings.WriteValue(kProtocolsValueName, value); |
121 // TODO(mattm): We should call UpdateConfig after updating settings, but these | 129 // TODO(mattm): We should call UpdateConfig after updating settings, but these |
122 // methods are static. | 130 // methods are static. |
123 } | 131 } |
124 | 132 |
125 void SSLConfigServiceWin::UpdateConfig(TimeTicks now) { | 133 void SSLConfigServiceWin::UpdateConfig(TimeTicks now) { |
126 SSLConfig orig_config = config_info_; | 134 SSLConfig orig_config = config_info_; |
127 GetSSLConfigNow(&config_info_); | 135 GetSSLConfigNow(&config_info_); |
128 if (ever_updated_) | 136 if (ever_updated_) |
129 ProcessConfigUpdate(orig_config, config_info_); | 137 ProcessConfigUpdate(orig_config, config_info_); |
130 config_time_ = now; | 138 config_time_ = now; |
131 ever_updated_ = true; | 139 ever_updated_ = true; |
132 } | 140 } |
133 | 141 |
134 } // namespace net | 142 } // namespace net |
OLD | NEW |