bug 700693 - OCSP stapling PSM changes r=bsmith
[gecko.git] / security / manager / ssl / src / SharedSSLState.h
blob57f4d4fa07ffd5fe9c4edd9a0a14e88dae1a0a7c
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 "mozilla/RefPtr.h"
11 #include "nsNSSIOLayer.h"
13 class nsClientAuthRememberService;
14 class nsIObserver;
16 namespace mozilla {
17 namespace psm {
19 class SharedSSLState {
20 public:
21 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedSSLState)
22 SharedSSLState();
23 ~SharedSSLState();
25 static void GlobalInit();
26 static void GlobalCleanup();
28 nsClientAuthRememberService* GetClientAuthRememberService() {
29 return mClientAuthRemember;
32 nsSSLIOLayerHelpers& IOLayerHelpers() {
33 return mIOLayerHelpers;
36 // Main-thread only
37 void ResetStoredData();
38 void NotePrivateBrowsingStatus();
39 void SetOCSPStaplingEnabled(bool enabled) { mOCSPStaplingEnabled = enabled; }
41 // The following methods may be called from any thread
42 bool SocketCreated();
43 void NoteSocketCreated();
44 static void NoteCertOverrideServiceInstantiated();
45 static void NoteCertDBServiceInstantiated();
46 bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; }
48 private:
49 void Cleanup();
51 nsCOMPtr<nsIObserver> mObserver;
52 RefPtr<nsClientAuthRememberService> mClientAuthRemember;
53 nsSSLIOLayerHelpers mIOLayerHelpers;
55 // True if any sockets have been created that use this shared data.
56 // Requires synchronization between the socket and main threads for
57 // reading/writing.
58 Mutex mMutex;
59 bool mSocketCreated;
60 bool mOCSPStaplingEnabled;
63 SharedSSLState* PublicSSLState();
64 SharedSSLState* PrivateSSLState();
66 } // namespace psm
67 } // namespace mozilla
69 #endif