michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef SharedSSLState_h michael@0: #define SharedSSLState_h michael@0: michael@0: #include "mozilla/RefPtr.h" michael@0: #include "nsNSSIOLayer.h" michael@0: michael@0: class nsClientAuthRememberService; michael@0: class nsIObserver; michael@0: michael@0: namespace mozilla { michael@0: namespace psm { michael@0: michael@0: class SharedSSLState { michael@0: public: michael@0: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedSSLState) michael@0: SharedSSLState(); michael@0: ~SharedSSLState(); michael@0: michael@0: static void GlobalInit(); michael@0: static void GlobalCleanup(); michael@0: michael@0: nsClientAuthRememberService* GetClientAuthRememberService() { michael@0: return mClientAuthRemember; michael@0: } michael@0: michael@0: nsSSLIOLayerHelpers& IOLayerHelpers() { michael@0: return mIOLayerHelpers; michael@0: } michael@0: michael@0: // Main-thread only michael@0: void ResetStoredData(); michael@0: void NotePrivateBrowsingStatus(); michael@0: void SetOCSPStaplingEnabled(bool staplingEnabled) michael@0: { michael@0: mOCSPStaplingEnabled = staplingEnabled; michael@0: } michael@0: michael@0: // The following methods may be called from any thread michael@0: bool SocketCreated(); michael@0: void NoteSocketCreated(); michael@0: static void NoteCertOverrideServiceInstantiated(); michael@0: static void NoteCertDBServiceInstantiated(); michael@0: bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; } michael@0: michael@0: private: michael@0: void Cleanup(); michael@0: michael@0: nsCOMPtr mObserver; michael@0: RefPtr mClientAuthRemember; michael@0: nsSSLIOLayerHelpers mIOLayerHelpers; michael@0: michael@0: // True if any sockets have been created that use this shared data. michael@0: // Requires synchronization between the socket and main threads for michael@0: // reading/writing. michael@0: Mutex mMutex; michael@0: bool mSocketCreated; michael@0: bool mOCSPStaplingEnabled; michael@0: }; michael@0: michael@0: SharedSSLState* PublicSSLState(); michael@0: SharedSSLState* PrivateSSLState(); michael@0: michael@0: } // namespace psm michael@0: } // namespace mozilla michael@0: michael@0: #endif