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 "base/sequence_checker.h" |
8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
9 | 10 |
10 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
11 #include <windows.h> | 12 #include <windows.h> |
12 #endif // defined(OS_WIN) | 13 #endif // defined(OS_WIN) |
13 | 14 |
14 #include <set> | 15 #include <set> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "base/callback.h" | 18 #include "base/callback.h" |
18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
19 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
20 #include "base/logging.h" | 21 #include "base/logging.h" |
21 #include "base/macros.h" | 22 #include "base/macros.h" |
22 #include "base/memory/ref_counted.h" | 23 #include "base/memory/ref_counted.h" |
23 #include "base/process/process.h" | 24 #include "base/process/process.h" |
24 #include "base/threading/non_thread_safe.h" | |
25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
26 | 26 |
27 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 27 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
28 #include "base/files/scoped_temp_dir.h" | 28 #include "base/files/scoped_temp_dir.h" |
29 #endif | 29 #endif |
30 | 30 |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
32 #include "base/win/message_window.h" | 32 #include "base/win/message_window.h" |
33 #endif // defined(OS_WIN) | 33 #endif // defined(OS_WIN) |
34 | 34 |
35 namespace base { | 35 namespace base { |
36 class CommandLine; | 36 class CommandLine; |
37 } | 37 } |
38 | 38 |
39 // ProcessSingleton ---------------------------------------------------------- | 39 // ProcessSingleton ---------------------------------------------------------- |
40 // | 40 // |
41 // This class allows different browser processes to communicate with | 41 // This class allows different browser processes to communicate with |
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 { |
51 public: | 51 public: |
52 // Used to send the reason of remote hang process termination as histogram. | 52 // Used to send the reason of remote hang process termination as histogram. |
53 enum RemoteHungProcessTerminateReason { | 53 enum RemoteHungProcessTerminateReason { |
54 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
55 USER_ACCEPTED_TERMINATION = 1, | 55 USER_ACCEPTED_TERMINATION = 1, |
56 NO_VISIBLE_WINDOW_FOUND = 2, | 56 NO_VISIBLE_WINDOW_FOUND = 2, |
57 #elif defined(OS_POSIX) | 57 #elif defined(OS_POSIX) |
58 NOTIFY_ATTEMPTS_EXCEEDED = 3, | 58 NOTIFY_ATTEMPTS_EXCEEDED = 3, |
59 SOCKET_WRITE_FAILED = 4, | 59 SOCKET_WRITE_FAILED = 4, |
60 SOCKET_READ_FAILED = 5, | 60 SOCKET_READ_FAILED = 5, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 // Temporary directory to hold the socket. | 212 // Temporary directory to hold the socket. |
213 base::ScopedTempDir socket_dir_; | 213 base::ScopedTempDir socket_dir_; |
214 | 214 |
215 // Helper class for linux specific messages. LinuxWatcher is ref counted | 215 // Helper class for linux specific messages. LinuxWatcher is ref counted |
216 // because it posts messages between threads. | 216 // because it posts messages between threads. |
217 class LinuxWatcher; | 217 class LinuxWatcher; |
218 scoped_refptr<LinuxWatcher> watcher_; | 218 scoped_refptr<LinuxWatcher> watcher_; |
219 #endif | 219 #endif |
220 | 220 |
| 221 SEQUENCE_CHECKER(sequence_checker_); |
| 222 |
221 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 223 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
222 }; | 224 }; |
223 | 225 |
224 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 226 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
OLD | NEW |