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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 void ChildThreadImpl::RecordComputedAction(const std::string& action) { | 650 void ChildThreadImpl::RecordComputedAction(const std::string& action) { |
651 NOTREACHED(); | 651 NOTREACHED(); |
652 } | 652 } |
653 | 653 |
654 ServiceManagerConnection* ChildThreadImpl::GetServiceManagerConnection() { | 654 ServiceManagerConnection* ChildThreadImpl::GetServiceManagerConnection() { |
655 return service_manager_connection_.get(); | 655 return service_manager_connection_.get(); |
656 } | 656 } |
657 | 657 |
658 service_manager::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { | 658 service_manager::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { |
659 if (!interface_registry_.get()) { | 659 if (!interface_registry_.get()) { |
660 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( | 660 interface_registry_ = |
661 service_manager::Identity(), service_manager::InterfaceProviderSpec()); | 661 base::MakeUnique<service_manager::InterfaceRegistry>(); |
662 } | 662 } |
663 return interface_registry_.get(); | 663 return interface_registry_.get(); |
664 } | 664 } |
665 | 665 |
666 service_manager::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { | 666 service_manager::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { |
667 if (browser_connection_) | 667 if (browser_connection_) |
668 return browser_connection_->GetRemoteInterfaces(); | 668 return browser_connection_->GetRemoteInterfaces(); |
669 | 669 |
670 if (!remote_interfaces_.get()) | 670 if (!remote_interfaces_.get()) |
671 remote_interfaces_.reset(new service_manager::InterfaceProvider); | 671 remote_interfaces_.reset(new service_manager::InterfaceProvider); |
672 return remote_interfaces_.get(); | 672 return remote_interfaces_.get(); |
673 } | 673 } |
674 | 674 |
| 675 const service_manager::ServiceInfo& |
| 676 ChildThreadImpl::GetChildServiceInfo() const { |
| 677 return child_info_; |
| 678 } |
| 679 |
| 680 const service_manager::ServiceInfo& |
| 681 ChildThreadImpl::GetBrowserServiceInfo() const { |
| 682 return browser_info_; |
| 683 } |
| 684 |
675 IPC::MessageRouter* ChildThreadImpl::GetRouter() { | 685 IPC::MessageRouter* ChildThreadImpl::GetRouter() { |
676 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); | 686 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); |
677 return &router_; | 687 return &router_; |
678 } | 688 } |
679 | 689 |
680 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() { | 690 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() { |
681 if (!remote_route_provider_) { | 691 if (!remote_route_provider_) { |
682 DCHECK(channel_); | 692 DCHECK(channel_); |
683 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); | 693 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); |
684 } | 694 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 768 |
759 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 769 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
760 return OnControlMessageReceived(msg); | 770 return OnControlMessageReceived(msg); |
761 | 771 |
762 return router_.OnMessageReceived(msg); | 772 return router_.OnMessageReceived(msg); |
763 } | 773 } |
764 | 774 |
765 void ChildThreadImpl::StartServiceManagerConnection() { | 775 void ChildThreadImpl::StartServiceManagerConnection() { |
766 DCHECK(service_manager_connection_); | 776 DCHECK(service_manager_connection_); |
767 service_manager_connection_->Start(); | 777 service_manager_connection_->Start(); |
| 778 // We don't care about storing the id, since if this pipe closes we're toast. |
| 779 service_manager_connection_->AddOnConnectHandler( |
| 780 base::Bind(&ChildThreadImpl::OnConnect, weak_factory_.GetWeakPtr())); |
768 } | 781 } |
769 | 782 |
770 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 783 bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
771 return false; | 784 return false; |
772 } | 785 } |
773 | 786 |
774 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { | 787 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { |
775 // Set timer slack to maximum on main thread when in background. | 788 // Set timer slack to maximum on main thread when in background. |
776 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 789 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
777 if (backgrounded) | 790 if (backgrounded) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 void ChildThreadImpl::GetAssociatedInterface( | 874 void ChildThreadImpl::GetAssociatedInterface( |
862 const std::string& name, | 875 const std::string& name, |
863 mojom::AssociatedInterfaceAssociatedRequest request) { | 876 mojom::AssociatedInterfaceAssociatedRequest request) { |
864 int32_t routing_id = static_cast<int32_t>(reinterpret_cast<uintptr_t>( | 877 int32_t routing_id = static_cast<int32_t>(reinterpret_cast<uintptr_t>( |
865 associated_interface_provider_bindings_.dispatch_context())); | 878 associated_interface_provider_bindings_.dispatch_context())); |
866 Listener* route = router_.GetRoute(routing_id); | 879 Listener* route = router_.GetRoute(routing_id); |
867 if (route) | 880 if (route) |
868 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); | 881 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); |
869 } | 882 } |
870 | 883 |
| 884 void ChildThreadImpl::OnConnect( |
| 885 const service_manager::ServiceInfo& local_info, |
| 886 const service_manager::ServiceInfo& remote_info) { |
| 887 if (remote_info.identity.name() != kBrowserServiceName) |
| 888 return; |
| 889 child_info_ = local_info; |
| 890 browser_info_ = remote_info; |
| 891 } |
| 892 |
871 bool ChildThreadImpl::IsInBrowserProcess() const { | 893 bool ChildThreadImpl::IsInBrowserProcess() const { |
872 return static_cast<bool>(browser_process_io_runner_); | 894 return static_cast<bool>(browser_process_io_runner_); |
873 } | 895 } |
874 | 896 |
875 } // namespace content | 897 } // namespace content |
OLD | NEW |