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

Side by Side Diff: content/browser/child_process_launcher.h

Issue 1923653002: Wire up process launch error codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android Created 4 years, 7 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
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 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/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/process/kill.h" 11 #include "base/process/kill.h"
12 #include "base/process/launch.h" 12 #include "base/process/launch.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/sandboxed_process_launcher_delegate.h" 18 #include "content/public/common/sandboxed_process_launcher_delegate.h"
19 #include "mojo/edk/embedder/platform_channel_pair.h" 19 #include "mojo/edk/embedder/platform_channel_pair.h"
20 20
21 namespace base { 21 namespace base {
22 class CommandLine; 22 class CommandLine;
23 } 23 }
24 24
25 namespace content { 25 namespace content {
26 26
27 // Platform neutral result codes for process launches.
28 // Each platform can optionally define its own specific set of error codes.
29 // For Windows, these are sandbox::ResultCode starting at offset 1000 located in
jam 2016/04/28 15:41:14 normally this is done by having the lower layer se
Will Harris 2016/05/02 16:45:23 I now start the enum in the lower layer, and then
30 // sandbox/win/src/sandbox_types.h
31 enum LaunchResultCode {
32 // Launch success.
33 LAUNCH_RESULT_SUCCESS = 0,
34 // Generic launch failure.
35 LAUNCH_RESULT_FAILURE,
36 // Placeholder for last item of the enum.
37 LAUNCH_RESULT_CODE_LAST_CODE
38 };
39
27 // Launches a process asynchronously and notifies the client of the process 40 // Launches a process asynchronously and notifies the client of the process
28 // handle when it's available. It's used to avoid blocking the calling thread 41 // handle when it's available. It's used to avoid blocking the calling thread
29 // on the OS since often it can take > 100 ms to create the process. 42 // on the OS since often it can take > 100 ms to create the process.
30 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe { 43 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe {
31 public: 44 public:
32 class CONTENT_EXPORT Client { 45 class CONTENT_EXPORT Client {
33 public: 46 public:
34 // Will be called on the thread that the ChildProcessLauncher was 47 // Will be called on the thread that the ChildProcessLauncher was
35 // constructed on. 48 // constructed on.
36 virtual void OnProcessLaunched() = 0; 49 virtual void OnProcessLaunched() = 0;
37 50
38 virtual void OnProcessLaunchFailed() {}; 51 virtual void OnProcessLaunchFailed(int error_code) {};
39 52
40 protected: 53 protected:
41 virtual ~Client() {} 54 virtual ~Client() {}
42 }; 55 };
43 56
44 // Launches the process asynchronously, calling the client when the result is 57 // Launches the process asynchronously, calling the client when the result is
45 // ready. Deleting this object before the process is created is safe, since 58 // ready. Deleting this object before the process is created is safe, since
46 // the callback won't be called. If the process is still running by the time 59 // the callback won't be called. If the process is still running by the time
47 // this object destructs, it will be terminated. 60 // this object destructs, it will be terminated.
48 // Takes ownership of cmd_line. 61 // Takes ownership of cmd_line.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // to launch the child process on the launcher thread. 107 // to launch the child process on the launcher thread.
95 // It makes sure we always perform the necessary cleanup if the 108 // It makes sure we always perform the necessary cleanup if the
96 // client went away. 109 // client went away.
97 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, 110 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance,
98 bool terminate_on_shutdown, 111 bool terminate_on_shutdown,
99 ZygoteHandle zygote, 112 ZygoteHandle zygote,
100 #if defined(OS_ANDROID) 113 #if defined(OS_ANDROID)
101 base::ScopedFD ipcfd, 114 base::ScopedFD ipcfd,
102 base::ScopedFD mojo_fd, 115 base::ScopedFD mojo_fd,
103 #endif 116 #endif
104 base::Process process); 117 base::Process process,
118 int error_code);
105 119
106 // Notifies the client about the result of the operation. 120 // Notifies the client about the result of the operation.
107 void Notify(ZygoteHandle zygote, 121 void Notify(ZygoteHandle zygote,
108 #if defined(OS_ANDROID) 122 #if defined(OS_ANDROID)
109 base::ScopedFD ipcfd, 123 base::ScopedFD ipcfd,
110 #endif 124 #endif
111 base::Process process); 125 base::Process process,
126 int error_code);
112 127
113 #if defined(MOJO_SHELL_CLIENT) 128 #if defined(MOJO_SHELL_CLIENT)
114 // When this process is run from an external Mojo shell, this function will 129 // When this process is run from an external Mojo shell, this function will
115 // create a channel and pass one end to the spawned process and register the 130 // create a channel and pass one end to the spawned process and register the
116 // other end with the external shell, allowing the spawned process to bind an 131 // other end with the external shell, allowing the spawned process to bind an
117 // Application request from the shell. 132 // Application request from the shell.
118 void CreateMojoShellChannel(base::CommandLine* command_line, 133 void CreateMojoShellChannel(base::CommandLine* command_line,
119 int child_process_id); 134 int child_process_id);
120 #endif 135 #endif
121 136
(...skipping 12 matching lines...) Expand all
134 mojo::edk::PlatformChannelPair mojo_platform_channel_; 149 mojo::edk::PlatformChannelPair mojo_platform_channel_;
135 150
136 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; 151 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_;
137 152
138 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); 153 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
139 }; 154 };
140 155
141 } // namespace content 156 } // namespace content
142 157
143 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ 158 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698