security/manager/ssl/src/SharedSSLState.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:35bb203ef4a0
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/. */
6
7 #ifndef SharedSSLState_h
8 #define SharedSSLState_h
9
10 #include "mozilla/RefPtr.h"
11 #include "nsNSSIOLayer.h"
12
13 class nsClientAuthRememberService;
14 class nsIObserver;
15
16 namespace mozilla {
17 namespace psm {
18
19 class SharedSSLState {
20 public:
21 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedSSLState)
22 SharedSSLState();
23 ~SharedSSLState();
24
25 static void GlobalInit();
26 static void GlobalCleanup();
27
28 nsClientAuthRememberService* GetClientAuthRememberService() {
29 return mClientAuthRemember;
30 }
31
32 nsSSLIOLayerHelpers& IOLayerHelpers() {
33 return mIOLayerHelpers;
34 }
35
36 // Main-thread only
37 void ResetStoredData();
38 void NotePrivateBrowsingStatus();
39 void SetOCSPStaplingEnabled(bool staplingEnabled)
40 {
41 mOCSPStaplingEnabled = staplingEnabled;
42 }
43
44 // The following methods may be called from any thread
45 bool SocketCreated();
46 void NoteSocketCreated();
47 static void NoteCertOverrideServiceInstantiated();
48 static void NoteCertDBServiceInstantiated();
49 bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; }
50
51 private:
52 void Cleanup();
53
54 nsCOMPtr<nsIObserver> mObserver;
55 RefPtr<nsClientAuthRememberService> mClientAuthRemember;
56 nsSSLIOLayerHelpers mIOLayerHelpers;
57
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;
62 bool mSocketCreated;
63 bool mOCSPStaplingEnabled;
64 };
65
66 SharedSSLState* PublicSSLState();
67 SharedSSLState* PrivateSSLState();
68
69 } // namespace psm
70 } // namespace mozilla
71
72 #endif

mercurial