| 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 "content/common/file_path_watcher/file_path_watcher.h" |
| 25 |
| 24 class CommandLine; | 26 class CommandLine; |
| 25 CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, | 27 CFDictionaryRef CreateServiceProcessLaunchdPlist(CommandLine* cmd_line, |
| 26 bool for_auto_launch); | 28 bool for_auto_launch); |
| 27 #endif // OS_MACOSX | 29 #endif // OS_MACOSX |
| 28 | 30 |
| 29 // Watches for |kShutDownMessage| to be written to the file descriptor it is | 31 // Watches for |kShutDownMessage| to be written to the file descriptor it is |
| 30 // watching. When it reads |kShutDownMessage|, it performs |shutdown_task_|. | 32 // watching. When it reads |kShutDownMessage|, it performs |shutdown_task_|. |
| 31 // Used here to monitor the socket listening to g_signal_socket. | 33 // Used here to monitor the socket listening to g_signal_socket. |
| 32 class ServiceProcessShutdownMonitor | 34 class ServiceProcessShutdownMonitor |
| 33 : public base::MessagePumpLibevent::Watcher { | 35 : public base::MessagePumpLibevent::Watcher { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 | 52 |
| 51 struct ServiceProcessState::StateData | 53 struct ServiceProcessState::StateData |
| 52 : public base::RefCountedThreadSafe<ServiceProcessState::StateData> { | 54 : public base::RefCountedThreadSafe<ServiceProcessState::StateData> { |
| 53 StateData(); | 55 StateData(); |
| 54 | 56 |
| 55 // WatchFileDescriptor needs to be set up by the thread that is going | 57 // WatchFileDescriptor needs to be set up by the thread that is going |
| 56 // to be monitoring it. | 58 // to be monitoring it. |
| 57 void SignalReady(); | 59 void SignalReady(); |
| 58 | 60 |
| 59 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 62 void WatchExecutable(); |
| 63 |
| 60 base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; | 64 base::mac::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; |
| 65 FilePathWatcher executable_watcher_; |
| 66 ServiceProcessState* state_; |
| 61 #endif // OS_MACOSX | 67 #endif // OS_MACOSX |
| 62 #if defined(OS_LINUX) | 68 #if defined(OS_LINUX) |
| 63 scoped_ptr<MultiProcessLock> initializing_lock_; | 69 scoped_ptr<MultiProcessLock> initializing_lock_; |
| 64 scoped_ptr<MultiProcessLock> running_lock_; | 70 scoped_ptr<MultiProcessLock> running_lock_; |
| 65 #endif // OS_LINUX | 71 #endif // OS_LINUX |
| 66 scoped_ptr<ServiceProcessShutdownMonitor> shut_down_monitor_; | 72 scoped_ptr<ServiceProcessShutdownMonitor> shut_down_monitor_; |
| 67 base::MessagePumpLibevent::FileDescriptorWatcher watcher_; | 73 base::MessagePumpLibevent::FileDescriptorWatcher watcher_; |
| 68 int sockets_[2]; | 74 int sockets_[2]; |
| 69 struct sigaction old_action_; | 75 struct sigaction old_action_; |
| 70 bool set_action_; | 76 bool set_action_; |
| 71 | 77 |
| 72 protected: | 78 protected: |
| 73 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; | 79 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; |
| 74 virtual ~StateData(); | 80 virtual ~StateData(); |
| 75 }; | 81 }; |
| 76 | 82 |
| 77 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ | 83 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |
| OLD | NEW |