| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/launcher/launcher_app.h" | 5 #include "services/ui/launcher/launcher_app.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/logging.h" | 8 #include "base/logging.h" | 
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" | 
| 10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 30 | 30 | 
| 31   tracing_.Initialize(app_impl_); | 31   tracing_.Initialize(app_impl_); | 
| 32   TRACE_EVENT0("launcher", __func__); | 32   TRACE_EVENT0("launcher", __func__); | 
| 33 | 33 | 
| 34   for (size_t i = 0; i < command_line->GetArgs().size(); ++i) { | 34   for (size_t i = 0; i < command_line->GetArgs().size(); ++i) { | 
| 35     Launch(command_line->GetArgs()[i]); | 35     Launch(command_line->GetArgs()[i]); | 
| 36   } | 36   } | 
| 37 } | 37 } | 
| 38 | 38 | 
| 39 bool LauncherApp::ConfigureIncomingConnection( | 39 bool LauncherApp::ConfigureIncomingConnection( | 
| 40     mojo::ApplicationConnection* connection) { | 40     mojo::ServiceProviderImpl* service_provider_impl) { | 
| 41   // Only present the launcher interface to the shell. | 41   // Only present the launcher interface to the shell. | 
| 42   if (connection->GetServiceProviderImpl() | 42   if (service_provider_impl->connection_context().remote_url.empty()) { | 
| 43           .connection_context() | 43     service_provider_impl->AddService<Launcher>( | 
| 44           .remote_url.empty()) { |  | 
| 45     connection->GetServiceProviderImpl().AddService<Launcher>( |  | 
| 46         [this](const mojo::ConnectionContext& connection_context, | 44         [this](const mojo::ConnectionContext& connection_context, | 
| 47                mojo::InterfaceRequest<Launcher> launcher_request) { | 45                mojo::InterfaceRequest<Launcher> launcher_request) { | 
| 48           bindings_.AddBinding(this, launcher_request.Pass()); | 46           bindings_.AddBinding(this, launcher_request.Pass()); | 
| 49         }); | 47         }); | 
| 50   } | 48   } | 
| 51   return true; | 49   return true; | 
| 52 } | 50 } | 
| 53 | 51 | 
| 54 void LauncherApp::Launch(const mojo::String& application_url) { | 52 void LauncherApp::Launch(const mojo::String& application_url) { | 
| 55   uint32_t next_id = next_id_++; | 53   uint32_t next_id = next_id_++; | 
| 56   std::unique_ptr<LaunchInstance> instance(new LaunchInstance( | 54   std::unique_ptr<LaunchInstance> instance(new LaunchInstance( | 
| 57       app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination, | 55       app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination, | 
| 58                                              base::Unretained(this), next_id))); | 56                                              base::Unretained(this), next_id))); | 
| 59   instance->Launch(); | 57   instance->Launch(); | 
| 60   launch_instances_.emplace(next_id, std::move(instance)); | 58   launch_instances_.emplace(next_id, std::move(instance)); | 
| 61 } | 59 } | 
| 62 | 60 | 
| 63 void LauncherApp::OnLaunchTermination(uint32_t id) { | 61 void LauncherApp::OnLaunchTermination(uint32_t id) { | 
| 64   launch_instances_.erase(id); | 62   launch_instances_.erase(id); | 
| 65   if (launch_instances_.empty()) { | 63   if (launch_instances_.empty()) { | 
| 66     app_impl_->Terminate(); | 64     app_impl_->Terminate(); | 
| 67   } | 65   } | 
| 68 } | 66 } | 
| 69 | 67 | 
| 70 }  // namespace launcher | 68 }  // namespace launcher | 
| OLD | NEW | 
|---|