зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1745063 - Don't send SetOffline IPC to socket process in nsIOService::Observe, r=necko-reviewers,valentin
Differential Revision: https://phabricator.services.mozilla.com/D133371
This commit is contained in:
Родитель
1128d4e52b
Коммит
fc1efcd291
|
@ -1215,7 +1215,10 @@ nsIOService::GetOffline(bool* offline) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::SetOffline(bool offline) {
|
||||
nsIOService::SetOffline(bool offline) { return SetOfflineInternal(offline); }
|
||||
|
||||
nsresult nsIOService::SetOfflineInternal(bool offline,
|
||||
bool notifySocketProcess) {
|
||||
LOG(("nsIOService::SetOffline offline=%d\n", offline));
|
||||
// When someone wants to go online (!offline) after we got XPCOM shutdown
|
||||
// throw ERROR_NOT_AVAILABLE to prevent return to online state.
|
||||
|
@ -1244,7 +1247,7 @@ nsIOService::SetOffline(bool offline) {
|
|||
NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
|
||||
offline ? u"true" : u"false");
|
||||
}
|
||||
if (SocketProcessReady()) {
|
||||
if (SocketProcessReady() && notifySocketProcess) {
|
||||
Unused << mSocketProcess->GetActor()->SendSetOffline(offline);
|
||||
}
|
||||
}
|
||||
|
@ -1578,6 +1581,13 @@ void nsIOService::SetHttpHandlerAlreadyShutingDown() {
|
|||
NS_IMETHODIMP
|
||||
nsIOService::Observe(nsISupports* subject, const char* topic,
|
||||
const char16_t* data) {
|
||||
if (UseSocketProcess() && SocketProcessReady() &&
|
||||
mObserverTopicForSocketProcess.Contains(nsDependentCString(topic))) {
|
||||
nsCString topicStr(topic);
|
||||
nsString dataStr(data);
|
||||
Unused << mSocketProcess->GetActor()->SendNotifyObserver(topicStr, dataStr);
|
||||
}
|
||||
|
||||
if (!strcmp(topic, kProfileChangeNetTeardownTopic)) {
|
||||
if (!mHttpHandlerAlreadyShutingDown) {
|
||||
mNetTearingDownStarted = PR_IntervalNow();
|
||||
|
@ -1585,12 +1595,12 @@ nsIOService::Observe(nsISupports* subject, const char* topic,
|
|||
mHttpHandlerAlreadyShutingDown = false;
|
||||
if (!mOffline) {
|
||||
mOfflineForProfileChange = true;
|
||||
SetOffline(true);
|
||||
SetOfflineInternal(true, false);
|
||||
}
|
||||
} else if (!strcmp(topic, kProfileChangeNetRestoreTopic)) {
|
||||
if (mOfflineForProfileChange) {
|
||||
mOfflineForProfileChange = false;
|
||||
SetOffline(false);
|
||||
SetOfflineInternal(false, false);
|
||||
}
|
||||
} else if (!strcmp(topic, kProfileDoChange)) {
|
||||
if (data && u"startup"_ns.Equals(data)) {
|
||||
|
@ -1620,7 +1630,7 @@ nsIOService::Observe(nsISupports* subject, const char* topic,
|
|||
}
|
||||
mHttpHandlerAlreadyShutingDown = false;
|
||||
|
||||
SetOffline(true);
|
||||
SetOfflineInternal(true, false);
|
||||
|
||||
if (mCaptivePortalService) {
|
||||
static_cast<CaptivePortalService*>(mCaptivePortalService.get())->Stop();
|
||||
|
@ -1648,17 +1658,6 @@ nsIOService::Observe(nsISupports* subject, const char* topic,
|
|||
NS_DispatchToMainThread(wakeupNotifier);
|
||||
}
|
||||
|
||||
if (UseSocketProcess() &&
|
||||
mObserverTopicForSocketProcess.Contains(nsDependentCString(topic))) {
|
||||
nsCString topicStr(topic);
|
||||
nsString dataStr(data);
|
||||
auto sendObserver = [topicStr, dataStr]() {
|
||||
Unused << gIOService->mSocketProcess->GetActor()->SendNotifyObserver(
|
||||
topicStr, dataStr);
|
||||
};
|
||||
CallOrWaitForSocketProcess(sendObserver);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ class nsIOService final : public nsIIOService,
|
|||
|
||||
void DestroySocketProcess();
|
||||
|
||||
nsresult SetOfflineInternal(bool offline, bool notifySocketProcess = true);
|
||||
|
||||
private:
|
||||
mozilla::Atomic<bool, mozilla::Relaxed> mOffline{true};
|
||||
mozilla::Atomic<bool, mozilla::Relaxed> mOfflineForProfileChange{false};
|
||||
|
|
Загрузка…
Ссылка в новой задаче