OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
12 #include <windows.h> | 12 #include <windows.h> |
13 #endif | 13 #endif // defined(OS_WIN) |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #if defined(USE_X11) || defined(OS_MACOSX) | |
17 #include "base/file_path.h" | |
18 #endif | |
19 #include "base/logging.h" | 16 #include "base/logging.h" |
20 #include "base/non_thread_safe.h" | 17 #include "base/non_thread_safe.h" |
21 #include "base/ref_counted.h" | 18 #include "base/ref_counted.h" |
22 #include "gfx/native_widget_types.h" | 19 #include "gfx/native_widget_types.h" |
20 | |
21 #if defined(OS_POSIX) | |
22 #include "base/file_path.h" | |
23 #endif // defined(OS_POSIX) | |
24 | |
23 #if defined(USE_X11) | 25 #if defined(USE_X11) |
24 #include "base/scoped_temp_dir.h" | 26 #include "base/scoped_temp_dir.h" |
25 #endif | 27 #endif // defined(USE_X11) |
26 | 28 |
27 class CommandLine; | 29 class CommandLine; |
28 class FilePath; | 30 class FilePath; |
29 | 31 |
30 // ProcessSingleton ---------------------------------------------------------- | 32 // ProcessSingleton ---------------------------------------------------------- |
31 // | 33 // |
32 // This class allows different browser processes to communicate with | 34 // This class allows different browser processes to communicate with |
33 // each other. It is named according to the user data directory, so | 35 // each other. It is named according to the user data directory, so |
34 // we can be sure that no more than one copy of the application can be | 36 // we can be sure that no more than one copy of the application can be |
35 // running at once with a given data directory. | 37 // running at once with a given data directory. |
(...skipping 22 matching lines...) Expand all Loading... | |
58 // TODO(brettw): this will not handle all cases. If two process start up too | 60 // TODO(brettw): this will not handle all cases. If two process start up too |
59 // close to each other, the Create() might not yet have happened for the | 61 // close to each other, the Create() might not yet have happened for the |
60 // first one, so this function won't find it. | 62 // first one, so this function won't find it. |
61 NotifyResult NotifyOtherProcess(); | 63 NotifyResult NotifyOtherProcess(); |
62 | 64 |
63 // Notify another process, if available. Otherwise sets ourselves as the | 65 // Notify another process, if available. Otherwise sets ourselves as the |
64 // singleton instance. Returns PROCESS_NONE if we became the singleton | 66 // singleton instance. Returns PROCESS_NONE if we became the singleton |
65 // instance. | 67 // instance. |
66 NotifyResult NotifyOtherProcessOrCreate(); | 68 NotifyResult NotifyOtherProcessOrCreate(); |
67 | 69 |
68 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 70 #if defined(USE_X11) |
evanm
2010/12/15 02:12:53
Is this really an X11-specific block of code?
Cons
Lei Zhang
2010/12/21 05:14:43
Changed this to OS_LINUX since it's only implement
| |
69 // Exposed for testing. We use a timeout on Linux, and in tests we want | 71 // Exposed for testing. We use a timeout on Linux, and in tests we want |
70 // this timeout to be short. | 72 // this timeout to be short. |
71 NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line, | 73 NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line, |
72 int timeout_seconds, | 74 int timeout_seconds, |
73 bool kill_unresponsive); | 75 bool kill_unresponsive); |
74 NotifyResult NotifyOtherProcessWithTimeoutOrCreate( | 76 NotifyResult NotifyOtherProcessWithTimeoutOrCreate( |
75 const CommandLine& command_line, | 77 const CommandLine& command_line, |
76 int timeout_seconds); | 78 int timeout_seconds); |
77 #endif | 79 #endif // defined(USE_X11) |
78 | 80 |
79 // Sets ourself up as the singleton instance. Returns true on success. If | 81 // Sets ourself up as the singleton instance. Returns true on success. If |
80 // false is returned, we are not the singleton instance and the caller must | 82 // false is returned, we are not the singleton instance and the caller must |
81 // exit. | 83 // exit. |
82 bool Create(); | 84 bool Create(); |
83 | 85 |
84 // Clear any lock state during shutdown. | 86 // Clear any lock state during shutdown. |
85 void Cleanup(); | 87 void Cleanup(); |
86 | 88 |
87 // Blocks the dispatch of CopyData messages. foreground_window refers | 89 // Blocks the dispatch of CopyData messages. foreground_window refers |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 // File descriptor associated with the lockfile, valid between | 161 // File descriptor associated with the lockfile, valid between |
160 // |Create()| and |Cleanup()|. Two instances cannot have a lock on | 162 // |Create()| and |Cleanup()|. Two instances cannot have a lock on |
161 // the same file at the same time. | 163 // the same file at the same time. |
162 int lock_fd_; | 164 int lock_fd_; |
163 #endif | 165 #endif |
164 | 166 |
165 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 167 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
166 }; | 168 }; |
167 | 169 |
168 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 170 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
OLD | NEW |