1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_BASE_SSL_CONFIG_SERVICE_MAC_H_ 6 #define NET_BASE_SSL_CONFIG_SERVICE_MAC_H_ 7 8 #include "base/time.h" 9 #include "net/base/ssl_config_service.h" 10 11 namespace net { 12 13 // This class is responsible for getting and setting the SSL configuration on 14 // Mac OS X. 15 class SSLConfigServiceMac : public SSLConfigService { 16 public: 17 SSLConfigServiceMac(); 18 explicit SSLConfigServiceMac(base::TimeTicks now); // Used for testing. 19 20 // Get the current SSL configuration settings. Can be called on any 21 // thread. 22 static bool GetSSLConfigNow(SSLConfig* config); 23 24 // Setters. Can be called on any thread. 25 static void SetRevCheckingEnabled(bool enabled); 26 static void SetSSL2Enabled(bool enabled); 27 static void SetSSL3Enabled(bool enabled); 28 static void SetTLS1Enabled(bool enabled); 29 30 // Get the (cached) SSL configuration settings that are fresh within 10 31 // seconds. This is cheaper than GetSSLConfigNow and is suitable when 32 // we don't need the absolutely current configuration settings. This 33 // method is not thread-safe, so it must be called on the same thread. GetSSLConfig(SSLConfig * config)34 void GetSSLConfig(SSLConfig* config) { 35 GetSSLConfigAt(config, base::TimeTicks::Now()); 36 } 37 38 // Used for testing. 39 void GetSSLConfigAt(SSLConfig* config, base::TimeTicks now); 40 41 private: ~SSLConfigServiceMac()42 virtual ~SSLConfigServiceMac() {} 43 44 void UpdateConfig(base::TimeTicks now); 45 46 // We store the system SSL config and the time that we fetched it. 47 SSLConfig config_info_; 48 base::TimeTicks config_time_; 49 bool ever_updated_; 50 51 DISALLOW_EVIL_CONSTRUCTORS(SSLConfigServiceMac); 52 }; 53 54 } // namespace net 55 56 #endif // NET_BASE_SSL_CONFIG_SERVICE_MAC_H_ 57