base::FilePath user_data_dir_;
ShouldKillRemoteProcessCallback should_kill_remote_process_callback_;
#elif defined(OS_POSIX) && !defined(OS_ANDROID)
+ // Start listening to the socket.
+ void StartListening(int sock);
+
// Return true if the given pid is one of our child processes.
// Assumes that the current pid is the root of all pids of the current
// instance.
PathService::Get(base::FILE_EXE, &exec_path);
return (!other_chrome_path.empty() &&
- other_chrome_path.BaseName() ==
- exec_path.BaseName());
+ other_chrome_path.BaseName() == exec_path.BaseName());
}
// A helper class to hold onto a socket.
if (listen(sock, 5) < 0)
NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
- DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
- BrowserThread::PostTask(
- BrowserThread::IO,
+ // In Electron the ProcessSingleton is created earlier than the IO
+ // thread gets created, so we have to postpone the call until message
+ // loop is up an running.
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner(
+ base::ThreadTaskRunnerHandle::Get());
+ task_runner->PostTask(
FROM_HERE,
- base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
- watcher_.get(),
- sock));
+ base::Bind(&ProcessSingleton::StartListening,
+ base::Unretained(this), sock));
return true;
}
UnlinkPath(lock_path_);
}
+void ProcessSingleton::StartListening(int sock) {
+ DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
+ watcher_.get(),
+ sock));
+}
+
bool ProcessSingleton::IsSameChromeInstance(pid_t pid) {
pid_t cur_pid = current_pid_;
while (pid != cur_pid) {