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_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 5 #ifndef CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
6 #define CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 6 #define CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/cancelable_callback.h" | 15 #include "base/cancelable_callback.h" |
16 #include "base/id_map.h" | 16 #include "base/id_map.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
20 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
22 #include "ipc/ipc_channel_proxy.h" | 22 #include "ipc/ipc_channel_proxy.h" |
23 #include "ipc/ipc_listener.h" | 23 #include "ipc/ipc_listener.h" |
24 #include "ipc/ipc_sender.h" | 24 #include "ipc/ipc_sender.h" |
25 | 25 |
| 26 namespace base { |
26 class CommandLine; | 27 class CommandLine; |
| 28 } |
27 | 29 |
28 namespace cloud_print { | 30 namespace cloud_print { |
29 struct CloudPrintProxyInfo; | 31 struct CloudPrintProxyInfo; |
30 } // namespace cloud_print | 32 } // namespace cloud_print |
31 | 33 |
32 // A ServiceProcessControl works as a portal between the service process and | 34 // A ServiceProcessControl works as a portal between the service process and |
33 // the browser process. | 35 // the browser process. |
34 // | 36 // |
35 // It is used to start and terminate the service process. It is also used | 37 // It is used to start and terminate the service process. It is also used |
36 // to send and receive IPC messages from the service process. | 38 // to send and receive IPC messages from the service process. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // be called in this case. | 127 // be called in this case. |
126 bool GetHistograms(const base::Closure& cloud_print_status_callback, | 128 bool GetHistograms(const base::Closure& cloud_print_status_callback, |
127 const base::TimeDelta& timeout); | 129 const base::TimeDelta& timeout); |
128 | 130 |
129 private: | 131 private: |
130 // This class is responsible for launching the service process on the | 132 // This class is responsible for launching the service process on the |
131 // PROCESS_LAUNCHER thread. | 133 // PROCESS_LAUNCHER thread. |
132 class Launcher | 134 class Launcher |
133 : public base::RefCountedThreadSafe<ServiceProcessControl::Launcher> { | 135 : public base::RefCountedThreadSafe<ServiceProcessControl::Launcher> { |
134 public: | 136 public: |
135 Launcher(ServiceProcessControl* process, CommandLine* cmd_line); | 137 Launcher(ServiceProcessControl* process, base::CommandLine* cmd_line); |
136 // Execute the command line to start the process asynchronously. After the | 138 // Execute the command line to start the process asynchronously. After the |
137 // command is executed |task| is called with the process handle on the UI | 139 // command is executed |task| is called with the process handle on the UI |
138 // thread. | 140 // thread. |
139 void Run(const base::Closure& task); | 141 void Run(const base::Closure& task); |
140 | 142 |
141 bool launched() const { return launched_; } | 143 bool launched() const { return launched_; } |
142 | 144 |
143 private: | 145 private: |
144 friend class base::RefCountedThreadSafe<ServiceProcessControl::Launcher>; | 146 friend class base::RefCountedThreadSafe<ServiceProcessControl::Launcher>; |
145 virtual ~Launcher(); | 147 virtual ~Launcher(); |
146 | 148 |
147 #if !defined(OS_MACOSX) | 149 #if !defined(OS_MACOSX) |
148 void DoDetectLaunched(); | 150 void DoDetectLaunched(); |
149 #endif // !OS_MACOSX | 151 #endif // !OS_MACOSX |
150 | 152 |
151 void DoRun(); | 153 void DoRun(); |
152 void Notify(); | 154 void Notify(); |
153 void CloseProcessHandle(); | 155 void CloseProcessHandle(); |
154 ServiceProcessControl* process_; | 156 ServiceProcessControl* process_; |
155 scoped_ptr<CommandLine> cmd_line_; | 157 scoped_ptr<base::CommandLine> cmd_line_; |
156 base::Closure notify_task_; | 158 base::Closure notify_task_; |
157 bool launched_; | 159 bool launched_; |
158 uint32 retry_count_; | 160 uint32 retry_count_; |
159 base::ProcessHandle process_handle_; | 161 base::ProcessHandle process_handle_; |
160 }; | 162 }; |
161 | 163 |
162 friend class MockServiceProcessControl; | 164 friend class MockServiceProcessControl; |
163 friend class CloudPrintProxyPolicyStartupTest; | 165 friend class CloudPrintProxyPolicyStartupTest; |
164 | 166 |
165 ServiceProcessControl(); | 167 ServiceProcessControl(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // the service process. | 212 // the service process. |
211 base::Closure histograms_callback_; | 213 base::Closure histograms_callback_; |
212 | 214 |
213 content::NotificationRegistrar registrar_; | 215 content::NotificationRegistrar registrar_; |
214 | 216 |
215 // Callback that gets invoked if service didn't reply in time. | 217 // Callback that gets invoked if service didn't reply in time. |
216 base::CancelableClosure histograms_timeout_callback_; | 218 base::CancelableClosure histograms_timeout_callback_; |
217 }; | 219 }; |
218 | 220 |
219 #endif // CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ | 221 #endif // CHROME_BROWSER_SERVICE_PROCESS_SERVICE_PROCESS_CONTROL_H_ |
OLD | NEW |