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 CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
11 #include "base/process/launch.h" | 11 #include "base/process/launch.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 | 13 |
| 14 namespace base { |
14 class CommandLine; | 15 class CommandLine; |
| 16 } |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 class SandboxedProcessLauncherDelegate; | 19 class SandboxedProcessLauncherDelegate; |
18 | 20 |
19 // Launches a process asynchronously and notifies the client of the process | 21 // Launches a process asynchronously and notifies the client of the process |
20 // handle when it's available. It's used to avoid blocking the calling thread | 22 // handle when it's available. It's used to avoid blocking the calling thread |
21 // on the OS since often it can take > 100 ms to create the process. | 23 // on the OS since often it can take > 100 ms to create the process. |
22 class CONTENT_EXPORT ChildProcessLauncher { | 24 class CONTENT_EXPORT ChildProcessLauncher { |
23 public: | 25 public: |
24 class CONTENT_EXPORT Client { | 26 class CONTENT_EXPORT Client { |
25 public: | 27 public: |
26 // Will be called on the thread that the ChildProcessLauncher was | 28 // Will be called on the thread that the ChildProcessLauncher was |
27 // constructed on. | 29 // constructed on. |
28 virtual void OnProcessLaunched() = 0; | 30 virtual void OnProcessLaunched() = 0; |
29 | 31 |
30 virtual void OnProcessLaunchFailed() {}; | 32 virtual void OnProcessLaunchFailed() {}; |
31 | 33 |
32 protected: | 34 protected: |
33 virtual ~Client() {} | 35 virtual ~Client() {} |
34 }; | 36 }; |
35 | 37 |
36 // Launches the process asynchronously, calling the client when the result is | 38 // Launches the process asynchronously, calling the client when the result is |
37 // ready. Deleting this object before the process is created is safe, since | 39 // ready. Deleting this object before the process is created is safe, since |
38 // the callback won't be called. If the process is still running by the time | 40 // the callback won't be called. If the process is still running by the time |
39 // this object destructs, it will be terminated. | 41 // this object destructs, it will be terminated. |
40 // Takes ownership of cmd_line. | 42 // Takes ownership of cmd_line. |
41 ChildProcessLauncher( | 43 ChildProcessLauncher( |
42 SandboxedProcessLauncherDelegate* delegate, | 44 SandboxedProcessLauncherDelegate* delegate, |
43 CommandLine* cmd_line, | 45 base::CommandLine* cmd_line, |
44 int child_process_id, | 46 int child_process_id, |
45 Client* client); | 47 Client* client); |
46 ~ChildProcessLauncher(); | 48 ~ChildProcessLauncher(); |
47 | 49 |
48 // True if the process is being launched and so the handle isn't available. | 50 // True if the process is being launched and so the handle isn't available. |
49 bool IsStarting(); | 51 bool IsStarting(); |
50 | 52 |
51 // Getter for the process handle. Only call after the process has started. | 53 // Getter for the process handle. Only call after the process has started. |
52 base::ProcessHandle GetHandle(); | 54 base::ProcessHandle GetHandle(); |
53 | 55 |
(...skipping 23 matching lines...) Expand all Loading... |
77 class Context; | 79 class Context; |
78 | 80 |
79 scoped_refptr<Context> context_; | 81 scoped_refptr<Context> context_; |
80 | 82 |
81 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 83 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
82 }; | 84 }; |
83 | 85 |
84 } // namespace content | 86 } // namespace content |
85 | 87 |
86 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 88 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
OLD | NEW |