| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 308 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 309 switches::kNoProcessSingletonDialog)) | 309 switches::kNoProcessSingletonDialog)) |
| 310 ProcessSingletonDialog::ShowAndRun(WideToUTF8(error)); | 310 ProcessSingletonDialog::ShowAndRun(WideToUTF8(error)); |
| 311 #endif | 311 #endif |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool IsChromeProcess(pid_t pid) { | 314 bool IsChromeProcess(pid_t pid) { |
| 315 FilePath other_chrome_path(base::GetProcessExecutablePath(pid)); | 315 FilePath other_chrome_path(base::GetProcessExecutablePath(pid)); |
| 316 return (!other_chrome_path.empty() && | 316 return (!other_chrome_path.empty() && |
| 317 other_chrome_path.BaseName() == | 317 other_chrome_path.BaseName() == |
| 318 FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName)); | 318 FilePath(chrome::kBrowserProcessExecutableName)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 // Return true if the given pid is one of our child processes. | 321 // Return true if the given pid is one of our child processes. |
| 322 // Assumes that the current pid is the root of all pids of the current instance. | 322 // Assumes that the current pid is the root of all pids of the current instance. |
| 323 bool IsSameChromeInstance(pid_t pid) { | 323 bool IsSameChromeInstance(pid_t pid) { |
| 324 pid_t cur_pid = base::GetCurrentProcId(); | 324 pid_t cur_pid = base::GetCurrentProcId(); |
| 325 while (pid != cur_pid) { | 325 while (pid != cur_pid) { |
| 326 pid = base::GetParentProcessId(pid); | 326 pid = base::GetParentProcessId(pid); |
| 327 if (pid < 0) | 327 if (pid < 0) |
| 328 return false; | 328 return false; |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 sock)); | 976 sock)); |
| 977 | 977 |
| 978 return true; | 978 return true; |
| 979 } | 979 } |
| 980 | 980 |
| 981 void ProcessSingleton::Cleanup() { | 981 void ProcessSingleton::Cleanup() { |
| 982 UnlinkPath(socket_path_); | 982 UnlinkPath(socket_path_); |
| 983 UnlinkPath(cookie_path_); | 983 UnlinkPath(cookie_path_); |
| 984 UnlinkPath(lock_path_); | 984 UnlinkPath(lock_path_); |
| 985 } | 985 } |
| OLD | NEW |