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

Side by Side Diff: shell/context.cc

Issue 1061413002: Shell: Make a separate binary for child processes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "shell/context.h" 5 #include "shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 void Context::SetCommandLineCWD(const base::FilePath& path) { 230 void Context::SetCommandLineCWD(const base::FilePath& path) {
231 command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path)); 231 command_line_cwd_ = AddTrailingSlashIfNeeded(FilePathToFileURL(path));
232 } 232 }
233 233
234 GURL Context::ResolveCommandLineURL(const std::string& path) { 234 GURL Context::ResolveCommandLineURL(const std::string& path) {
235 return command_line_cwd_.Resolve(path); 235 return command_line_cwd_.Resolve(path);
236 } 236 }
237 237
238 bool Context::Init() { 238 bool Context::Init() {
239 TRACE_EVENT0("mojo_shell", "Context::Init"); 239 base::FilePath shell_path = base::MakeAbsoluteFilePath(
240 base::CommandLine::ForCurrentProcess()->GetProgram());
241 base::FilePath shell_child_path =
242 shell_path.DirName().AppendASCII("mojo_shell_child");
243 return InitWithPaths(shell_path, shell_child_path);
244 }
245
246 bool Context::InitWithPaths(const base::FilePath& shell_path,
247 const base::FilePath& shell_child_path) {
248 TRACE_EVENT0("mojo_shell", "Context::InitWithPaths");
240 const base::CommandLine& command_line = 249 const base::CommandLine& command_line =
241 *base::CommandLine::ForCurrentProcess(); 250 *base::CommandLine::ForCurrentProcess();
242 251
243 if (command_line.HasSwitch(switches::kWaitForDebugger)) 252 if (command_line.HasSwitch(switches::kWaitForDebugger))
244 base::debug::WaitForDebugger(60, true); 253 base::debug::WaitForDebugger(60, true);
245 254
246 mojo_shell_path_ = base::MakeAbsoluteFilePath(command_line.GetProgram()); 255 mojo_shell_path_ = shell_path;
247 // TODO(vtl): For the moment, the child is the same as the parent. 256 mojo_shell_child_path_ = shell_child_path;
248 mojo_shell_child_path_ = mojo_shell_path_;
249 257
250 EnsureEmbedderIsInitialized(); 258 EnsureEmbedderIsInitialized();
251 task_runners_.reset( 259 task_runners_.reset(
252 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); 260 new TaskRunners(base::MessageLoop::current()->message_loop_proxy()));
253 261
254 // TODO(vtl): Probably these failures should be checked before |Init()|, and 262 // TODO(vtl): Probably these failures should be checked before |Init()|, and
255 // this function simply shouldn't fail. 263 // this function simply shouldn't fail.
256 if (!shell_file_root_.is_valid()) 264 if (!shell_file_root_.is_valid())
257 return false; 265 return false;
258 if (!ConfigureURLMappings(command_line, this)) 266 if (!ConfigureURLMappings(command_line, this))
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { 351 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
344 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 352 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
345 task_runners_->shell_runner()); 353 task_runners_->shell_runner());
346 base::MessageLoop::current()->Quit(); 354 base::MessageLoop::current()->Quit();
347 } 355 }
348 } 356 }
349 } 357 }
350 358
351 } // namespace shell 359 } // namespace shell
352 } // namespace mojo 360 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698