| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // The file descriptor we're reading. | 509 // The file descriptor we're reading. |
| 510 const int fd_; | 510 const int fd_; |
| 511 | 511 |
| 512 // Store the message in this buffer. | 512 // Store the message in this buffer. |
| 513 char buf_[kMaxMessageLength]; | 513 char buf_[kMaxMessageLength]; |
| 514 | 514 |
| 515 // Tracks the number of bytes we've read in case we're getting partial | 515 // Tracks the number of bytes we've read in case we're getting partial |
| 516 // reads. | 516 // reads. |
| 517 size_t bytes_read_; | 517 size_t bytes_read_; |
| 518 | 518 |
| 519 base::OneShotTimer<SocketReader> timer_; | 519 base::OneShotTimer timer_; |
| 520 | 520 |
| 521 DISALLOW_COPY_AND_ASSIGN(SocketReader); | 521 DISALLOW_COPY_AND_ASSIGN(SocketReader); |
| 522 }; | 522 }; |
| 523 | 523 |
| 524 // We expect to only be constructed on the UI thread. | 524 // We expect to only be constructed on the UI thread. |
| 525 explicit LinuxWatcher(ProcessSingleton* parent) | 525 explicit LinuxWatcher(ProcessSingleton* parent) |
| 526 : ui_message_loop_(base::MessageLoop::current()), | 526 : ui_message_loop_(base::MessageLoop::current()), |
| 527 parent_(parent) { | 527 parent_(parent) { |
| 528 } | 528 } |
| 529 | 529 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 void ProcessSingleton::KillProcess(int pid) { | 1055 void ProcessSingleton::KillProcess(int pid) { |
| 1056 // TODO(james.su@gmail.com): Is SIGKILL ok? | 1056 // TODO(james.su@gmail.com): Is SIGKILL ok? |
| 1057 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); | 1057 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); |
| 1058 // ESRCH = No Such Process (can happen if the other process is already in | 1058 // ESRCH = No Such Process (can happen if the other process is already in |
| 1059 // progress of shutting down and finishes before we try to kill it). | 1059 // progress of shutting down and finishes before we try to kill it). |
| 1060 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " | 1060 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " |
| 1061 << base::safe_strerror(errno); | 1061 << base::safe_strerror(errno); |
| 1062 } | 1062 } |
| OLD | NEW |