OLD | NEW |
1 // Copyright (c) 2011 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/callback.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
15 | 16 |
16 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 17 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
17 #include "chrome/common/multi_process_lock.h" | 18 #include "chrome/common/multi_process_lock.h" |
18 MultiProcessLock* TakeServiceRunningLock(bool waiting); | 19 MultiProcessLock* TakeServiceRunningLock(bool waiting); |
19 #endif | 20 #endif |
20 | 21 |
21 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
22 #include "base/files/file_path_watcher.h" | 23 #include "base/files/file_path_watcher.h" |
(...skipping 12 matching lines...) Expand all Loading... |
35 // watching. When it reads |kTerminateMessage|, it performs |terminate_task_|. | 36 // watching. When it reads |kTerminateMessage|, it performs |terminate_task_|. |
36 // Used here to monitor the socket listening to g_signal_socket. | 37 // Used here to monitor the socket listening to g_signal_socket. |
37 class ServiceProcessTerminateMonitor | 38 class ServiceProcessTerminateMonitor |
38 : public MessageLoopForIO::Watcher { | 39 : public MessageLoopForIO::Watcher { |
39 public: | 40 public: |
40 | 41 |
41 enum { | 42 enum { |
42 kTerminateMessage = 0xdecea5e | 43 kTerminateMessage = 0xdecea5e |
43 }; | 44 }; |
44 | 45 |
45 explicit ServiceProcessTerminateMonitor(Task* terminate_task); | 46 explicit ServiceProcessTerminateMonitor(const base::Closure& terminate_task); |
46 virtual ~ServiceProcessTerminateMonitor(); | 47 virtual ~ServiceProcessTerminateMonitor(); |
47 | 48 |
48 // MessageLoopForIO::Watcher overrides | 49 // MessageLoopForIO::Watcher overrides |
49 virtual void OnFileCanReadWithoutBlocking(int fd); | 50 virtual void OnFileCanReadWithoutBlocking(int fd); |
50 virtual void OnFileCanWriteWithoutBlocking(int fd); | 51 virtual void OnFileCanWriteWithoutBlocking(int fd); |
51 | 52 |
52 private: | 53 private: |
53 scoped_ptr<Task> terminate_task_; | 54 base::Closure terminate_task_; |
54 }; | 55 }; |
55 | 56 |
56 struct ServiceProcessState::StateData | 57 struct ServiceProcessState::StateData |
57 : public base::RefCountedThreadSafe<ServiceProcessState::StateData> { | 58 : public base::RefCountedThreadSafe<ServiceProcessState::StateData> { |
58 StateData(); | 59 StateData(); |
59 | 60 |
60 // WatchFileDescriptor needs to be set up by the thread that is going | 61 // WatchFileDescriptor needs to be set up by the thread that is going |
61 // to be monitoring it. | 62 // to be monitoring it. |
62 void SignalReady(base::WaitableEvent* signal, bool* success); | 63 void SignalReady(base::WaitableEvent* signal, bool* success); |
63 | 64 |
(...skipping 16 matching lines...) Expand all Loading... |
80 int sockets_[2]; | 81 int sockets_[2]; |
81 struct sigaction old_action_; | 82 struct sigaction old_action_; |
82 bool set_action_; | 83 bool set_action_; |
83 | 84 |
84 protected: | 85 protected: |
85 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; | 86 friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; |
86 virtual ~StateData(); | 87 virtual ~StateData(); |
87 }; | 88 }; |
88 | 89 |
89 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ | 90 #endif // CHROME_COMMON_SERVICE_PROCESS_UTIL_POSIX_H_ |
OLD | NEW |