chore: update process singleton patch (#35376)

* chore: update process singleton patch

* fix: windows compilation error

* chore: remove outdated comment in patch
This commit is contained in:
Robo 2022-08-20 07:45:58 +09:00 committed by GitHub
parent 9b787d30f4
commit 19baea4bc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 188 deletions

View file

@ -715,8 +715,9 @@ void App::OnFinishLaunching(base::Value::Dict launch_info) {
void App::OnPreMainMessageLoopRun() {
content::BrowserChildProcessObserver::Add(this);
if (process_singleton_) {
process_singleton_->OnBrowserReady();
if (process_singleton_ && watch_singleton_socket_on_ready_) {
process_singleton_->StartWatching();
watch_singleton_socket_on_ready_ = false;
}
}
@ -1124,15 +1125,20 @@ bool App::RequestSingleInstanceLock(gin::Arguments* args) {
#endif
switch (process_singleton_->NotifyOtherProcessOrCreate()) {
case ProcessSingleton::NotifyResult::PROCESS_NONE:
if (content::BrowserThread::IsThreadInitialized(
content::BrowserThread::IO)) {
process_singleton_->StartWatching();
} else {
watch_singleton_socket_on_ready_ = true;
}
return true;
case ProcessSingleton::NotifyResult::LOCK_ERROR:
case ProcessSingleton::NotifyResult::PROFILE_IN_USE:
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED: {
process_singleton_.reset();
return false;
}
case ProcessSingleton::NotifyResult::PROCESS_NONE:
default: // Shouldn't be needed, but VS warns if it is not there.
return true;
}
}

View file

@ -264,6 +264,7 @@ class App : public ElectronBrowserClient::Delegate,
bool disable_hw_acceleration_ = false;
bool disable_domain_blocking_for_3DAPIs_ = false;
bool watch_singleton_socket_on_ready_ = false;
};
} // namespace api