Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: ipc/ipc_mojo_bootstrap.cc

Issue 2137353002: Adds associated interface support to IPC::Channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@channel-bindings-1
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 endpoint_client_.reset(); 580 endpoint_client_.reset();
581 if (controller_) 581 if (controller_)
582 controller_->ShutDown(); 582 controller_->ShutDown();
583 } 583 }
584 584
585 void set_connection_error_handler(const base::Closure& handler) { 585 void set_connection_error_handler(const base::Closure& handler) {
586 DCHECK(endpoint_client_); 586 DCHECK(endpoint_client_);
587 endpoint_client_->set_connection_error_handler(handler); 587 endpoint_client_->set_connection_error_handler(handler);
588 } 588 }
589 589
590 mojo::AssociatedGroup* associated_group() {
591 DCHECK(controller_);
592 return controller_->associated_group();
593 }
594
590 void Bind(mojo::ScopedMessagePipeHandle handle) { 595 void Bind(mojo::ScopedMessagePipeHandle handle) {
591 DCHECK(!controller_); 596 DCHECK(!controller_);
592 controller_ = 597 controller_ =
593 new ChannelAssociatedGroupController(false, std::move(handle)); 598 new ChannelAssociatedGroupController(false, std::move(handle));
594 stub_.serialization_context()->group_controller = controller_; 599 stub_.serialization_context()->group_controller = controller_;
595 600
596 endpoint_client_.reset(new mojo::InterfaceEndpointClient( 601 endpoint_client_.reset(new mojo::InterfaceEndpointClient(
597 controller_->CreateLocalEndpointHandle(mojo::kMasterInterfaceId), 602 controller_->CreateLocalEndpointHandle(mojo::kMasterInterfaceId),
598 &stub_, 603 &stub_,
599 base::MakeUnique<typename mojom::Bootstrap::RequestValidator_>(), 604 base::MakeUnique<typename mojom::Bootstrap::RequestValidator_>(),
(...skipping 10 matching lines...) Expand all
610 615
611 // MojoBootstrap for the server process. You should create the instance 616 // MojoBootstrap for the server process. You should create the instance
612 // using MojoBootstrap::Create(). 617 // using MojoBootstrap::Create().
613 class MojoServerBootstrap : public MojoBootstrap { 618 class MojoServerBootstrap : public MojoBootstrap {
614 public: 619 public:
615 MojoServerBootstrap(); 620 MojoServerBootstrap();
616 621
617 private: 622 private:
618 // MojoBootstrap implementation. 623 // MojoBootstrap implementation.
619 void Connect() override; 624 void Connect() override;
625 mojo::AssociatedGroup* GetAssociatedGroup() override {
626 return bootstrap_.associated_group();
627 }
620 628
621 void OnInitDone(int32_t peer_pid); 629 void OnInitDone(int32_t peer_pid);
622 630
623 BootstrapMasterProxy bootstrap_; 631 BootstrapMasterProxy bootstrap_;
624 IPC::mojom::ChannelAssociatedPtrInfo send_channel_; 632 IPC::mojom::ChannelAssociatedPtrInfo send_channel_;
625 IPC::mojom::ChannelAssociatedRequest receive_channel_request_; 633 IPC::mojom::ChannelAssociatedRequest receive_channel_request_;
626 634
627 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap); 635 DISALLOW_COPY_AND_ASSIGN(MojoServerBootstrap);
628 }; 636 };
629 637
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 677
670 // MojoBootstrap for client processes. You should create the instance 678 // MojoBootstrap for client processes. You should create the instance
671 // using MojoBootstrap::Create(). 679 // using MojoBootstrap::Create().
672 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap { 680 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap {
673 public: 681 public:
674 MojoClientBootstrap(); 682 MojoClientBootstrap();
675 683
676 private: 684 private:
677 // MojoBootstrap implementation. 685 // MojoBootstrap implementation.
678 void Connect() override; 686 void Connect() override;
687 mojo::AssociatedGroup* GetAssociatedGroup() override {
688 return binding_.associated_group();
689 }
679 690
680 // mojom::Bootstrap implementation. 691 // mojom::Bootstrap implementation.
681 void Init(mojom::ChannelAssociatedRequest receive_channel, 692 void Init(mojom::ChannelAssociatedRequest receive_channel,
682 mojom::ChannelAssociatedPtrInfo send_channel, 693 mojom::ChannelAssociatedPtrInfo send_channel,
683 int32_t peer_pid, 694 int32_t peer_pid,
684 const InitCallback& callback) override; 695 const InitCallback& callback) override;
685 696
686 BootstrapMasterBinding binding_; 697 BootstrapMasterBinding binding_;
687 698
688 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); 699 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 767
757 bool MojoBootstrap::HasFailed() const { 768 bool MojoBootstrap::HasFailed() const {
758 return state() == STATE_ERROR; 769 return state() == STATE_ERROR;
759 } 770 }
760 771
761 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { 772 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() {
762 return std::move(handle_); 773 return std::move(handle_);
763 } 774 }
764 775
765 } // namespace IPC 776 } // namespace IPC
OLDNEW
« ipc/ipc_channel.h ('K') | « ipc/ipc_mojo_bootstrap.h ('k') | ipc/ipc_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698