| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ | 5 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| 6 #define CHROME_BROWSER_PROCESS_SINGLETON_H_ | 6 #define CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // this method, only callers for whom failure is preferred to notifying | 125 // this method, only callers for whom failure is preferred to notifying |
| 126 // another process should call this directly. | 126 // another process should call this directly. |
| 127 bool Create(); | 127 bool Create(); |
| 128 | 128 |
| 129 // Clear any lock state during shutdown. | 129 // Clear any lock state during shutdown. |
| 130 void Cleanup(); | 130 void Cleanup(); |
| 131 | 131 |
| 132 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 132 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 133 static void DisablePromptForTesting(); | 133 static void DisablePromptForTesting(); |
| 134 static void SkipIsChromeProcessCheckForTesting(bool skip); | 134 static void SkipIsChromeProcessCheckForTesting(bool skip); |
| 135 static void SetUserOptedUnlockInUseProfileForTesting(bool set_unlock); |
| 135 #endif | 136 #endif |
| 136 #if defined(OS_WIN) | 137 #if defined(OS_WIN) |
| 137 // Called to query whether to kill a hung browser process that has visible | 138 // Called to query whether to kill a hung browser process that has visible |
| 138 // windows. Return true to allow killing the hung process. | 139 // windows. Return true to allow killing the hung process. |
| 139 using ShouldKillRemoteProcessCallback = base::Callback<bool()>; | 140 using ShouldKillRemoteProcessCallback = base::Callback<bool()>; |
| 140 void OverrideShouldKillRemoteProcessCallbackForTesting( | 141 void OverrideShouldKillRemoteProcessCallbackForTesting( |
| 141 const ShouldKillRemoteProcessCallback& display_dialog_callback); | 142 const ShouldKillRemoteProcessCallback& display_dialog_callback); |
| 142 #endif | 143 #endif |
| 143 | 144 |
| 144 protected: | 145 protected: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 HANDLE lock_file_; | 178 HANDLE lock_file_; |
| 178 base::FilePath user_data_dir_; | 179 base::FilePath user_data_dir_; |
| 179 ShouldKillRemoteProcessCallback should_kill_remote_process_callback_; | 180 ShouldKillRemoteProcessCallback should_kill_remote_process_callback_; |
| 180 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 181 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
| 181 // Return true if the given pid is one of our child processes. | 182 // Return true if the given pid is one of our child processes. |
| 182 // Assumes that the current pid is the root of all pids of the current | 183 // Assumes that the current pid is the root of all pids of the current |
| 183 // instance. | 184 // instance. |
| 184 bool IsSameChromeInstance(pid_t pid); | 185 bool IsSameChromeInstance(pid_t pid); |
| 185 | 186 |
| 186 // Extract the process's pid from a symbol link path and if it is on | 187 // Extract the process's pid from a symbol link path and if it is on |
| 187 // the same host, kill the process, unlink the lock file and return true. | 188 // the same host or is_connected_to_socket is true, kill the process, unlink |
| 189 // the lock file and return true. |
| 188 // If the process is part of the same chrome instance, unlink the lock file | 190 // If the process is part of the same chrome instance, unlink the lock file |
| 189 // and return true without killing it. | 191 // and return true without killing it. |
| 190 // If the process is on a different host, return false. | 192 // If the process is on a different host and is_connected_to_socket is false, |
| 191 bool KillProcessByLockPath(); | 193 // display profile in use error dialog (on Linux). If user opted to unlock |
| 194 // profile (on Mac OS X by default), unlink the lock file and return true. |
| 195 // Otherwise return false. |
| 196 bool KillProcessByLockPath(bool is_connected_to_socket); |
| 192 | 197 |
| 193 // Default function to kill a process, overridable by tests. | 198 // Default function to kill a process, overridable by tests. |
| 194 void KillProcess(int pid); | 199 void KillProcess(int pid); |
| 195 | 200 |
| 196 // Allow overriding for tests. | 201 // Allow overriding for tests. |
| 197 base::ProcessId current_pid_; | 202 base::ProcessId current_pid_; |
| 198 | 203 |
| 199 // Function to call when the other process is hung and needs to be killed. | 204 // Function to call when the other process is hung and needs to be killed. |
| 200 // Allows overriding for tests. | 205 // Allows overriding for tests. |
| 201 base::Callback<void(int)> kill_callback_; | 206 base::Callback<void(int)> kill_callback_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 215 // Helper class for linux specific messages. LinuxWatcher is ref counted | 220 // Helper class for linux specific messages. LinuxWatcher is ref counted |
| 216 // because it posts messages between threads. | 221 // because it posts messages between threads. |
| 217 class LinuxWatcher; | 222 class LinuxWatcher; |
| 218 scoped_refptr<LinuxWatcher> watcher_; | 223 scoped_refptr<LinuxWatcher> watcher_; |
| 219 #endif | 224 #endif |
| 220 | 225 |
| 221 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 226 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 222 }; | 227 }; |
| 223 | 228 |
| 224 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 229 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |