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

Side by Side Diff: shell/application_manager/shell_impl.cc

Issue 1450223002: Add an ApplicationConnector.Duplicate(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « shell/application_manager/shell_impl.h ('k') | shell/shell_apptest.cc » ('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 "shell/application_manager/shell_impl.h" 5 #include "shell/application_manager/shell_impl.h"
6 6
7 #include <utility>
8
7 #include "mojo/converters/url/url_type_converters.h" 9 #include "mojo/converters/url/url_type_converters.h"
8 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h" 10 #include "mojo/services/content_handler/interfaces/content_handler.mojom.h"
9 #include "shell/application_manager/application_manager.h" 11 #include "shell/application_manager/application_manager.h"
10 12
13 using mojo::ApplicationConnector;
14 using mojo::ApplicationPtr;
15 using mojo::Array;
16 using mojo::InterfaceRequest;
11 using mojo::ServiceProvider; 17 using mojo::ServiceProvider;
12 using mojo::ServiceProviderPtr; 18 using mojo::ServiceProviderPtr;
19 using mojo::Shell;
20 using mojo::ShellPtr;
21 using mojo::String;
13 22
14 namespace shell { 23 namespace shell {
15 24
16 ShellImpl::ShellImpl(mojo::ApplicationPtr application, 25 // ShellImpl::ApplicationConnectorImpl -----------------------------------------
26
27 ShellImpl::ApplicationConnectorImpl::ApplicationConnectorImpl(Shell* shell)
28 : shell_(shell) {}
29
30 ShellImpl::ApplicationConnectorImpl::~ApplicationConnectorImpl() {}
31
32 void ShellImpl::ApplicationConnectorImpl::ConnectToApplication(
33 const String& app_url,
34 InterfaceRequest<ServiceProvider> services,
35 ServiceProviderPtr exposed_services) {
36 shell_->ConnectToApplication(app_url, std::move(services),
37 std::move(exposed_services));
38 }
39
40 void ShellImpl::ApplicationConnectorImpl::Duplicate(
41 InterfaceRequest<ApplicationConnector> application_connector_request) {
42 bindings_.AddBinding(this, std::move(application_connector_request));
43 }
44
45 // ShellImpl -------------------------------------------------------------------
46
47 ShellImpl::ShellImpl(ApplicationPtr application,
17 ApplicationManager* manager, 48 ApplicationManager* manager,
18 const Identity& identity, 49 const Identity& identity,
19 const base::Closure& on_application_end) 50 const base::Closure& on_application_end)
20 : manager_(manager), 51 : manager_(manager),
21 identity_(identity), 52 identity_(identity),
22 on_application_end_(on_application_end), 53 on_application_end_(on_application_end),
23 application_(application.Pass()), 54 application_(std::move(application)),
24 binding_(this), 55 binding_(this),
25 application_connector_impl_(this) { 56 application_connector_impl_(this) {
26 binding_.set_connection_error_handler( 57 binding_.set_connection_error_handler(
27 [this]() { manager_->OnShellImplError(this); }); 58 [this]() { manager_->OnShellImplError(this); });
28 } 59 }
29 60
30 ShellImpl::~ShellImpl() { 61 ShellImpl::~ShellImpl() {
31 } 62 }
32 63
33 void ShellImpl::InitializeApplication(mojo::Array<mojo::String> args) { 64 void ShellImpl::InitializeApplication(Array<String> args) {
34 mojo::ShellPtr shell; 65 ShellPtr shell;
35 binding_.Bind(mojo::GetProxy(&shell)); 66 binding_.Bind(GetProxy(&shell));
36 application_->Initialize(shell.Pass(), args.Pass(), identity_.url.spec()); 67 application_->Initialize(std::move(shell), std::move(args),
68 identity_.url.spec());
37 } 69 }
38 70
39 void ShellImpl::ConnectToClient( 71 void ShellImpl::ConnectToClient(const GURL& requested_url,
40 const GURL& requested_url, 72 const GURL& requestor_url,
41 const GURL& requestor_url, 73 InterfaceRequest<ServiceProvider> services,
42 mojo::InterfaceRequest<ServiceProvider> services, 74 ServiceProviderPtr exposed_services) {
43 ServiceProviderPtr exposed_services) { 75 application_->AcceptConnection(
44 application_->AcceptConnection(mojo::String::From(requestor_url), 76 String::From(requestor_url), std::move(services),
45 services.Pass(), exposed_services.Pass(), 77 std::move(exposed_services), requested_url.spec());
46 requested_url.spec());
47 } 78 }
48 79
49 void ShellImpl::ConnectToApplication( 80 void ShellImpl::ConnectToApplication(const String& app_url,
50 const mojo::String& app_url, 81 InterfaceRequest<ServiceProvider> services,
51 mojo::InterfaceRequest<ServiceProvider> services, 82 ServiceProviderPtr exposed_services) {
52 ServiceProviderPtr exposed_services) {
53 GURL app_gurl(app_url); 83 GURL app_gurl(app_url);
54 if (!app_gurl.is_valid()) { 84 if (!app_gurl.is_valid()) {
55 LOG(ERROR) << "Error: invalid URL: " << app_url; 85 LOG(ERROR) << "Error: invalid URL: " << app_url;
56 return; 86 return;
57 } 87 }
58 manager_->ConnectToApplication(app_gurl, identity_.url, services.Pass(), 88 manager_->ConnectToApplication(app_gurl, identity_.url, std::move(services),
59 exposed_services.Pass(), base::Closure()); 89 std::move(exposed_services), base::Closure());
60 } 90 }
61 91
62 void ShellImpl::CreateApplicationConnector( 92 void ShellImpl::CreateApplicationConnector(
63 mojo::InterfaceRequest<mojo::ApplicationConnector> 93 InterfaceRequest<ApplicationConnector> application_connector_request) {
64 application_connector_request) { 94 application_connector_impl_.Duplicate(
65 application_connectors_.AddBinding(&application_connector_impl_, 95 std::move(application_connector_request));
66 application_connector_request.Pass());
67 } 96 }
68 97
69 } // namespace shell 98 } // namespace shell
OLDNEW
« no previous file with comments | « shell/application_manager/shell_impl.h ('k') | shell/shell_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698