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

Side by Side Diff: mojo/shell/public/cpp/lib/application_impl.cc

Issue 1679573002: Move shell interfaces into the shell.mojom namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 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
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/converters/network/network_type_converters.h" 10 #include "mojo/converters/network/network_type_converters.h"
(...skipping 11 matching lines...) Expand all
22 if (base::MessageLoop::current() && 22 if (base::MessageLoop::current() &&
23 base::MessageLoop::current()->is_running()) 23 base::MessageLoop::current()->is_running())
24 base::MessageLoop::current()->QuitWhenIdle(); 24 base::MessageLoop::current()->QuitWhenIdle();
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 ApplicationImpl::ConnectParams::ConnectParams(const std::string& url) 29 ApplicationImpl::ConnectParams::ConnectParams(const std::string& url)
30 : ConnectParams(URLRequest::From(url)) {} 30 : ConnectParams(URLRequest::From(url)) {}
31 ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request) 31 ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request)
32 : request_(std::move(request)), filter_(CapabilityFilter::New()) { 32 : request_(std::move(request)),
33 filter_(shell::mojom::CapabilityFilter::New()) {
33 filter_->filter.mark_non_null(); 34 filter_->filter.mark_non_null();
34 } 35 }
35 ApplicationImpl::ConnectParams::~ConnectParams() {} 36 ApplicationImpl::ConnectParams::~ConnectParams() {}
36 37
37 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 38 ApplicationImpl::ApplicationImpl(
38 InterfaceRequest<Application> request) 39 ApplicationDelegate* delegate,
40 InterfaceRequest<shell::mojom::Application> request)
39 : ApplicationImpl(delegate, 41 : ApplicationImpl(delegate,
40 std::move(request), 42 std::move(request),
41 base::Bind(&DefaultTerminationClosure)) {} 43 base::Bind(&DefaultTerminationClosure)) {}
42 44
43 ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate, 45 ApplicationImpl::ApplicationImpl(
44 InterfaceRequest<Application> request, 46 ApplicationDelegate* delegate,
45 const Closure& termination_closure) 47 InterfaceRequest<shell::mojom::Application> request,
48 const Closure& termination_closure)
46 : delegate_(delegate), 49 : delegate_(delegate),
47 binding_(this, std::move(request)), 50 binding_(this, std::move(request)),
48 id_(Shell::kInvalidApplicationID), 51 id_(shell::mojom::Shell::kInvalidApplicationID),
49 termination_closure_(termination_closure), 52 termination_closure_(termination_closure),
50 app_lifetime_helper_(this), 53 app_lifetime_helper_(this),
51 quit_requested_(false), 54 quit_requested_(false),
52 weak_factory_(this) {} 55 weak_factory_(this) {}
53 56
54 ApplicationImpl::~ApplicationImpl() { 57 ApplicationImpl::~ApplicationImpl() {
55 app_lifetime_helper_.OnQuit(); 58 app_lifetime_helper_.OnQuit();
56 } 59 }
57 60
58 scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication( 61 scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication(
(...skipping 15 matching lines...) Expand all
74 std::string application_url = request->url.To<std::string>(); 77 std::string application_url = request->url.To<std::string>();
75 // We allow all interfaces on outgoing connections since we are presumably in 78 // We allow all interfaces on outgoing connections since we are presumably in
76 // a position to know who we're talking to. 79 // a position to know who we're talking to.
77 // TODO(beng): is this a valid assumption or do we need to figure some way to 80 // TODO(beng): is this a valid assumption or do we need to figure some way to
78 // filter here too? 81 // filter here too?
79 std::set<std::string> allowed; 82 std::set<std::string> allowed;
80 allowed.insert("*"); 83 allowed.insert("*");
81 InterfaceRequest<ServiceProvider> remote_services_proxy = 84 InterfaceRequest<ServiceProvider> remote_services_proxy =
82 GetProxy(&remote_services); 85 GetProxy(&remote_services);
83 scoped_ptr<internal::ServiceRegistry> registry(new internal::ServiceRegistry( 86 scoped_ptr<internal::ServiceRegistry> registry(new internal::ServiceRegistry(
84 application_url, application_url, Shell::kInvalidApplicationID, 87 application_url, application_url,
85 std::move(remote_services), std::move(local_request), allowed)); 88 shell::mojom::Shell::kInvalidApplicationID, std::move(remote_services),
89 std::move(local_request), allowed));
86 shell_->ConnectToApplication(std::move(request), 90 shell_->ConnectToApplication(std::move(request),
87 std::move(remote_services_proxy), 91 std::move(remote_services_proxy),
88 std::move(local_services), params->TakeFilter(), 92 std::move(local_services), params->TakeFilter(),
89 registry->GetConnectToApplicationCallback()); 93 registry->GetConnectToApplicationCallback());
90 return std::move(registry); 94 return std::move(registry);
91 } 95 }
92 96
93 void ApplicationImpl::WaitForInitialize() { 97 void ApplicationImpl::WaitForInitialize() {
94 DCHECK(!shell_.is_bound()); 98 DCHECK(!shell_.is_bound());
95 binding_.WaitForIncomingMethodCall(); 99 binding_.WaitForIncomingMethodCall();
96 } 100 }
97 101
98 void ApplicationImpl::Quit() { 102 void ApplicationImpl::Quit() {
99 // We can't quit immediately, since there could be in-flight requests from the 103 // We can't quit immediately, since there could be in-flight requests from the
100 // shell. So check with it first. 104 // shell. So check with it first.
101 if (shell_) { 105 if (shell_) {
102 quit_requested_ = true; 106 quit_requested_ = true;
103 shell_->QuitApplication(); 107 shell_->QuitApplication();
104 } else { 108 } else {
105 QuitNow(); 109 QuitNow();
106 } 110 }
107 } 111 }
108 112
109 void ApplicationImpl::Initialize(ShellPtr shell, 113 void ApplicationImpl::Initialize(shell::mojom::ShellPtr shell,
110 const mojo::String& url, 114 const mojo::String& url,
111 uint32_t id) { 115 uint32_t id) {
112 shell_ = std::move(shell); 116 shell_ = std::move(shell);
113 shell_.set_connection_error_handler([this]() { OnConnectionError(); }); 117 shell_.set_connection_error_handler([this]() { OnConnectionError(); });
114 url_ = url; 118 url_ = url;
115 id_ = id; 119 id_ = id;
116 delegate_->Initialize(this); 120 delegate_->Initialize(this);
117 } 121 }
118 122
119 void ApplicationImpl::AcceptConnection( 123 void ApplicationImpl::AcceptConnection(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return; 164 return;
161 shell_ = nullptr; 165 shell_ = nullptr;
162 } 166 }
163 167
164 void ApplicationImpl::QuitNow() { 168 void ApplicationImpl::QuitNow() {
165 delegate_->Quit(); 169 delegate_->Quit();
166 termination_closure_.Run(); 170 termination_closure_.Run();
167 } 171 }
168 172
169 void ApplicationImpl::UnbindConnections( 173 void ApplicationImpl::UnbindConnections(
170 InterfaceRequest<Application>* application_request, 174 InterfaceRequest<shell::mojom::Application>* application_request,
171 ShellPtr* shell) { 175 shell::mojom::ShellPtr* shell) {
172 *application_request = binding_.Unbind(); 176 *application_request = binding_.Unbind();
173 shell->Bind(shell_.PassInterface()); 177 shell->Bind(shell_.PassInterface());
174 } 178 }
175 179
176 CapabilityFilterPtr CreatePermissiveCapabilityFilter() { 180 shell::mojom::CapabilityFilterPtr CreatePermissiveCapabilityFilter() {
177 CapabilityFilterPtr filter(CapabilityFilter::New()); 181 shell::mojom::CapabilityFilterPtr filter(
182 shell::mojom::CapabilityFilter::New());
178 Array<String> all_interfaces; 183 Array<String> all_interfaces;
179 all_interfaces.push_back("*"); 184 all_interfaces.push_back("*");
180 filter->filter.insert("*", std::move(all_interfaces)); 185 filter->filter.insert("*", std::move(all_interfaces));
181 return filter; 186 return filter;
182 } 187 }
183 188
184 } // namespace mojo 189 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/content_handler_factory.h ('k') | mojo/shell/public/cpp/lib/application_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698