Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/security/manager/ssl/SharedSSLState.h
Line
Count
Source (jump to first uncovered line)
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
  explicit SharedSSLState(uint32_t aTlsFlags = 0);
23
24
  static void GlobalInit();
25
  static void GlobalCleanup();
26
27
0
  nsClientAuthRememberService* GetClientAuthRememberService() {
28
0
    return mClientAuthRemember;
29
0
  }
30
31
0
  nsSSLIOLayerHelpers& IOLayerHelpers() {
32
0
    return mIOLayerHelpers;
33
0
  }
34
35
  // Main-thread only
36
  void ResetStoredData();
37
  void NotePrivateBrowsingStatus();
38
  void SetOCSPStaplingEnabled(bool staplingEnabled)
39
0
  {
40
0
    mOCSPStaplingEnabled = staplingEnabled;
41
0
  }
42
  void SetOCSPMustStapleEnabled(bool mustStapleEnabled)
43
0
  {
44
0
    mOCSPMustStapleEnabled = mustStapleEnabled;
45
0
  }
46
  void SetSignedCertTimestampsEnabled(bool signedCertTimestampsEnabled)
47
0
  {
48
0
    mSignedCertTimestampsEnabled = signedCertTimestampsEnabled;
49
0
  }
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
  bool IsSignedCertTimestampsEnabled() const
58
0
  {
59
0
    return mSignedCertTimestampsEnabled;
60
0
  }
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