mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 881761 - Part 3: Initialize NSS when initializing PeerConnection. r=ekr,bsmith
This commit is contained in:
parent
a7d87f751d
commit
4afedddb6b
@ -45,6 +45,9 @@
|
||||
#include "nsDOMDataChannel.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/PublicSSL.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIScriptError.h"
|
||||
@ -81,9 +84,46 @@ using namespace mozilla::dom;
|
||||
|
||||
typedef PCObserverString ObString;
|
||||
|
||||
static const char* logTag = "PeerConnectionImpl";
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
static nsresult InitNSSInContent()
|
||||
{
|
||||
NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_NOT_SAME_THREAD);
|
||||
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Content) {
|
||||
MOZ_ASSUME_UNREACHABLE("Must be called in content process");
|
||||
}
|
||||
|
||||
static bool nssStarted = false;
|
||||
if (nssStarted) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NSS_NoDB_Init(nullptr) != SECSuccess) {
|
||||
CSFLogError(logTag, "NSS_NoDB_Init failed.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_FAILED(mozilla::psm::InitializeCipherSuite())) {
|
||||
CSFLogError(logTag, "Fail to set up nss cipher suite.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mozilla::psm::ConfigureMD5(false);
|
||||
|
||||
nssStarted = true;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
|
||||
namespace mozilla {
|
||||
class DataChannel;
|
||||
}
|
||||
|
||||
class nsIDOMDataChannel;
|
||||
|
||||
static const char* logTag = "PeerConnectionImpl";
|
||||
static const int DTLS_FINGERPRINT_LENGTH = 64;
|
||||
static const int MEDIA_STREAM_MUTE = 0x80;
|
||||
|
||||
@ -643,17 +683,24 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
|
||||
|
||||
mSTSThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
|
||||
MOZ_ASSERT(mSTSThread);
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
// This code interferes with the C++ unit test startup code.
|
||||
nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &res);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// Initialize NSS if we are in content process. For chrome process, NSS should already
|
||||
// been initialized.
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
// This code interferes with the C++ unit test startup code.
|
||||
nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &res);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
} else {
|
||||
NS_ENSURE_SUCCESS(res = InitNSSInContent(), res);
|
||||
}
|
||||
|
||||
// Currently no standalone unit tests for DataChannel,
|
||||
// which is the user of mWindow
|
||||
MOZ_ASSERT(aWindow);
|
||||
mWindow = aWindow;
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
#endif
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
|
||||
// Generate a random handle
|
||||
unsigned char handle_bin[8];
|
||||
|
Loading…
Reference in New Issue
Block a user