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

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 debug and clang 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 #if defined(OS_WIN)
22 #include "sandbox/win/src/sandbox_types.h"
23 #endif
24
21 namespace base { 25 namespace base {
22 class CommandLine; 26 class CommandLine;
23 } 27 }
24 28
25 namespace content { 29 namespace content {
26 30
31 // Note: These codes are listed in a histogram and any new codes should be added
32 // at the end.
33 enum LaunchResultCode {
34 // Launch start code, to not overlap with sandbox::ResultCode.
35 LAUNCH_RESULT_START = 1001,
36 // Launch success.
37 LAUNCH_RESULT_SUCCESS,
38 // Generic launch failure.
39 LAUNCH_RESULT_FAILURE,
40 // Placeholder for last item of the enum.
41 LAUNCH_RESULT_CODE_LAST_CODE
42 };
43
44 #if defined(OS_WIN)
45 static_assert(static_cast<int>(LAUNCH_RESULT_START) >
46 static_cast<int>(sandbox::SBOX_ERROR_LAST),
47 "LaunchResultCode must not overlap with sandbox::ResultCode");
48 #endif
49
27 // Launches a process asynchronously and notifies the client of the process 50 // 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 51 // 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. 52 // on the OS since often it can take > 100 ms to create the process.
30 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe { 53 class CONTENT_EXPORT ChildProcessLauncher : public base::NonThreadSafe {
31 public: 54 public:
32 class CONTENT_EXPORT Client { 55 class CONTENT_EXPORT Client {
33 public: 56 public:
34 // Will be called on the thread that the ChildProcessLauncher was 57 // Will be called on the thread that the ChildProcessLauncher was
35 // constructed on. 58 // constructed on.
36 virtual void OnProcessLaunched() = 0; 59 virtual void OnProcessLaunched() = 0;
37 60
38 virtual void OnProcessLaunchFailed() {}; 61 virtual void OnProcessLaunchFailed(int error_code) {};
39 62
40 protected: 63 protected:
41 virtual ~Client() {} 64 virtual ~Client() {}
42 }; 65 };
43 66
44 // Launches the process asynchronously, calling the client when the result is 67 // Launches the process asynchronously, calling the client when the result is
45 // ready. Deleting this object before the process is created is safe, since 68 // 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 69 // the callback won't be called. If the process is still running by the time
47 // this object destructs, it will be terminated. 70 // this object destructs, it will be terminated.
48 // Takes ownership of cmd_line. 71 // 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. 117 // to launch the child process on the launcher thread.
95 // It makes sure we always perform the necessary cleanup if the 118 // It makes sure we always perform the necessary cleanup if the
96 // client went away. 119 // client went away.
97 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, 120 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance,
98 bool terminate_on_shutdown, 121 bool terminate_on_shutdown,
99 ZygoteHandle zygote, 122 ZygoteHandle zygote,
100 #if defined(OS_ANDROID) 123 #if defined(OS_ANDROID)
101 base::ScopedFD ipcfd, 124 base::ScopedFD ipcfd,
102 base::ScopedFD mojo_fd, 125 base::ScopedFD mojo_fd,
103 #endif 126 #endif
104 base::Process process); 127 base::Process process,
128 int error_code);
105 129
106 // Notifies the client about the result of the operation. 130 // Notifies the client about the result of the operation.
107 void Notify(ZygoteHandle zygote, 131 void Notify(ZygoteHandle zygote,
108 #if defined(OS_ANDROID) 132 #if defined(OS_ANDROID)
109 base::ScopedFD ipcfd, 133 base::ScopedFD ipcfd,
110 #endif 134 #endif
111 base::Process process); 135 base::Process process,
136 int error_code);
112 137
113 #if defined(MOJO_SHELL_CLIENT) 138 #if defined(MOJO_SHELL_CLIENT)
114 // When this process is run from an external Mojo shell, this function will 139 // 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 140 // 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 141 // other end with the external shell, allowing the spawned process to bind an
117 // Application request from the shell. 142 // Application request from the shell.
118 void CreateMojoShellChannel(base::CommandLine* command_line, 143 void CreateMojoShellChannel(base::CommandLine* command_line,
119 int child_process_id); 144 int child_process_id);
120 #endif 145 #endif
121 146
(...skipping 12 matching lines...) Expand all
134 mojo::edk::PlatformChannelPair mojo_platform_channel_; 159 mojo::edk::PlatformChannelPair mojo_platform_channel_;
135 160
136 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; 161 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_;
137 162
138 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); 163 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
139 }; 164 };
140 165
141 } // namespace content 166 } // namespace content
142 167
143 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ 168 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698