Backed out changeset f53842753805 (bug 1804872) for causing reftest failures on 15535...
[gecko.git] / security / manager / ssl / SharedSSLState.h
blob31562fc76beebd9d630efe69e7545cee2059bd64
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef SharedSSLState_h
8 #define SharedSSLState_h
10 #include "nsNSSIOLayer.h"
12 class nsIObserver;
14 namespace mozilla {
15 namespace psm {
17 class SharedSSLState {
18 public:
19 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedSSLState)
20 explicit SharedSSLState(uint32_t aTlsFlags = 0);
22 static void GlobalInit();
23 static void GlobalCleanup();
25 nsSSLIOLayerHelpers& IOLayerHelpers() { return mIOLayerHelpers; }
27 // Main-thread only
28 void ResetStoredData();
29 void NotePrivateBrowsingStatus();
30 void SetOCSPStaplingEnabled(bool staplingEnabled) {
31 mOCSPStaplingEnabled = staplingEnabled;
33 void SetOCSPMustStapleEnabled(bool mustStapleEnabled) {
34 mOCSPMustStapleEnabled = mustStapleEnabled;
36 void SetSignedCertTimestampsEnabled(bool signedCertTimestampsEnabled) {
37 mSignedCertTimestampsEnabled = signedCertTimestampsEnabled;
40 // The following methods may be called from any thread
41 bool SocketCreated();
42 void NoteSocketCreated();
43 static void NoteCertOverrideServiceInstantiated();
44 bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; }
45 bool IsOCSPMustStapleEnabled() const { return mOCSPMustStapleEnabled; }
46 bool IsSignedCertTimestampsEnabled() const {
47 return mSignedCertTimestampsEnabled;
50 private:
51 ~SharedSSLState();
53 void Cleanup();
55 nsCOMPtr<nsIObserver> mObserver;
56 nsSSLIOLayerHelpers mIOLayerHelpers;
58 // True if any sockets have been created that use this shared data.
59 // Requires synchronization between the socket and main threads for
60 // reading/writing.
61 Mutex mMutex MOZ_UNANNOTATED;
62 bool mSocketCreated;
63 bool mOCSPStaplingEnabled;
64 bool mOCSPMustStapleEnabled;
65 bool mSignedCertTimestampsEnabled;
68 SharedSSLState* PublicSSLState();
69 SharedSSLState* PrivateSSLState();
71 } // namespace psm
72 } // namespace mozilla
74 #endif