security/manager/ssl/src/SharedSSLState.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/src/SharedSSLState.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef SharedSSLState_h
    1.11 +#define SharedSSLState_h
    1.12 +
    1.13 +#include "mozilla/RefPtr.h"
    1.14 +#include "nsNSSIOLayer.h"
    1.15 +
    1.16 +class nsClientAuthRememberService;
    1.17 +class nsIObserver;
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace psm {
    1.21 +
    1.22 +class SharedSSLState {
    1.23 +public:
    1.24 +  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedSSLState)
    1.25 +  SharedSSLState();
    1.26 +  ~SharedSSLState();
    1.27 +
    1.28 +  static void GlobalInit();
    1.29 +  static void GlobalCleanup();
    1.30 +
    1.31 +  nsClientAuthRememberService* GetClientAuthRememberService() {
    1.32 +    return mClientAuthRemember;
    1.33 +  }
    1.34 +
    1.35 +  nsSSLIOLayerHelpers& IOLayerHelpers() {
    1.36 +    return mIOLayerHelpers;
    1.37 +  }
    1.38 +
    1.39 +  // Main-thread only
    1.40 +  void ResetStoredData();
    1.41 +  void NotePrivateBrowsingStatus();
    1.42 +  void SetOCSPStaplingEnabled(bool staplingEnabled)
    1.43 +  {
    1.44 +    mOCSPStaplingEnabled = staplingEnabled;
    1.45 +  }
    1.46 +
    1.47 +  // The following methods may be called from any thread
    1.48 +  bool SocketCreated();
    1.49 +  void NoteSocketCreated();
    1.50 +  static void NoteCertOverrideServiceInstantiated();
    1.51 +  static void NoteCertDBServiceInstantiated();
    1.52 +  bool IsOCSPStaplingEnabled() const { return mOCSPStaplingEnabled; }
    1.53 +
    1.54 +private:
    1.55 +  void Cleanup();
    1.56 +
    1.57 +  nsCOMPtr<nsIObserver> mObserver;
    1.58 +  RefPtr<nsClientAuthRememberService> mClientAuthRemember;
    1.59 +  nsSSLIOLayerHelpers mIOLayerHelpers;
    1.60 +
    1.61 +  // True if any sockets have been created that use this shared data.
    1.62 +  // Requires synchronization between the socket and main threads for
    1.63 +  // reading/writing.
    1.64 +  Mutex mMutex;
    1.65 +  bool mSocketCreated;
    1.66 +  bool mOCSPStaplingEnabled;
    1.67 +};
    1.68 +
    1.69 +SharedSSLState* PublicSSLState();
    1.70 +SharedSSLState* PrivateSSLState();
    1.71 +
    1.72 +} // namespace psm
    1.73 +} // namespace mozilla
    1.74 +
    1.75 +#endif

mercurial