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

Side by Side Diff: chrome/browser/child_process_launcher.cc

Issue 397031: Launch processes asynchronously so as not to block the UI thread. For now, re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: return 0 instead of -1 if zygote couldn't launch renderer Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/child_process_launcher.h" 5 #include "chrome/browser/child_process_launcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 private: 66 private:
67 friend class base::RefCountedThreadSafe<ChildProcessLauncher::Context>; 67 friend class base::RefCountedThreadSafe<ChildProcessLauncher::Context>;
68 friend class ChildProcessLauncher; 68 friend class ChildProcessLauncher;
69 69
70 ~Context() { 70 ~Context() {
71 Terminate(); 71 Terminate();
72 } 72 }
73 73
74 void LaunchInternal(int ipcfd, CommandLine* cmd_line) { 74 void LaunchInternal(int ipcfd, CommandLine* cmd_line) {
75 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line); 75 scoped_ptr<CommandLine> cmd_line_deleter(cmd_line);
76 base::ProcessHandle handle; 76 base::ProcessHandle handle = base::kNullProcessHandle;
77 bool zygote = false; 77 bool zygote = false;
78 #if defined(OS_WIN) 78 #if defined(OS_WIN)
79 handle = sandbox::StartProcess(cmd_line); 79 handle = sandbox::StartProcess(cmd_line);
80 #elif defined(OS_POSIX) 80 #elif defined(OS_POSIX)
81 81
82 #if defined(OS_LINUX) 82 #if defined(OS_LINUX)
83 // On Linux, normally spawn processes with zygotes. We can't do this when 83 // On Linux, normally spawn processes with zygotes. We can't do this when
84 // we're spawning child processes through an external program (i.e. there is 84 // we're spawning child processes through an external program (i.e. there is
85 // a command prefix) like GDB so fall through to the POSIX case then. 85 // a command prefix) like GDB so fall through to the POSIX case then.
86 if (!CommandLine::ForCurrentProcess()->HasSwitch( 86 if (!CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 25 matching lines...) Expand all
112 fds_to_map.push_back(std::make_pair(crash_signal_fd, 112 fds_to_map.push_back(std::make_pair(crash_signal_fd,
113 kCrashDumpSignal + 3)); 113 kCrashDumpSignal + 3));
114 } 114 }
115 const int sandbox_fd = 115 const int sandbox_fd =
116 Singleton<RenderSandboxHostLinux>()->GetRendererSocket(); 116 Singleton<RenderSandboxHostLinux>()->GetRendererSocket();
117 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3)); 117 fds_to_map.push_back(std::make_pair(sandbox_fd, kSandboxIPCChannel + 3));
118 #endif // defined(OS_LINUX) 118 #endif // defined(OS_LINUX)
119 119
120 // Actually launch the app. 120 // Actually launch the app.
121 if (!base::LaunchApp(cmd_line->argv(), fds_to_map, false, &handle)) 121 if (!base::LaunchApp(cmd_line->argv(), fds_to_map, false, &handle))
122 handle = 0; 122 handle = base::kNullProcessHandle;
123 } 123 }
124 #endif 124 #endif
125 125
126 ChromeThread::PostTask( 126 ChromeThread::PostTask(
127 client_thread_id_, FROM_HERE, 127 client_thread_id_, FROM_HERE,
128 NewRunnableMethod( 128 NewRunnableMethod(
129 this, &ChildProcessLauncher::Context::Notify, handle, zygote)); 129 this, &ChildProcessLauncher::Context::Notify, handle, zygote));
130 } 130 }
131 131
132 void Notify(base::ProcessHandle handle, bool zygote) { 132 void Notify(base::ProcessHandle handle, bool zygote) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (child_exited) 229 if (child_exited)
230 context_->process_.Close(); 230 context_->process_.Close();
231 231
232 return did_crash; 232 return did_crash;
233 } 233 }
234 234
235 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { 235 void ChildProcessLauncher::SetProcessBackgrounded(bool background) {
236 DCHECK(!context_->starting_); 236 DCHECK(!context_->starting_);
237 context_->process_.SetProcessBackgrounded(background); 237 context_->process_.SetProcessBackgrounded(background);
238 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/child_process_launcher.h ('k') | chrome/browser/extensions/extension_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698