| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 22 matching lines...) Expand all Loading... |
| 33 public: | 33 public: |
| 34 enum NotifyResult { | 34 enum NotifyResult { |
| 35 PROCESS_NONE, | 35 PROCESS_NONE, |
| 36 PROCESS_NOTIFIED, | 36 PROCESS_NOTIFIED, |
| 37 PROFILE_IN_USE, | 37 PROFILE_IN_USE, |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 explicit ProcessSingleton(const FilePath& user_data_dir); | 40 explicit ProcessSingleton(const FilePath& user_data_dir); |
| 41 ~ProcessSingleton(); | 41 ~ProcessSingleton(); |
| 42 | 42 |
| 43 // Notify another process, if available. |
| 43 // Returns true if another process was found and notified, false if we | 44 // Returns true if another process was found and notified, false if we |
| 44 // should continue with this process. | 45 // should continue with this process. |
| 45 // Windows code roughly based on Mozilla. | 46 // Windows code roughly based on Mozilla. |
| 46 // | 47 // |
| 47 // TODO(brettw): this will not handle all cases. If two process start up too | 48 // TODO(brettw): this will not handle all cases. If two process start up too |
| 48 // close to each other, the Create() might not yet have happened for the | 49 // close to each other, the Create() might not yet have happened for the |
| 49 // first one, so this function won't find it. | 50 // first one, so this function won't find it. |
| 50 NotifyResult NotifyOtherProcess(); | 51 NotifyResult NotifyOtherProcess(); |
| 51 | 52 |
| 53 #if defined(OS_LINUX) |
| 54 // Exposed for testing. We use a timeout on Linux, and in tests we want |
| 55 // this timeout to be short. |
| 56 NotifyResult NotifyOtherProcessWithTimeout(int timeout_seconds); |
| 57 #endif |
| 58 |
| 52 // Sets ourself up as the singleton instance. | 59 // Sets ourself up as the singleton instance. |
| 53 void Create(); | 60 void Create(); |
| 54 | 61 |
| 55 // Clear any lock state during shutdown. | 62 // Clear any lock state during shutdown. |
| 56 void Cleanup(); | 63 void Cleanup(); |
| 57 | 64 |
| 58 // Blocks the dispatch of CopyData messages. foreground_window refers | 65 // Blocks the dispatch of CopyData messages. foreground_window refers |
| 59 // to the window that should be set to the foreground if a CopyData message | 66 // to the window that should be set to the foreground if a CopyData message |
| 60 // is received while the ProcessSingleton is locked. | 67 // is received while the ProcessSingleton is locked. |
| 61 void Lock(gfx::NativeWindow foreground_window) { | 68 void Lock(gfx::NativeWindow foreground_window) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Helper class for linux specific messages. LinuxWatcher is ref counted | 123 // Helper class for linux specific messages. LinuxWatcher is ref counted |
| 117 // because it posts messages between threads. | 124 // because it posts messages between threads. |
| 118 class LinuxWatcher; | 125 class LinuxWatcher; |
| 119 scoped_refptr<LinuxWatcher> watcher_; | 126 scoped_refptr<LinuxWatcher> watcher_; |
| 120 #endif | 127 #endif |
| 121 | 128 |
| 122 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 129 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 123 }; | 130 }; |
| 124 | 131 |
| 125 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 132 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |