Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: remoting/host/win/worker_process_launcher.h

Issue 12545006: The worker process launcher can now ask the worker to crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
13 #include "ipc/ipc_sender.h" 13 #include "ipc/ipc_sender.h"
14 14
15 namespace base { 15 namespace base {
16 class SingleThreadTaskRunner; 16 class SingleThreadTaskRunner;
17 } // namespace base 17 } // namespace base
18 18
19 namespace IPC { 19 namespace IPC {
20 class Listener; 20 class Listener;
21 class Message; 21 class Message;
22 } // namespace IPC 22 } // namespace IPC
23 23
24 namespace tracked_objects {
25 class Location;
26 } // namespace tracked_objects
27
24 namespace remoting { 28 namespace remoting {
25 29
26 class WorkerProcessIpcDelegate; 30 class WorkerProcessIpcDelegate;
27 31
28 // Launches a worker process that is controlled via an IPC channel. All 32 // Launches a worker process that is controlled via an IPC channel. All
29 // interaction with the spawned process is through WorkerProcessIpcDelegate and 33 // interaction with the spawned process is through WorkerProcessIpcDelegate and
30 // Send() method. In case of error the channel is closed and the worker process 34 // Send() method. In case of error the channel is closed and the worker process
31 // is terminated. 35 // is terminated.
32 class WorkerProcessLauncher { 36 class WorkerProcessLauncher {
33 public: 37 public:
34 class Delegate : public IPC::Sender { 38 class Delegate : public IPC::Sender {
35 public: 39 public:
36 virtual ~Delegate(); 40 virtual ~Delegate();
37 41
42 // Closes the IPC channel.
43 virtual void CloseChannel() = 0;
44
38 // Returns PID of the worker process or 0 if it is not available. 45 // Returns PID of the worker process or 0 if it is not available.
39 virtual DWORD GetProcessId() const = 0; 46 virtual DWORD GetProcessId() const = 0;
40 47
41 // Returns true if the worker process should not be restarted any more. 48 // Returns true if the worker process should not be restarted any more.
42 virtual bool IsPermanentError(int failure_count) const = 0; 49 virtual bool IsPermanentError(int failure_count) const = 0;
43 50
44 // Terminates the worker process with the given exit code. Destroys the IPC 51 // Terminates the worker process with the given exit code. Destroys the IPC
45 // channel created by LaunchProcess(). 52 // channel created by LaunchProcess().
46 virtual void KillProcess(DWORD exit_code) = 0; 53 virtual void KillProcess(DWORD exit_code) = 0;
47 54
(...skipping 13 matching lines...) Expand all
61 // 68 //
62 // The caller should call all the methods on this class on 69 // The caller should call all the methods on this class on
63 // the |caller_task_runner| thread. Methods of both delegate interfaces are 70 // the |caller_task_runner| thread. Methods of both delegate interfaces are
64 // called on the |caller_task_runner| thread as well. 71 // called on the |caller_task_runner| thread as well.
65 WorkerProcessLauncher( 72 WorkerProcessLauncher(
66 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 73 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
67 scoped_ptr<Delegate> launcher_delegate, 74 scoped_ptr<Delegate> launcher_delegate,
68 WorkerProcessIpcDelegate* worker_delegate); 75 WorkerProcessIpcDelegate* worker_delegate);
69 ~WorkerProcessLauncher(); 76 ~WorkerProcessLauncher();
70 77
78 // Asks the worker process to crash generating a dump and closes
Wez 2013/03/07 01:54:35 nit: "... crash and generate a dump, and ..."
alexeypa (please no reviews) 2013/03/07 21:28:30 Done.
79 // the IPC channel. |location| is passed to the worker so that it is included
80 // to the generated dump. Restarts the worker process forcefully, if it does
Wez 2013/03/07 01:54:35 nit: "... it is on the stack in the dump."
Wez 2013/03/07 01:54:35 nit: Does it always restart it, or just kill it an
alexeypa (please no reviews) 2013/03/07 21:28:30 Done.
alexeypa (please no reviews) 2013/03/07 21:28:30 It always restarts it. If the caller decide to sto
81 // not exit on its own.
82 void Crash(const tracked_objects::Location& location);
83
71 // Sends an IPC message to the worker process. The message will be silently 84 // Sends an IPC message to the worker process. The message will be silently
72 // dropped if Send() is called before Start() or after stutdown has been 85 // dropped if Send() is called before Start() or after stutdown has been
73 // initiated. 86 // initiated.
74 void Send(IPC::Message* message); 87 void Send(IPC::Message* message);
75 88
76 private: 89 private:
77 // The actual implementation resides in WorkerProcessLauncher::Core class. 90 // The actual implementation resides in WorkerProcessLauncher::Core class.
78 class Core; 91 class Core;
79 scoped_refptr<Core> core_; 92 scoped_refptr<Core> core_;
80 93
81 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher); 94 DISALLOW_COPY_AND_ASSIGN(WorkerProcessLauncher);
82 }; 95 };
83 96
84 } // namespace remoting 97 } // namespace remoting
85 98
86 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_ 99 #endif // REMOTING_HOST_WIN_WORKER_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698