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 REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ | 5 #ifndef REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ |
6 #define REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ | 6 #define REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/threading/non_thread_safe.h" | 16 #include "base/sequence_checker.h" |
17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
18 #include "base/win/object_watcher.h" | 18 #include "base/win/object_watcher.h" |
19 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
20 #include "net/base/backoff_entry.h" | 20 #include "net/base/backoff_entry.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class TimeDelta; | 23 class TimeDelta; |
24 } // namespace base | 24 } // namespace base |
25 | 25 |
26 namespace IPC { | 26 namespace IPC { |
27 class Message; | 27 class Message; |
28 } // namespace IPC | 28 } // namespace IPC |
29 | 29 |
30 namespace tracked_objects { | 30 namespace tracked_objects { |
31 class Location; | 31 class Location; |
32 } // namespace tracked_objects | 32 } // namespace tracked_objects |
33 | 33 |
34 namespace remoting { | 34 namespace remoting { |
35 | 35 |
36 class WorkerProcessIpcDelegate; | 36 class WorkerProcessIpcDelegate; |
37 | 37 |
38 // Launches a worker process that is controlled via an IPC channel. All | 38 // Launches a worker process that is controlled via an IPC channel. All |
39 // interaction with the spawned process is through WorkerProcessIpcDelegate and | 39 // interaction with the spawned process is through WorkerProcessIpcDelegate and |
40 // Send() method. In case of error the channel is closed and the worker process | 40 // Send() method. In case of error the channel is closed and the worker process |
41 // is terminated. | 41 // is terminated. |
42 class WorkerProcessLauncher | 42 class WorkerProcessLauncher : public base::win::ObjectWatcher::Delegate { |
43 : public base::NonThreadSafe, | |
44 public base::win::ObjectWatcher::Delegate { | |
45 public: | 43 public: |
46 class Delegate { | 44 class Delegate { |
47 public: | 45 public: |
48 virtual ~Delegate(); | 46 virtual ~Delegate(); |
49 | 47 |
50 // Asynchronously starts the worker process and creates an IPC channel it | 48 // Asynchronously starts the worker process and creates an IPC channel it |
51 // can connect to. |event_handler| must remain valid until KillProcess() has | 49 // can connect to. |event_handler| must remain valid until KillProcess() has |
52 // been called. | 50 // been called. |
53 virtual void LaunchProcess(WorkerProcessLauncher* event_handler) = 0; | 51 virtual void LaunchProcess(WorkerProcessLauncher* event_handler) = 0; |
54 | 52 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // terminates. | 154 // terminates. |
157 base::win::ObjectWatcher process_watcher_; | 155 base::win::ObjectWatcher process_watcher_; |
158 | 156 |
159 // Timer used to detect whether a launch attempt was successful or not, and to | 157 // Timer used to detect whether a launch attempt was successful or not, and to |
160 // cancel the launch attempt if it is taking too long. | 158 // cancel the launch attempt if it is taking too long. |
161 base::OneShotTimer launch_result_timer_; | 159 base::OneShotTimer launch_result_timer_; |
162 | 160 |
163 // The handle of the worker process, if launched. | 161 // The handle of the worker process, if launched. |
164 base::win::ScopedHandle worker_process_; | 162 base::win::ScopedHandle worker_process_; |
165 | 163 |
| 164 SEQUENCE_CHECKER(sequence_checker_); |
| 165 |
166 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); | 166 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace remoting | 169 } // namespace remoting |
170 | 170 |
171 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ | 171 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ |
OLD | NEW |