linux: Delay creating watcher until message loop is ready

This commit is contained in:
Cheng Zhao 2015-10-22 15:57:37 +08:00
parent f01e84a418
commit 230f2760e7

View file

@ -715,8 +715,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)) {
socket_path_ = user_data_dir.Append(kSingletonSocketFilename); socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
lock_path_ = user_data_dir.Append(kSingletonLockFilename); lock_path_ = user_data_dir.Append(kSingletonLockFilename);
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename); cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
@ -1007,6 +1006,7 @@ void ProcessSingleton::Cleanup() {
} }
void ProcessSingleton::StartListening(int sock) { void ProcessSingleton::StartListening(int sock) {
watcher_ = new LinuxWatcher(this);
DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO)); DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, BrowserThread::IO,