Chromium Code Reviews| Index: mojo/shell/standalone/context.cc |
| diff --git a/mojo/shell/standalone/context.cc b/mojo/shell/standalone/context.cc |
| index 589e7db4850d30dc8f1e8ee4784b5f06d55ad3c8..77a0ab449b868f50baf427f5ae8493a8f2192694 100644 |
| --- a/mojo/shell/standalone/context.cc |
| +++ b/mojo/shell/standalone/context.cc |
| @@ -89,6 +89,11 @@ scoped_ptr<base::Thread> CreateIOThread(const char* name) { |
| return thread; |
| } |
| +void OnInstanceQuit(const GURL& url, const Identity& identity) { |
| + if (url == identity.url()) |
| + base::MessageLoop::current()->QuitWhenIdle(); |
|
sky
2016/02/19 05:20:51
Ick, quitting arbitrary messageloop is error prone
|
| +} |
| + |
| } // namespace |
| Context::Context() |
| @@ -142,7 +147,7 @@ void Context::Init(const base::FilePath& shell_file_root) { |
| new OutOfProcessNativeRunnerFactory(blocking_pool_.get())); |
| } |
| application_manager_.reset(new ApplicationManager( |
| - std::move(runner_factory), blocking_pool_.get(), true)); |
| + std::move(runner_factory), blocking_pool_.get(), true)); |
| shell::mojom::InterfaceProviderPtr tracing_remote_interfaces; |
| shell::mojom::InterfaceProviderPtr tracing_local_interfaces; |
| @@ -201,50 +206,31 @@ void Context::OnShutdownComplete() { |
| base::MessageLoop::current()->QuitWhenIdle(); |
| } |
| -void Context::Run(const GURL& url) { |
| - DCHECK(app_complete_callback_.is_null()); |
| - shell::mojom::InterfaceProviderPtr remote_interfaces; |
| - shell::mojom::InterfaceProviderPtr local_interfaces; |
| - |
| - app_urls_.insert(url); |
| - |
| - scoped_ptr<ConnectParams> params(new ConnectParams); |
| - params->set_target( |
| - Identity(url, std::string(), GetPermissiveCapabilityFilter())); |
| - params->set_remote_interfaces(GetProxy(&remote_interfaces)); |
| - params->set_local_interfaces(std::move(local_interfaces)); |
| - params->set_on_application_end( |
| - base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); |
| - application_manager_->Connect(std::move(params)); |
| -} |
| - |
| -void Context::RunCommandLineApplication(const base::Closure& callback) { |
| - DCHECK(app_urls_.empty()); |
| - DCHECK(app_complete_callback_.is_null()); |
| +void Context::RunCommandLineApplication() { |
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| base::CommandLine::StringVector args = command_line->GetArgs(); |
| for (size_t i = 0; i < args.size(); ++i) { |
| GURL possible_app(args[i]); |
| if (possible_app.SchemeIs("mojo")) { |
| Run(possible_app); |
| - app_complete_callback_ = callback; |
| break; |
| } |
| } |
| } |
| -void Context::OnApplicationEnd(const GURL& url) { |
| - if (app_urls_.find(url) != app_urls_.end()) { |
| - app_urls_.erase(url); |
| - if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
| - DCHECK_EQ(base::MessageLoop::current()->task_runner(), shell_runner_); |
| - if (app_complete_callback_.is_null()) { |
| - base::MessageLoop::current()->QuitWhenIdle(); |
| - } else { |
| - app_complete_callback_.Run(); |
| - } |
| - } |
| - } |
| +void Context::Run(const GURL& url) { |
| + application_manager_->SetInstanceQuitCallback( |
|
sky
2016/02/19 05:20:51
If Run() is called multiple-times doesn't the new
|
| + base::Bind(&OnInstanceQuit, url)); |
| + |
| + shell::mojom::InterfaceProviderPtr remote_interfaces; |
| + shell::mojom::InterfaceProviderPtr local_interfaces; |
| + |
| + scoped_ptr<ConnectParams> params(new ConnectParams); |
| + params->set_target( |
| + Identity(url, std::string(), GetPermissiveCapabilityFilter())); |
| + params->set_remote_interfaces(GetProxy(&remote_interfaces)); |
| + params->set_local_interfaces(std::move(local_interfaces)); |
| + application_manager_->Connect(std::move(params)); |
| } |
| } // namespace shell |