Line data Source code
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 :
24 : static void GlobalInit();
25 : static void GlobalCleanup();
26 :
27 0 : nsClientAuthRememberService* GetClientAuthRememberService() {
28 0 : return mClientAuthRemember;
29 : }
30 :
31 0 : nsSSLIOLayerHelpers& IOLayerHelpers() {
32 0 : return mIOLayerHelpers;
33 : }
34 :
35 : // Main-thread only
36 : void ResetStoredData();
37 : void NotePrivateBrowsingStatus();
38 2 : void SetOCSPStaplingEnabled(bool staplingEnabled)
39 : {
40 2 : mOCSPStaplingEnabled = staplingEnabled;
41 2 : }
42 2 : void SetOCSPMustStapleEnabled(bool mustStapleEnabled)
43 : {
44 2 : mOCSPMustStapleEnabled = mustStapleEnabled;
45 2 : }
46 2 : void SetSignedCertTimestampsEnabled(bool signedCertTimestampsEnabled)
47 : {
48 2 : mSignedCertTimestampsEnabled = signedCertTimestampsEnabled;
49 2 : }
50 :
51 : // The following methods may be called from any thread
52 : bool SocketCreated();
53 : void NoteSocketCreated();
54 : static void NoteCertOverrideServiceInstantiated();
55 0 : bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; }
56 0 : bool IsOCSPMustStapleEnabled() const { return mOCSPMustStapleEnabled; }
57 0 : bool IsSignedCertTimestampsEnabled() const
58 : {
59 0 : return mSignedCertTimestampsEnabled;
60 : }
61 :
62 : private:
63 : ~SharedSSLState();
64 :
65 : void Cleanup();
66 :
67 : nsCOMPtr<nsIObserver> mObserver;
68 : RefPtr<nsClientAuthRememberService> mClientAuthRemember;
69 : nsSSLIOLayerHelpers mIOLayerHelpers;
70 :
71 : // True if any sockets have been created that use this shared data.
72 : // Requires synchronization between the socket and main threads for
73 : // reading/writing.
74 : Mutex mMutex;
75 : bool mSocketCreated;
76 : bool mOCSPStaplingEnabled;
77 : bool mOCSPMustStapleEnabled;
78 : bool mSignedCertTimestampsEnabled;
79 : };
80 :
81 : SharedSSLState* PublicSSLState();
82 : SharedSSLState* PrivateSSLState();
83 :
84 : } // namespace psm
85 : } // namespace mozilla
86 :
87 : #endif
|