| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Mojo isn't supported on all child process types. | 254 // Mojo isn't supported on all child process types. |
| 255 // TODO(crbug.com/604282): Support Mojo in the remaining processes. | 255 // TODO(crbug.com/604282): Support Mojo in the remaining processes. |
| 256 if (!platform_channel.is_valid()) | 256 if (!platform_channel.is_valid()) |
| 257 return; | 257 return; |
| 258 mojo::edk::SetParentPipeHandle(std::move(platform_channel)); | 258 mojo::edk::SetParentPipeHandle(std::move(platform_channel)); |
| 259 } | 259 } |
| 260 | 260 |
| 261 class ChannelBootstrapFilter : public ConnectionFilter { | 261 class ChannelBootstrapFilter : public ConnectionFilter { |
| 262 public: | 262 public: |
| 263 explicit ChannelBootstrapFilter(IPC::mojom::ChannelBootstrapPtrInfo bootstrap) | 263 explicit ChannelBootstrapFilter(IPC::mojom::ChannelBootstrapPtrInfo bootstrap) |
| 264 : bootstrap_(std::move(bootstrap)), weak_factory_(this) {} | 264 : bootstrap_(std::move(bootstrap)) {} |
| 265 | 265 |
| 266 private: | 266 private: |
| 267 // ConnectionFilter: | 267 // ConnectionFilter: |
| 268 bool OnConnect(const service_manager::Identity& remote_identity, | 268 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
| 269 service_manager::InterfaceRegistry* registry, | 269 const std::string& interface_name, |
| 270 service_manager::Connector* connector) override { | 270 mojo::ScopedMessagePipeHandle* interface_pipe, |
| 271 if (remote_identity.name() != mojom::kBrowserServiceName) | 271 service_manager::Connector* connector) override { |
| 272 return false; | 272 if (source_info.identity.name() != mojom::kBrowserServiceName) |
| 273 return; |
| 273 | 274 |
| 274 registry->AddInterface(base::Bind(&ChannelBootstrapFilter::CreateBootstrap, | 275 if (interface_name == IPC::mojom::ChannelBootstrap::Name_) { |
| 275 weak_factory_.GetWeakPtr())); | 276 DCHECK(bootstrap_.is_valid()); |
| 276 return true; | 277 mojo::FuseInterface(mojo::MakeRequest<IPC::mojom::ChannelBootstrap>( |
| 277 } | 278 std::move(*interface_pipe)), |
| 278 | 279 std::move(bootstrap_)); |
| 279 void CreateBootstrap(IPC::mojom::ChannelBootstrapRequest request) { | 280 } |
| 280 DCHECK(bootstrap_.is_valid()); | |
| 281 mojo::FuseInterface(std::move(request), std::move(bootstrap_)); | |
| 282 } | 281 } |
| 283 | 282 |
| 284 IPC::mojom::ChannelBootstrapPtrInfo bootstrap_; | 283 IPC::mojom::ChannelBootstrapPtrInfo bootstrap_; |
| 285 base::WeakPtrFactory<ChannelBootstrapFilter> weak_factory_; | |
| 286 | 284 |
| 287 DISALLOW_COPY_AND_ASSIGN(ChannelBootstrapFilter); | 285 DISALLOW_COPY_AND_ASSIGN(ChannelBootstrapFilter); |
| 288 }; | 286 }; |
| 289 | 287 |
| 290 } // namespace | 288 } // namespace |
| 291 | 289 |
| 292 ChildThread* ChildThread::Get() { | 290 ChildThread* ChildThread::Get() { |
| 293 return ChildThreadImpl::current(); | 291 return ChildThreadImpl::current(); |
| 294 } | 292 } |
| 295 | 293 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 service_request_token = options.in_process_service_request_token; | 442 service_request_token = options.in_process_service_request_token; |
| 445 } | 443 } |
| 446 if (!service_request_token.empty()) { | 444 if (!service_request_token.empty()) { |
| 447 mojo::ScopedMessagePipeHandle handle = | 445 mojo::ScopedMessagePipeHandle handle = |
| 448 mojo::edk::CreateChildMessagePipe(service_request_token); | 446 mojo::edk::CreateChildMessagePipe(service_request_token); |
| 449 DCHECK(handle.is_valid()); | 447 DCHECK(handle.is_valid()); |
| 450 service_manager_connection_ = ServiceManagerConnection::Create( | 448 service_manager_connection_ = ServiceManagerConnection::Create( |
| 451 mojo::MakeRequest<service_manager::mojom::Service>(std::move(handle)), | 449 mojo::MakeRequest<service_manager::mojom::Service>(std::move(handle)), |
| 452 GetIOTaskRunner()); | 450 GetIOTaskRunner()); |
| 453 | 451 |
| 454 // When connect_to_browser is true, we obtain interfaces from the browser | |
| 455 // process by connecting to it, rather than from the incoming interface | |
| 456 // provider. Exposed interfaces are subject to manifest capability spec. | |
| 457 if (options.connect_to_browser) { | |
| 458 browser_connection_ = | |
| 459 service_manager_connection_->GetConnector()->Connect( | |
| 460 mojom::kBrowserServiceName); | |
| 461 } | |
| 462 | |
| 463 // TODO(rockot): Remove this once all child-to-browser interface connections | 452 // TODO(rockot): Remove this once all child-to-browser interface connections |
| 464 // are made via a Connector rather than directly through an | 453 // are made via a Connector rather than directly through an |
| 465 // InterfaceProvider, and all exposed interfaces are exposed via a | 454 // InterfaceProvider, and all exposed interfaces are exposed via a |
| 466 // ConnectionFilter. | 455 // ConnectionFilter. |
| 467 service_manager_connection_->SetupInterfaceRequestProxies( | 456 service_manager_connection_->SetupInterfaceRequestProxies( |
| 468 GetInterfaceRegistry(), nullptr); | 457 GetInterfaceRegistry(), nullptr); |
| 469 } | 458 } |
| 470 | 459 |
| 471 sync_message_filter_ = channel_->CreateSyncMessageFilter(); | 460 sync_message_filter_ = channel_->CreateSyncMessageFilter(); |
| 472 thread_safe_sender_ = new ThreadSafeSender( | 461 thread_safe_sender_ = new ThreadSafeSender( |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 connected_to_browser_ = true; | 864 connected_to_browser_ = true; |
| 876 child_info_ = local_info; | 865 child_info_ = local_info; |
| 877 browser_info_ = remote_info; | 866 browser_info_ = remote_info; |
| 878 } | 867 } |
| 879 | 868 |
| 880 bool ChildThreadImpl::IsInBrowserProcess() const { | 869 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 881 return static_cast<bool>(browser_process_io_runner_); | 870 return static_cast<bool>(browser_process_io_runner_); |
| 882 } | 871 } |
| 883 | 872 |
| 884 } // namespace content | 873 } // namespace content |
| OLD | NEW |