| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // each other. It is named according to the user data directory, so | 42 // each other. It is named according to the user data directory, so |
| 43 // we can be sure that no more than one copy of the application can be | 43 // we can be sure that no more than one copy of the application can be |
| 44 // running at once with a given data directory. | 44 // running at once with a given data directory. |
| 45 // | 45 // |
| 46 // Implementation notes: | 46 // Implementation notes: |
| 47 // - the Windows implementation uses an invisible global message window; | 47 // - the Windows implementation uses an invisible global message window; |
| 48 // - the Linux implementation uses a Unix domain socket in the user data dir. | 48 // - the Linux implementation uses a Unix domain socket in the user data dir. |
| 49 | 49 |
| 50 class ProcessSingleton : public base::NonThreadSafe { | 50 class ProcessSingleton : public base::NonThreadSafe { |
| 51 public: | 51 public: |
| 52 // Used to send the reason of remote hang process termination as histogram. |
| 53 enum RemoteHungProcessTerminateReason { |
| 54 #if defined(OS_WIN) |
| 55 USER_ACCEPTED_TERMINATION = 1, |
| 56 NO_VISIBLE_WINDOW_FOUND = 2, |
| 57 #elif defined(OS_POSIX) |
| 58 NOTIFY_ATTEMPTS_EXCEEDED = 3, |
| 59 SOCKET_WRITE_FAILED = 4, |
| 60 SOCKET_READ_FAILED = 5, |
| 61 #endif |
| 62 REMOTE_HUNG_PROCESS_TERMINATE_REASON_COUNT |
| 63 }; |
| 64 |
| 65 // Used to send the result of interaction with remote process as histograms in |
| 66 // case when remote process influences on start. |
| 67 enum RemoteProcessInteractionResult { |
| 68 TERMINATE_SUCCEEDED = 0, |
| 69 TERMINATE_FAILED = 1, |
| 70 REMOTE_PROCESS_NOT_FOUND = 2, |
| 71 #if defined(OS_WIN) |
| 72 TERMINATE_WAIT_TIMEOUT = 3, |
| 73 RUNNING_PROCESS_NOTIFY_ERROR = 4, |
| 74 #elif defined(OS_POSIX) |
| 75 TERMINATE_NOT_ENOUGH_PERMISSIONS = 5, |
| 76 REMOTE_PROCESS_SHUTTING_DOWN = 6, |
| 77 PROFILE_UNLOCKED = 7, |
| 78 PROFILE_UNLOCKED_BEFORE_KILL = 8, |
| 79 SAME_BROWSER_INSTANCE = 9, |
| 80 SAME_BROWSER_INSTANCE_BEFORE_KILL = 10, |
| 81 FAILED_TO_EXTRACT_PID = 11, |
| 82 INVALID_LOCK_FILE = 12, |
| 83 ORPHANED_LOCK_FILE = 13, |
| 84 #endif |
| 85 REMOTE_PROCESS_INTERACTION_RESULT_COUNT |
| 86 }; |
| 87 |
| 52 // Logged as histograms, do not modify these values. | 88 // Logged as histograms, do not modify these values. |
| 53 enum NotifyResult { | 89 enum NotifyResult { |
| 54 PROCESS_NONE = 0, | 90 PROCESS_NONE = 0, |
| 55 PROCESS_NOTIFIED = 1, | 91 PROCESS_NOTIFIED = 1, |
| 56 PROFILE_IN_USE = 2, | 92 PROFILE_IN_USE = 2, |
| 57 LOCK_ERROR = 3, | 93 LOCK_ERROR = 3, |
| 58 LAST_VALUE = LOCK_ERROR | 94 LAST_VALUE = LOCK_ERROR |
| 59 }; | 95 }; |
| 60 | 96 |
| 61 static constexpr int kNumNotifyResults = LAST_VALUE + 1; | 97 static constexpr int kNumNotifyResults = LAST_VALUE + 1; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 88 // NOTE: Most callers should generally prefer NotifyOtherProcessOrCreate() to | 124 // NOTE: Most callers should generally prefer NotifyOtherProcessOrCreate() to |
| 89 // this method, only callers for whom failure is preferred to notifying | 125 // this method, only callers for whom failure is preferred to notifying |
| 90 // another process should call this directly. | 126 // another process should call this directly. |
| 91 bool Create(); | 127 bool Create(); |
| 92 | 128 |
| 93 // Clear any lock state during shutdown. | 129 // Clear any lock state during shutdown. |
| 94 void Cleanup(); | 130 void Cleanup(); |
| 95 | 131 |
| 96 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 132 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 97 static void DisablePromptForTesting(); | 133 static void DisablePromptForTesting(); |
| 134 static void SkipIsChromeProcessCheckForTesting(bool skip); |
| 98 #endif | 135 #endif |
| 99 #if defined(OS_WIN) | 136 #if defined(OS_WIN) |
| 100 // Called to query whether to kill a hung browser process that has visible | 137 // Called to query whether to kill a hung browser process that has visible |
| 101 // windows. Return true to allow killing the hung process. | 138 // windows. Return true to allow killing the hung process. |
| 102 using ShouldKillRemoteProcessCallback = base::Callback<bool()>; | 139 using ShouldKillRemoteProcessCallback = base::Callback<bool()>; |
| 103 void OverrideShouldKillRemoteProcessCallbackForTesting( | 140 void OverrideShouldKillRemoteProcessCallbackForTesting( |
| 104 const ShouldKillRemoteProcessCallback& display_dialog_callback); | 141 const ShouldKillRemoteProcessCallback& display_dialog_callback); |
| 105 #endif | 142 #endif |
| 106 | 143 |
| 107 protected: | 144 protected: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Helper class for linux specific messages. LinuxWatcher is ref counted | 215 // Helper class for linux specific messages. LinuxWatcher is ref counted |
| 179 // because it posts messages between threads. | 216 // because it posts messages between threads. |
| 180 class LinuxWatcher; | 217 class LinuxWatcher; |
| 181 scoped_refptr<LinuxWatcher> watcher_; | 218 scoped_refptr<LinuxWatcher> watcher_; |
| 182 #endif | 219 #endif |
| 183 | 220 |
| 184 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 221 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 185 }; | 222 }; |
| 186 | 223 |
| 187 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 224 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |