| 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 "content/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 public: | 151 public: |
| 152 Proxy(MojoShellContext* shell_context) | 152 Proxy(MojoShellContext* shell_context) |
| 153 : shell_context_(shell_context), | 153 : shell_context_(shell_context), |
| 154 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 154 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
| 155 | 155 |
| 156 ~Proxy() {} | 156 ~Proxy() {} |
| 157 | 157 |
| 158 void ConnectToApplication( | 158 void ConnectToApplication( |
| 159 const GURL& url, | 159 const GURL& url, |
| 160 const GURL& requestor_url, | 160 const GURL& requestor_url, |
| 161 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 161 mojo::InterfaceRequest<mojo::InterfaceProvider> request, |
| 162 mojo::ServiceProviderPtr exposed_services, | 162 mojo::InterfaceProviderPtr exposed_services, |
| 163 const mojo::shell::CapabilityFilter& filter, | 163 const mojo::shell::CapabilityFilter& filter, |
| 164 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { | 164 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { |
| 165 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { | 165 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { |
| 166 if (shell_context_) { | 166 if (shell_context_) { |
| 167 shell_context_->ConnectToApplicationOnOwnThread( | 167 shell_context_->ConnectToApplicationOnOwnThread( |
| 168 url, requestor_url, std::move(request), std::move(exposed_services), | 168 url, requestor_url, std::move(request), std::move(exposed_services), |
| 169 filter, callback); | 169 filter, callback); |
| 170 } | 170 } |
| 171 } else { | 171 } else { |
| 172 // |shell_context_| outlives the main MessageLoop, so it's safe for it to | 172 // |shell_context_| outlives the main MessageLoop, so it's safe for it to |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 #endif | 253 #endif |
| 254 } | 254 } |
| 255 | 255 |
| 256 MojoShellContext::~MojoShellContext() { | 256 MojoShellContext::~MojoShellContext() { |
| 257 } | 257 } |
| 258 | 258 |
| 259 // static | 259 // static |
| 260 void MojoShellContext::ConnectToApplication( | 260 void MojoShellContext::ConnectToApplication( |
| 261 const GURL& url, | 261 const GURL& url, |
| 262 const GURL& requestor_url, | 262 const GURL& requestor_url, |
| 263 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 263 mojo::InterfaceRequest<mojo::InterfaceProvider> request, |
| 264 mojo::ServiceProviderPtr exposed_services, | 264 mojo::InterfaceProviderPtr exposed_services, |
| 265 const mojo::shell::CapabilityFilter& filter, | 265 const mojo::shell::CapabilityFilter& filter, |
| 266 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { | 266 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { |
| 267 proxy_.Get()->ConnectToApplication(url, requestor_url, std::move(request), | 267 proxy_.Get()->ConnectToApplication(url, requestor_url, std::move(request), |
| 268 std::move(exposed_services), filter, | 268 std::move(exposed_services), filter, |
| 269 callback); | 269 callback); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void MojoShellContext::ConnectToApplicationOnOwnThread( | 272 void MojoShellContext::ConnectToApplicationOnOwnThread( |
| 273 const GURL& url, | 273 const GURL& url, |
| 274 const GURL& requestor_url, | 274 const GURL& requestor_url, |
| 275 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 275 mojo::InterfaceRequest<mojo::InterfaceProvider> request, |
| 276 mojo::ServiceProviderPtr exposed_services, | 276 mojo::InterfaceProviderPtr exposed_services, |
| 277 const mojo::shell::CapabilityFilter& filter, | 277 const mojo::shell::CapabilityFilter& filter, |
| 278 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { | 278 const mojo::shell::mojom::Shell::ConnectToApplicationCallback& callback) { |
| 279 scoped_ptr<mojo::shell::ConnectToApplicationParams> params( | 279 scoped_ptr<mojo::shell::ConnectToApplicationParams> params( |
| 280 new mojo::shell::ConnectToApplicationParams); | 280 new mojo::shell::ConnectToApplicationParams); |
| 281 params->set_source( | 281 params->set_source( |
| 282 mojo::shell::Identity(requestor_url, std::string(), | 282 mojo::shell::Identity(requestor_url, std::string(), |
| 283 mojo::shell::GetPermissiveCapabilityFilter())); | 283 mojo::shell::GetPermissiveCapabilityFilter())); |
| 284 params->SetTarget(mojo::shell::Identity(url, std::string(), filter)); | 284 params->SetTarget(mojo::shell::Identity(url, std::string(), filter)); |
| 285 params->set_services(std::move(request)); | 285 params->set_remote_interfaces(std::move(request)); |
| 286 params->set_exposed_services(std::move(exposed_services)); | 286 params->set_local_interfaces(std::move(exposed_services)); |
| 287 params->set_on_application_end(base::Bind(&base::DoNothing)); | 287 params->set_on_application_end(base::Bind(&base::DoNothing)); |
| 288 params->set_connect_callback(callback); | 288 params->set_connect_callback(callback); |
| 289 application_manager_->ConnectToApplication(std::move(params)); | 289 application_manager_->ConnectToApplication(std::move(params)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace content | 292 } // namespace content |
| OLD | NEW |