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