| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "content/public/browser/browser_thread.h" | 78 #include "content/public/browser/browser_thread.h" |
| 79 #include "grit/chromium_strings.h" | 79 #include "grit/chromium_strings.h" |
| 80 #include "grit/generated_resources.h" | 80 #include "grit/generated_resources.h" |
| 81 #include "net/base/net_util.h" | 81 #include "net/base/net_util.h" |
| 82 #include "ui/base/l10n/l10n_util.h" | 82 #include "ui/base/l10n/l10n_util.h" |
| 83 | 83 |
| 84 #if defined(OS_LINUX) | 84 #if defined(OS_LINUX) |
| 85 #include "chrome/browser/ui/process_singleton_dialog_linux.h" | 85 #include "chrome/browser/ui/process_singleton_dialog_linux.h" |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 88 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 89 #include "ui/views/linux_ui/linux_ui.h" | 89 #include "ui/views/linux_ui/linux_ui.h" |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 using content::BrowserThread; | 92 using content::BrowserThread; |
| 93 | 93 |
| 94 const int ProcessSingleton::kTimeoutInSeconds; | 94 const int ProcessSingleton::kTimeoutInSeconds; |
| 95 | 95 |
| 96 namespace { | 96 namespace { |
| 97 | 97 |
| 98 static bool g_disable_prompt; | 98 static bool g_disable_prompt; |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 if (!kill_unresponsive || !KillProcessByLockPath()) | 853 if (!kill_unresponsive || !KillProcessByLockPath()) |
| 854 return PROFILE_IN_USE; | 854 return PROFILE_IN_USE; |
| 855 return PROCESS_NONE; | 855 return PROCESS_NONE; |
| 856 } | 856 } |
| 857 | 857 |
| 858 buf[len] = '\0'; | 858 buf[len] = '\0'; |
| 859 if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) { | 859 if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) { |
| 860 // The other process is shutting down, it's safe to start a new process. | 860 // The other process is shutting down, it's safe to start a new process. |
| 861 return PROCESS_NONE; | 861 return PROCESS_NONE; |
| 862 } else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) { | 862 } else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) { |
| 863 #if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS) | 863 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 864 // Likely NULL in unit tests. | 864 // Likely NULL in unit tests. |
| 865 views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 865 views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
| 866 if (linux_ui) | 866 if (linux_ui) |
| 867 linux_ui->NotifyWindowManagerStartupComplete(); | 867 linux_ui->NotifyWindowManagerStartupComplete(); |
| 868 #endif | 868 #endif |
| 869 | 869 |
| 870 // Assume the other process is handling the request. | 870 // Assume the other process is handling the request. |
| 871 return PROCESS_NOTIFIED; | 871 return PROCESS_NOTIFIED; |
| 872 } | 872 } |
| 873 | 873 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void ProcessSingleton::KillProcess(int pid) { | 1046 void ProcessSingleton::KillProcess(int pid) { |
| 1047 // TODO(james.su@gmail.com): Is SIGKILL ok? | 1047 // TODO(james.su@gmail.com): Is SIGKILL ok? |
| 1048 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); | 1048 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); |
| 1049 // ESRCH = No Such Process (can happen if the other process is already in | 1049 // ESRCH = No Such Process (can happen if the other process is already in |
| 1050 // progress of shutting down and finishes before we try to kill it). | 1050 // progress of shutting down and finishes before we try to kill it). |
| 1051 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " | 1051 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " |
| 1052 << safe_strerror(errno); | 1052 << safe_strerror(errno); |
| 1053 } | 1053 } |
| OLD | NEW |