| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 12 #include "mojo/edk/embedder/simple_platform_support.h" | 12 #include "mojo/edk/embedder/simple_platform_support.h" |
| 13 #include "shell/dynamic_service_runner.h" |
| 13 #include "shell/external_application_registrar_connection.h" | 14 #include "shell/external_application_registrar_connection.h" |
| 14 #include "shell/in_process_dynamic_service_runner.h" | 15 #include "shell/in_process_dynamic_service_runner.h" |
| 15 #include "shell/init.h" | 16 #include "shell/init.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 const char kAppPath[] = "app-path"; | 20 const char kAppPath[] = "app-path"; |
| 20 const char kAppURL[] = "app-url"; | 21 const char kAppURL[] = "app-url"; |
| 21 const char kShellPath[] = "shell-path"; | 22 const char kShellPath[] = "shell-path"; |
| 22 } | 23 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 run_loop_.reset(); | 43 run_loop_.reset(); |
| 43 return shell_handle_.is_valid(); | 44 return shell_handle_.is_valid(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void Run() { | 47 void Run() { |
| 47 DCHECK(!run_loop_.get()); | 48 DCHECK(!run_loop_.get()); |
| 48 DCHECK(shell_handle_.is_valid()); | 49 DCHECK(shell_handle_.is_valid()); |
| 49 mojo::shell::InProcessDynamicServiceRunner service_runner(nullptr); | 50 mojo::shell::InProcessDynamicServiceRunner service_runner(nullptr); |
| 50 run_loop_.reset(new base::RunLoop); | 51 run_loop_.reset(new base::RunLoop); |
| 51 service_runner.Start( | 52 service_runner.Start( |
| 52 app_path_, shell_handle_.Pass(), | 53 app_path_, mojo::shell::DynamicServiceRunner::DontDeleteAppPath, |
| 54 shell_handle_.Pass(), |
| 53 base::Bind(&Launcher::OnAppCompleted, base::Unretained(this))); | 55 base::Bind(&Launcher::OnAppCompleted, base::Unretained(this))); |
| 54 run_loop_->Run(); | 56 run_loop_->Run(); |
| 55 run_loop_.reset(); | 57 run_loop_.reset(); |
| 56 } | 58 } |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 void OnRegistered(mojo::ShellPtr shell) { | 61 void OnRegistered(mojo::ShellPtr shell) { |
| 60 shell_handle_ = shell.PassMessagePipe(); | 62 shell_handle_ = shell.PassMessagePipe(); |
| 61 run_loop_->Quit(); | 63 run_loop_->Quit(); |
| 62 } | 64 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 93 | 95 |
| 94 if (!launcher.Register()) { | 96 if (!launcher.Register()) { |
| 95 LOG(ERROR) << "Error registering " | 97 LOG(ERROR) << "Error registering " |
| 96 << command_line->GetSwitchValueASCII(kAppURL); | 98 << command_line->GetSwitchValueASCII(kAppURL); |
| 97 return MOJO_RESULT_INVALID_ARGUMENT; | 99 return MOJO_RESULT_INVALID_ARGUMENT; |
| 98 } | 100 } |
| 99 | 101 |
| 100 launcher.Run(); | 102 launcher.Run(); |
| 101 return MOJO_RESULT_OK; | 103 return MOJO_RESULT_OK; |
| 102 } | 104 } |
| OLD | NEW |