OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 SocketReader(ProcessSingleton::LinuxWatcher* parent, | 463 SocketReader(ProcessSingleton::LinuxWatcher* parent, |
464 MessageLoop* ui_message_loop, | 464 MessageLoop* ui_message_loop, |
465 int fd) | 465 int fd) |
466 : parent_(parent), | 466 : parent_(parent), |
467 ui_message_loop_(ui_message_loop), | 467 ui_message_loop_(ui_message_loop), |
468 fd_(fd), | 468 fd_(fd), |
469 bytes_read_(0) { | 469 bytes_read_(0) { |
470 // Wait for reads. | 470 // Wait for reads. |
471 MessageLoopForIO::current()->WatchFileDescriptor( | 471 MessageLoopForIO::current()->WatchFileDescriptor( |
472 fd, true, MessageLoopForIO::WATCH_READ, &fd_reader_, this); | 472 fd, true, MessageLoopForIO::WATCH_READ, &fd_reader_, this); |
473 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds), | 473 timer_.Start(base::TimeDelta::FromSeconds(kTimeoutInSeconds), |
474 this, &SocketReader::OnTimerExpiry); | 474 this, &SocketReader::OnTimerExpiry); |
475 } | 475 } |
476 | 476 |
477 virtual ~SocketReader() { | 477 virtual ~SocketReader() { |
478 CloseSocket(fd_); | 478 CloseSocket(fd_); |
479 } | 479 } |
480 | 480 |
481 // MessageLoopForIO::Watcher impl. | 481 // MessageLoopForIO::Watcher impl. |
482 virtual void OnFileCanReadWithoutBlocking(int fd); | 482 virtual void OnFileCanReadWithoutBlocking(int fd); |
483 virtual void OnFileCanWriteWithoutBlocking(int fd) { | 483 virtual void OnFileCanWriteWithoutBlocking(int fd) { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 sock)); | 981 sock)); |
982 | 982 |
983 return true; | 983 return true; |
984 } | 984 } |
985 | 985 |
986 void ProcessSingleton::Cleanup() { | 986 void ProcessSingleton::Cleanup() { |
987 UnlinkPath(socket_path_); | 987 UnlinkPath(socket_path_); |
988 UnlinkPath(cookie_path_); | 988 UnlinkPath(cookie_path_); |
989 UnlinkPath(lock_path_); | 989 UnlinkPath(lock_path_); |
990 } | 990 } |
OLD | NEW |