зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1564960 - Calaulate network id on stream transport thread r=michal
Differential Revision: https://phabricator.services.mozilla.com/D39020 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ba042b192b
Коммит
91a9c98998
|
@ -14,7 +14,7 @@
|
|||
|
||||
class nsNetworkLinkService : public nsINetworkLinkService, public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSINETWORKLINKSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
|
@ -45,6 +45,7 @@ class nsNetworkLinkService : public nsINetworkLinkService, public nsIObserver {
|
|||
static void IPConfigChanged(SCDynamicStoreRef store, CFArrayRef changedKeys,
|
||||
void* info);
|
||||
void calculateNetworkId(void);
|
||||
void calculateNetworkIdInternal(void);
|
||||
|
||||
mozilla::Mutex mMutex;
|
||||
nsCString mNetworkId;
|
||||
|
|
|
@ -20,13 +20,14 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/SHA1.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsNetworkLinkService.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "../../base/IPv6Utils.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
@ -323,6 +324,20 @@ static bool ipv6NetworkId(SHA1Sum* sha1) {
|
|||
}
|
||||
|
||||
void nsNetworkLinkService::calculateNetworkId(void) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
target->Dispatch(NewRunnableMethod("nsNetworkLinkService::calculateNetworkIdInternal", this,
|
||||
&nsNetworkLinkService::calculateNetworkIdInternal),
|
||||
NS_DISPATCH_NORMAL));
|
||||
}
|
||||
|
||||
void nsNetworkLinkService::calculateNetworkIdInternal(void) {
|
||||
MOZ_ASSERT(!NS_IsMainThread(), "Should not be called on the main thread");
|
||||
SHA1Sum sha1;
|
||||
bool found4 = ipv4NetworkId(&sha1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче