Bug 1658278 - Move member initialization to header file r=necko-reviewers,dragana

Differential Revision: https://phabricator.services.mozilla.com/D107665
This commit is contained in:
Valentin Gosu 2021-03-19 17:51:26 +00:00
Родитель 0aea403b8a
Коммит 8e80fa3f32
2 изменённых файлов: 12 добавлений и 22 удалений

Просмотреть файл

@ -64,18 +64,7 @@ const nsCString& TRRService::ProviderKey() { return kTRRDomains[sDomainIndex]; }
NS_IMPL_ISUPPORTS(TRRService, nsIObserver, nsISupportsWeakReference)
TRRService::TRRService()
: mInitialized(false),
mBlocklistDurationSeconds(60),
mLock("trrservice"),
mConfirmationNS("example.com"_ns),
mCaptiveIsPassed(false),
mTRRBLStorage("DataMutex::TRRBlocklist"),
mParentalControlEnabled(false) {
mConfirmation.mState = CONFIRM_INIT;
mConfirmation.mTRRFailures = 0;
MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
}
TRRService::TRRService() { MOZ_ASSERT(NS_IsMainThread(), "wrong thread"); }
// static
void TRRService::AddObserver(nsIObserver* aObserver,

Просмотреть файл

@ -115,24 +115,25 @@ class TRRService : public TRRServiceBase,
void CompleteConfirmation(nsresult aStatus, TRR* aTrrRequest);
bool mInitialized;
Atomic<uint32_t, Relaxed> mBlocklistDurationSeconds;
bool mInitialized{false};
Atomic<uint32_t, Relaxed> mBlocklistDurationSeconds{60};
Mutex mLock;
Mutex mLock{"TRRService"};
nsCString mPrivateCred; // main thread only
nsCString mConfirmationNS;
nsCString mConfirmationNS{"example.com"_ns};
nsCString mBootstrapAddr;
Atomic<bool, Relaxed>
mCaptiveIsPassed; // set when captive portal check is passed
Atomic<bool, Relaxed> mCaptiveIsPassed{
false}; // set when captive portal check is passed
Atomic<bool, Relaxed> mDisableIPv6; // don't even try
// TRR Blocklist storage
// mTRRBLStorage is only modified on the main thread, but we query whether it
// is initialized or not off the main thread as well. Therefore we need to
// lock while creating it and while accessing it off the main thread.
DataMutex<nsTHashMap<nsCStringHashKey, int32_t>> mTRRBLStorage;
DataMutex<nsTHashMap<nsCStringHashKey, int32_t>> mTRRBLStorage{
"DataMutex::TRRBlocklist"};
// A set of domains that we should not use TRR for.
nsTHashtable<nsCStringHashKey> mExcludedDomains;
@ -150,12 +151,12 @@ class TRRService : public TRRServiceBase,
public:
static const size_t RESULTS_SIZE = 32;
Atomic<ConfirmationState, Relaxed> mState;
Atomic<ConfirmationState, Relaxed> mState{CONFIRM_INIT};
RefPtr<TRR> mTask;
nsCOMPtr<nsITimer> mTimer;
uint32_t mRetryInterval = 125; // milliseconds until retry
// The number of TRR requests that failed in a row.
Atomic<uint32_t, Relaxed> mTRRFailures;
Atomic<uint32_t, Relaxed> mTRRFailures{0};
// This buffer holds consecutive TRR failures reported by calling
// TRRIsOkay(). It is only meant for reporting event telemetry.
@ -197,7 +198,7 @@ class TRRService : public TRRServiceBase,
ConfirmationContext mConfirmation;
bool mParentalControlEnabled;
bool mParentalControlEnabled{false};
RefPtr<ODoHService> mODoHService;
nsCOMPtr<nsINetworkLinkService> mLinkService;
};