From b7119b5756089e5c8ed02adfd7476324190f5112 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 20 Sep 2017 11:40:49 +0900 Subject: [PATCH] Create watcher when message loop is ready --- atom/browser/api/atom_api_app.cc | 6 +----- chromium_src/chrome/browser/process_singleton_posix.cc | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 5b482ae8b5..37ff0507d7 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -407,11 +407,7 @@ bool NotificationCallbackWrapper( const base::FilePath& cwd) { // Make sure the callback is called after app gets ready. if (Browser::Get()->is_ready()) { - // We definitely want to call this callback on the UI thread - content::BrowserThread::PostTask( - content::BrowserThread::UI, - FROM_HERE, - base::Bind(base::IgnoreResult(callback), cmd, cwd)); + callback.Run(cmd, cwd); } else { scoped_refptr task_runner( base::ThreadTaskRunnerHandle::Get()); diff --git a/chromium_src/chrome/browser/process_singleton_posix.cc b/chromium_src/chrome/browser/process_singleton_posix.cc index 6ea5b54527..1943ad51f6 100644 --- a/chromium_src/chrome/browser/process_singleton_posix.cc +++ b/chromium_src/chrome/browser/process_singleton_posix.cc @@ -720,8 +720,7 @@ ProcessSingleton::ProcessSingleton( const base::FilePath& user_data_dir, const NotificationCallback& notification_callback) : notification_callback_(notification_callback), - current_pid_(base::GetCurrentProcId()), - watcher_(new LinuxWatcher(this)) { + current_pid_(base::GetCurrentProcId()) { // The user_data_dir may have not been created yet. base::CreateDirectoryAndGetError(user_data_dir, nullptr); @@ -883,6 +882,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() { } void ProcessSingleton::StartListeningOnSocket() { + watcher_ = new LinuxWatcher(this); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, @@ -1049,7 +1049,7 @@ bool ProcessSingleton::Create() { NOTREACHED() << "listen failed: " << base::safe_strerror(errno); sock_ = sock; - + if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { StartListeningOnSocket(); } else {