| OLD | NEW |
| 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 "ipc/ipc_mojo_bootstrap.h" | 5 #include "ipc/ipc_mojo_bootstrap.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 endpoint_client_.reset(); | 584 endpoint_client_.reset(); |
| 585 if (controller_) | 585 if (controller_) |
| 586 controller_->ShutDown(); | 586 controller_->ShutDown(); |
| 587 } | 587 } |
| 588 | 588 |
| 589 void set_connection_error_handler(const base::Closure& handler) { | 589 void set_connection_error_handler(const base::Closure& handler) { |
| 590 DCHECK(endpoint_client_); | 590 DCHECK(endpoint_client_); |
| 591 endpoint_client_->set_connection_error_handler(handler); | 591 endpoint_client_->set_connection_error_handler(handler); |
| 592 } | 592 } |
| 593 | 593 |
| 594 mojo::AssociatedGroup* associated_group() { |
| 595 DCHECK(controller_); |
| 596 return controller_->associated_group(); |
| 597 } |
| 598 |
| 594 void Bind(mojo::ScopedMessagePipeHandle handle) { | 599 void Bind(mojo::ScopedMessagePipeHandle handle) { |
| 595 DCHECK(!controller_); | 600 DCHECK(!controller_); |
| 596 controller_ = | 601 controller_ = |
| 597 new ChannelAssociatedGroupController(false, std::move(handle)); | 602 new ChannelAssociatedGroupController(false, std::move(handle)); |
| 598 stub_.serialization_context()->group_controller = controller_; | 603 stub_.serialization_context()->group_controller = controller_; |
| 599 | 604 |
| 600 endpoint_client_.reset(new mojo::InterfaceEndpointClient( | 605 endpoint_client_.reset(new mojo::InterfaceEndpointClient( |
| 601 controller_->CreateLocalEndpointHandle(mojo::kMasterInterfaceId), | 606 controller_->CreateLocalEndpointHandle(mojo::kMasterInterfaceId), |
| 602 &stub_, | 607 &stub_, |
| 603 base::MakeUnique<typename mojom::Bootstrap::RequestValidator_>(), | 608 base::MakeUnique<typename mojom::Bootstrap::RequestValidator_>(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 614 | 619 |
| 615 // MojoBootstrap for the server process. You should create the instance | 620 // MojoBootstrap for the server process. You should create the instance |
| 616 // using MojoBootstrap::Create(). | 621 // using MojoBootstrap::Create(). |
| 617 class MojoServerBootstrap : public MojoBootstrap { | 622 class MojoServerBootstrap : public MojoBootstrap { |
| 618 public: | 623 public: |
| 619 MojoServerBootstrap(); | 624 MojoServerBootstrap(); |
| 620 | 625 |
| 621 private: | 626 private: |
| 622 // MojoBootstrap implementation. | 627 // MojoBootstrap implementation. |
| 623 void Connect() override; | 628 void Connect() override; |
| 629 mojo::AssociatedGroup* GetAssociatedGroup() override { |
| 630 return bootstrap_.associated_group(); |
| 631 } |
| 624 | 632 |
| 625 void OnInitDone(int32_t peer_pid); | 633 void OnInitDone(int32_t peer_pid); |
| 626 | 634 |
| 627 BootstrapMasterProxy bootstrap_; | 635 BootstrapMasterProxy bootstrap_; |
| 628 IPC::mojom::ChannelAssociatedPtrInfo send_channel_; | 636 IPC::mojom::ChannelAssociatedPtrInfo send_channel_; |
| 629 IPC::mojom::ChannelAssociatedRequest receive_channel_request_; | 637 IPC::mojom::ChannelAssociatedRequest receive_channel_request_; |
| 630 | 638 |
| 631 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap); | 639 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap); |
| 632 }; | 640 }; |
| 633 | 641 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 681 |
| 674 // MojoBootstrap for client processes. You should create the instance | 682 // MojoBootstrap for client processes. You should create the instance |
| 675 // using MojoBootstrap::Create(). | 683 // using MojoBootstrap::Create(). |
| 676 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap { | 684 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap { |
| 677 public: | 685 public: |
| 678 MojoClientBootstrap(); | 686 MojoClientBootstrap(); |
| 679 | 687 |
| 680 private: | 688 private: |
| 681 // MojoBootstrap implementation. | 689 // MojoBootstrap implementation. |
| 682 void Connect() override; | 690 void Connect() override; |
| 691 mojo::AssociatedGroup* GetAssociatedGroup() override { |
| 692 return binding_.associated_group(); |
| 693 } |
| 683 | 694 |
| 684 // mojom::Bootstrap implementation. | 695 // mojom::Bootstrap implementation. |
| 685 void Init(mojom::ChannelAssociatedRequest receive_channel, | 696 void Init(mojom::ChannelAssociatedRequest receive_channel, |
| 686 mojom::ChannelAssociatedPtrInfo send_channel, | 697 mojom::ChannelAssociatedPtrInfo send_channel, |
| 687 int32_t peer_pid, | 698 int32_t peer_pid, |
| 688 const InitCallback& callback) override; | 699 const InitCallback& callback) override; |
| 689 | 700 |
| 690 BootstrapMasterBinding binding_; | 701 BootstrapMasterBinding binding_; |
| 691 | 702 |
| 692 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); | 703 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 771 |
| 761 bool MojoBootstrap::HasFailed() const { | 772 bool MojoBootstrap::HasFailed() const { |
| 762 return state() == STATE_ERROR; | 773 return state() == STATE_ERROR; |
| 763 } | 774 } |
| 764 | 775 |
| 765 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { | 776 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { |
| 766 return std::move(handle_); | 777 return std::move(handle_); |
| 767 } | 778 } |
| 768 | 779 |
| 769 } // namespace IPC | 780 } // namespace IPC |
| OLD | NEW |