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 #ifndef IPC_IPC_MESSAGE_PIPE_READER_H_ | 5 #ifndef IPC_IPC_MESSAGE_PIPE_READER_H_ |
6 #define IPC_IPC_MESSAGE_PIPE_READER_H_ | 6 #define IPC_IPC_MESSAGE_PIPE_READER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Sends an IPC::Message to the other end of the pipe. Safe to call from any | 81 // Sends an IPC::Message to the other end of the pipe. Safe to call from any |
82 // thread. | 82 // thread. |
83 bool Send(std::unique_ptr<Message> message); | 83 bool Send(std::unique_ptr<Message> message); |
84 | 84 |
85 // Requests an associated interface from the other end of the pipe. | 85 // Requests an associated interface from the other end of the pipe. |
86 void GetRemoteInterface(const std::string& name, | 86 void GetRemoteInterface(const std::string& name, |
87 mojo::ScopedInterfaceEndpointHandle handle); | 87 mojo::ScopedInterfaceEndpointHandle handle); |
88 | 88 |
89 base::ProcessId GetPeerPid() const { return peer_pid_; } | 89 base::ProcessId GetPeerPid() const { return peer_pid_; } |
90 | 90 |
| 91 mojom::Channel* sender() const { return sender_.get(); } |
| 92 |
91 protected: | 93 protected: |
92 void OnPipeClosed(); | 94 void OnPipeClosed(); |
93 void OnPipeError(MojoResult error); | 95 void OnPipeError(MojoResult error); |
94 | 96 |
95 private: | 97 private: |
96 // mojom::Channel: | 98 // mojom::Channel: |
97 void SetPeerPid(int32_t peer_pid) override; | 99 void SetPeerPid(int32_t peer_pid) override; |
98 void Receive( | 100 void Receive( |
99 const std::vector<uint8_t>& data, | 101 const std::vector<uint8_t>& data, |
100 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override; | 102 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override; |
101 void GetAssociatedInterface( | 103 void GetAssociatedInterface( |
102 const std::string& name, | 104 const std::string& name, |
103 mojom::GenericInterfaceAssociatedRequest request) override; | 105 mojom::GenericInterfaceAssociatedRequest request) override; |
104 | 106 |
105 // |delegate_| is null once the message pipe is closed. | 107 // |delegate_| is null once the message pipe is closed. |
106 Delegate* delegate_; | 108 Delegate* delegate_; |
107 base::ProcessId peer_pid_ = base::kNullProcessId; | 109 base::ProcessId peer_pid_ = base::kNullProcessId; |
108 mojom::ChannelAssociatedPtr sender_; | 110 mojom::ChannelAssociatedPtr sender_; |
109 mojo::AssociatedBinding<mojom::Channel> binding_; | 111 mojo::AssociatedBinding<mojom::Channel> binding_; |
110 | |
111 // Raw message pipe handle and interface ID we use to send legacy IPC messages | |
112 // over the associated pipe. | |
113 const uint32_t sender_interface_id_; | |
114 const mojo::MessagePipeHandle sender_pipe_; | |
115 | |
116 base::ThreadChecker thread_checker_; | 112 base::ThreadChecker thread_checker_; |
117 | 113 |
118 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); | 114 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); |
119 }; | 115 }; |
120 | 116 |
121 } // namespace internal | 117 } // namespace internal |
122 } // namespace IPC | 118 } // namespace IPC |
123 | 119 |
124 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_ | 120 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_ |
OLD | NEW |