| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // On Linux, when the user tries to launch a second copy of chrome, we check | 5 // On Linux, when the user tries to launch a second copy of chrome, we check |
| 6 // for a socket in the user's profile directory. If the socket file is open we | 6 // for a socket in the user's profile directory. If the socket file is open we |
| 7 // send a message to the first chrome browser process with the current | 7 // send a message to the first chrome browser process with the current |
| 8 // directory and second process command line flags. The second process then | 8 // directory and second process command line flags. The second process then |
| 9 // exits. | 9 // exits. |
| 10 // | 10 // |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } | 459 } |
| 460 int rv = SetNonBlocking(connection_socket); | 460 int rv = SetNonBlocking(connection_socket); |
| 461 DCHECK_EQ(0, rv) << "Failed to make non-blocking socket."; | 461 DCHECK_EQ(0, rv) << "Failed to make non-blocking socket."; |
| 462 SocketReader* reader = new SocketReader(this, | 462 SocketReader* reader = new SocketReader(this, |
| 463 ui_message_loop_, | 463 ui_message_loop_, |
| 464 connection_socket); | 464 connection_socket); |
| 465 readers_.insert(reader); | 465 readers_.insert(reader); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void ProcessSingleton::LinuxWatcher::StartListening(int socket) { | 468 void ProcessSingleton::LinuxWatcher::StartListening(int socket) { |
| 469 DCHECK(ChromeThread::GetMessageLoop(ChromeThread::IO) == | 469 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 470 MessageLoop::current()); | |
| 471 // Watch for client connections on this socket. | 470 // Watch for client connections on this socket. |
| 472 MessageLoopForIO* ml = MessageLoopForIO::current(); | 471 MessageLoopForIO* ml = MessageLoopForIO::current(); |
| 473 ml->AddDestructionObserver(this); | 472 ml->AddDestructionObserver(this); |
| 474 ml->WatchFileDescriptor(socket, true, MessageLoopForIO::WATCH_READ, | 473 ml->WatchFileDescriptor(socket, true, MessageLoopForIO::WATCH_READ, |
| 475 &fd_watcher_, this); | 474 &fd_watcher_, this); |
| 476 } | 475 } |
| 477 | 476 |
| 478 void ProcessSingleton::LinuxWatcher::HandleMessage( | 477 void ProcessSingleton::LinuxWatcher::HandleMessage( |
| 479 const std::string& current_dir, const std::vector<std::string>& argv, | 478 const std::string& current_dir, const std::vector<std::string>& argv, |
| 480 SocketReader* reader) { | 479 SocketReader* reader) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 DCHECK(ml); | 764 DCHECK(ml); |
| 766 ml->PostTask(FROM_HERE, NewRunnableMethod( | 765 ml->PostTask(FROM_HERE, NewRunnableMethod( |
| 767 watcher_.get(), | 766 watcher_.get(), |
| 768 &ProcessSingleton::LinuxWatcher::StartListening, | 767 &ProcessSingleton::LinuxWatcher::StartListening, |
| 769 sock)); | 768 sock)); |
| 770 } | 769 } |
| 771 | 770 |
| 772 void ProcessSingleton::Cleanup() { | 771 void ProcessSingleton::Cleanup() { |
| 773 UnlinkPath(lock_path_.value()); | 772 UnlinkPath(lock_path_.value()); |
| 774 } | 773 } |
| OLD | NEW |