| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Terminates the worker process and closes the IPC channel. | 60 // Terminates the worker process and closes the IPC channel. |
| 61 virtual void KillProcess() = 0; | 61 virtual void KillProcess() = 0; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Creates the launcher that will use |launcher_delegate| to manage the worker | 64 // Creates the launcher that will use |launcher_delegate| to manage the worker |
| 65 // process and |ipc_handler| to handle IPCs. The caller must ensure that | 65 // process and |ipc_handler| to handle IPCs. The caller must ensure that |
| 66 // |ipc_handler| must outlive this object. | 66 // |ipc_handler| must outlive this object. |
| 67 WorkerProcessLauncher(scoped_ptr<Delegate> launcher_delegate, | 67 WorkerProcessLauncher(scoped_ptr<Delegate> launcher_delegate, |
| 68 WorkerProcessIpcDelegate* ipc_handler); | 68 WorkerProcessIpcDelegate* ipc_handler); |
| 69 virtual ~WorkerProcessLauncher(); | 69 ~WorkerProcessLauncher() override; |
| 70 | 70 |
| 71 // Asks the worker process to crash and generate a dump, and closes the IPC | 71 // Asks the worker process to crash and generate a dump, and closes the IPC |
| 72 // channel. |location| is passed to the worker so that it is on the stack in | 72 // channel. |location| is passed to the worker so that it is on the stack in |
| 73 // the dump. Restarts the worker process forcefully, if it does | 73 // the dump. Restarts the worker process forcefully, if it does |
| 74 // not exit on its own. | 74 // not exit on its own. |
| 75 void Crash(const tracked_objects::Location& location); | 75 void Crash(const tracked_objects::Location& location); |
| 76 | 76 |
| 77 // Sends an IPC message to the worker process. The message will be silently | 77 // Sends an IPC message to the worker process. The message will be silently |
| 78 // dropped if Send() is called before Start() or after stutdown has been | 78 // dropped if Send() is called before Start() or after stutdown has been |
| 79 // initiated. | 79 // initiated. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 95 // has to validate |peer_pid| if necessary. | 95 // has to validate |peer_pid| if necessary. |
| 96 bool OnMessageReceived(const IPC::Message& message); | 96 bool OnMessageReceived(const IPC::Message& message); |
| 97 void OnChannelConnected(int32 peer_pid); | 97 void OnChannelConnected(int32 peer_pid); |
| 98 void OnChannelError(); | 98 void OnChannelError(); |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 friend class WorkerProcessLauncherTest; | 101 friend class WorkerProcessLauncherTest; |
| 102 | 102 |
| 103 // base::win::ObjectWatcher::Delegate implementation used to watch for | 103 // base::win::ObjectWatcher::Delegate implementation used to watch for |
| 104 // the worker process exiting. | 104 // the worker process exiting. |
| 105 virtual void OnObjectSignaled(HANDLE object) override; | 105 void OnObjectSignaled(HANDLE object) override; |
| 106 | 106 |
| 107 // Returns true when the object is being destroyed. | 107 // Returns true when the object is being destroyed. |
| 108 bool stopping() const { return ipc_handler_ == nullptr; } | 108 bool stopping() const { return ipc_handler_ == nullptr; } |
| 109 | 109 |
| 110 // Attempts to launch the worker process. Schedules next launch attempt if | 110 // Attempts to launch the worker process. Schedules next launch attempt if |
| 111 // creation of the process fails. | 111 // creation of the process fails. |
| 112 void LaunchWorker(); | 112 void LaunchWorker(); |
| 113 | 113 |
| 114 // Called to record outcome of a launch attempt: success or failure. | 114 // Called to record outcome of a launch attempt: success or failure. |
| 115 void RecordLaunchResult(); | 115 void RecordLaunchResult(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // The handle of the worker process, if launched. | 161 // The handle of the worker process, if launched. |
| 162 base::win::ScopedHandle worker_process_; | 162 base::win::ScopedHandle worker_process_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); | 164 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 } // namespace remoting | 167 } // namespace remoting |
| 168 | 168 |
| 169 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ | 169 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ |
| OLD | NEW |