| 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 // Logged as histograms, do not modify these values. |
| 52 enum NotifyResult { | 53 enum NotifyResult { |
| 53 PROCESS_NONE, | 54 PROCESS_NONE = 0, |
| 54 PROCESS_NOTIFIED, | 55 PROCESS_NOTIFIED = 1, |
| 55 PROFILE_IN_USE, | 56 PROFILE_IN_USE = 2, |
| 56 LOCK_ERROR, | 57 LOCK_ERROR = 3, |
| 58 LAST_VALUE = LOCK_ERROR |
| 57 }; | 59 }; |
| 58 | 60 |
| 61 static constexpr int kNumNotifyResults = LAST_VALUE + 1; |
| 62 |
| 59 // Implement this callback to handle notifications from other processes. The | 63 // Implement this callback to handle notifications from other processes. The |
| 60 // callback will receive the command line and directory with which the other | 64 // callback will receive the command line and directory with which the other |
| 61 // Chrome process was launched. Return true if the command line will be | 65 // Chrome process was launched. Return true if the command line will be |
| 62 // handled within the current browser instance or false if the remote process | 66 // handled within the current browser instance or false if the remote process |
| 63 // should handle it (i.e., because the current process is shutting down). | 67 // should handle it (i.e., because the current process is shutting down). |
| 64 using NotificationCallback = | 68 using NotificationCallback = |
| 65 base::Callback<bool(const base::CommandLine& command_line, | 69 base::Callback<bool(const base::CommandLine& command_line, |
| 66 const base::FilePath& current_directory)>; | 70 const base::FilePath& current_directory)>; |
| 67 | 71 |
| 68 ProcessSingleton(const base::FilePath& user_data_dir, | 72 ProcessSingleton(const base::FilePath& user_data_dir, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Helper class for linux specific messages. LinuxWatcher is ref counted | 178 // Helper class for linux specific messages. LinuxWatcher is ref counted |
| 175 // because it posts messages between threads. | 179 // because it posts messages between threads. |
| 176 class LinuxWatcher; | 180 class LinuxWatcher; |
| 177 scoped_refptr<LinuxWatcher> watcher_; | 181 scoped_refptr<LinuxWatcher> watcher_; |
| 178 #endif | 182 #endif |
| 179 | 183 |
| 180 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 184 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 181 }; | 185 }; |
| 182 | 186 |
| 183 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 187 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |