OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ | 5 #ifndef CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |
6 #define CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ | 6 #define CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |
7 | 7 |
8 #include "service_process_util.h" | 8 #include "service_process_util.h" |
9 | 9 |
10 #include <signal.h> | 10 #include <signal.h> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/message_pump_libevent.h" | 14 #include "base/message_pump_libevent.h" |
15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
16 | 16 |
17 #if defined(OS_LINUX) | 17 #if defined(OS_LINUX) |
18 #include "chrome/common/multi_process_lock.h" | 18 #include "chrome/common/multi_process_lock.h" |
19 MultiProcessLock* TakeServiceRunningLock(bool waiting); | 19 MultiProcessLock* TakeServiceRunningLock(bool waiting); |
20 #endif // OS_LINUX | 20 #endif // OS_LINUX |
21 | 21 |
22 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
23 #include "base/mac/scoped_cftyperef.h" | 23 #include "base/mac/scoped_cftyperef.h" |
| 24 #include "base/message_loop_proxy.h" |
| 25 #include "content/common/file_path_watcher/file_path_watcher.h" |
| 26 |
24 class CommandLine; | 27 class CommandLine; |
25 CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, | 28 CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, |
26 bool for_auto_launch); | 29 bool for_auto_launch); |
27 #endif // OS_MACOSX | 30 #endif // OS_MACOSX |
28 | 31 |
29 // Watches for |kShutDownMessage| to be written to the file descriptor it is | 32 // Watches for |kShutDownMessage| to be written to the file descriptor it is |
30 // watching. When it reads |kShutDownMessage|, it performs |shutdown_task_|. | 33 // watching. When it reads |kShutDownMessage|, it performs |shutdown_task_|. |
31 // Used here to monitor the socket listening to g_signal_socket. | 34 // Used here to monitor the socket listening to g_signal_socket. |
32 class ServiceProcessShutdownMonitor | 35 class ServiceProcessShutdownMonitor |
33 : public base::MessagePumpLibevent::Watcher { | 36 : public base::MessagePumpLibevent::Watcher { |
(...skipping 20 matching lines...) Expand all Loading... |
54 | 57 |
55 // WatchFileDescriptor needs to be set up by the thread that is going | 58 // WatchFileDescriptor needs to be set up by the thread that is going |
56 // to be monitoring it. | 59 // to be monitoring it. |
57 void SignalReady(); | 60 void SignalReady(); |
58 | 61 |
59 | 62 |
60 // TODO(jhawkins): Either make this a class or rename these public member | 63 // TODO(jhawkins): Either make this a class or rename these public member |
61 // variables to remove the trailing underscore. | 64 // variables to remove the trailing underscore. |
62 | 65 |
63 #if defined(OS_MACOSX) | 66 #if defined(OS_MACOSX) |
| 67 void WatchExecutable(); |
| 68 |
64 base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; | 69 base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; |
| 70 FilePathWatcher executable_watcher_; |
| 71 scoped_refptr<base::MessageLoopProxy> ui_message_loop_; |
| 72 ServiceProcessState* state_; |
65 #endif // OS_MACOSX | 73 #endif // OS_MACOSX |
66 #if defined(OS_LINUX) | 74 #if defined(OS_LINUX) |
67 scoped_ptr<MultiProcessLock> initializing_lock_; | 75 scoped_ptr<MultiProcessLock> initializing_lock_; |
68 scoped_ptr<MultiProcessLock> running_lock_; | 76 scoped_ptr<MultiProcessLock> running_lock_; |
69 #endif // OS_LINUX | 77 #endif // OS_LINUX |
70 scoped_ptr<ServiceProcessShutdownMonitor> shut_down_monitor_; | 78 scoped_ptr<ServiceProcessShutdownMonitor> shut_down_monitor_; |
71 base::MessagePumpLibevent::FileDescriptorWatcher watcher_; | 79 base::MessagePumpLibevent::FileDescriptorWatcher watcher_; |
72 int sockets_[2]; | 80 int sockets_[2]; |
73 struct sigaction old_action_; | 81 struct sigaction old_action_; |
74 bool set_action_; | 82 bool set_action_; |
75 | 83 |
76 protected: | 84 protected: |
77 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; | 85 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; |
78 virtual ~StateData(); | 86 virtual ~StateData(); |
79 }; | 87 }; |
80 | 88 |
81 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ | 89 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |
OLD | NEW |