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

Side by Side Diff: services/ui/launcher/launcher_app.cc

Issue 1980763002: ApplicationConnection devolution, part 2.3. (Closed) Base URL: https://github.com/domokit/mojo.git@work794_app_conn_devo_2.2
Patch Set: Created 4 years, 7 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
« no previous file with comments | « services/ui/launcher/launcher_app.h ('k') | services/ui/view_manager/view_manager_app.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
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::ApplicationConnection* connection) {
41 // Only present the launcher interface to the shell. 41 // Only present the launcher interface to the shell.
42 if (connection->GetServiceProviderImpl() 42 if (connection->GetServiceProviderImpl()
43 .connection_context() 43 .connection_context()
44 .remote_url.empty()) { 44 .remote_url.empty()) {
45 connection->AddService<Launcher>(this); 45 connection->GetServiceProviderImpl().AddService<Launcher>(
46 [this](const mojo::ConnectionContext& connection_context,
47 mojo::InterfaceRequest<Launcher> launcher_request) {
48 bindings_.AddBinding(this, launcher_request.Pass());
49 });
46 } 50 }
47 return true; 51 return true;
48 } 52 }
49 53
50 void LauncherApp::Create(const mojo::ConnectionContext& connection_context,
51 mojo::InterfaceRequest<Launcher> request) {
52 bindings_.AddBinding(this, request.Pass());
53 }
54
55 void LauncherApp::Launch(const mojo::String& application_url) { 54 void LauncherApp::Launch(const mojo::String& application_url) {
56 uint32_t next_id = next_id_++; 55 uint32_t next_id = next_id_++;
57 std::unique_ptr<LaunchInstance> instance(new LaunchInstance( 56 std::unique_ptr<LaunchInstance> instance(new LaunchInstance(
58 app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination, 57 app_impl_, application_url, base::Bind(&LauncherApp::OnLaunchTermination,
59 base::Unretained(this), next_id))); 58 base::Unretained(this), next_id)));
60 instance->Launch(); 59 instance->Launch();
61 launch_instances_.emplace(next_id, std::move(instance)); 60 launch_instances_.emplace(next_id, std::move(instance));
62 } 61 }
63 62
64 void LauncherApp::OnLaunchTermination(uint32_t id) { 63 void LauncherApp::OnLaunchTermination(uint32_t id) {
65 launch_instances_.erase(id); 64 launch_instances_.erase(id);
66 if (launch_instances_.empty()) { 65 if (launch_instances_.empty()) {
67 app_impl_->Terminate(); 66 app_impl_->Terminate();
68 } 67 }
69 } 68 }
70 69
71 } // namespace launcher 70 } // namespace launcher
OLDNEW
« no previous file with comments | « services/ui/launcher/launcher_app.h ('k') | services/ui/view_manager/view_manager_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698