Create watcher when message loop is ready

This commit is contained in:
Cheng Zhao 2017-09-20 11:40:49 +09:00
parent 4147fa4629
commit b7119b5756
2 changed files with 4 additions and 8 deletions

View file

@ -407,11 +407,7 @@ bool NotificationCallbackWrapper(
const base::FilePath& cwd) { const base::FilePath& cwd) {
// Make sure the callback is called after app gets ready. // Make sure the callback is called after app gets ready.
if (Browser::Get()->is_ready()) { if (Browser::Get()->is_ready()) {
// We definitely want to call this callback on the UI thread callback.Run(cmd, cwd);
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(base::IgnoreResult(callback), cmd, cwd));
} else { } else {
scoped_refptr<base::SingleThreadTaskRunner> task_runner( scoped_refptr<base::SingleThreadTaskRunner> task_runner(
base::ThreadTaskRunnerHandle::Get()); base::ThreadTaskRunnerHandle::Get());

View file

@ -720,8 +720,7 @@ ProcessSingleton::ProcessSingleton(
const base::FilePath& user_data_dir, const base::FilePath& user_data_dir,
const NotificationCallback& notification_callback) const NotificationCallback& notification_callback)
: notification_callback_(notification_callback), : notification_callback_(notification_callback),
current_pid_(base::GetCurrentProcId()), current_pid_(base::GetCurrentProcId()) {
watcher_(new LinuxWatcher(this)) {
// The user_data_dir may have not been created yet. // The user_data_dir may have not been created yet.
base::CreateDirectoryAndGetError(user_data_dir, nullptr); base::CreateDirectoryAndGetError(user_data_dir, nullptr);
@ -883,6 +882,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() {
} }
void ProcessSingleton::StartListeningOnSocket() { void ProcessSingleton::StartListeningOnSocket() {
watcher_ = new LinuxWatcher(this);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, BrowserThread::IO,
FROM_HERE, FROM_HERE,
@ -1049,7 +1049,7 @@ bool ProcessSingleton::Create() {
NOTREACHED() << "listen failed: " << base::safe_strerror(errno); NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
sock_ = sock; sock_ = sock;
if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
StartListeningOnSocket(); StartListeningOnSocket();
} else { } else {