| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 bool IsValid() { return sender_; } | 77 bool IsValid() { return sender_; } |
| 78 | 78 |
| 79 // Sends an IPC::Message to the other end of the pipe. Safe to call from any | 79 // Sends an IPC::Message to the other end of the pipe. Safe to call from any |
| 80 // thread. | 80 // thread. |
| 81 bool Send(std::unique_ptr<Message> message); | 81 bool Send(std::unique_ptr<Message> message); |
| 82 | 82 |
| 83 // Requests an associated interface from the other end of the pipe. | 83 // Requests an associated interface from the other end of the pipe. |
| 84 void GetRemoteInterface(const std::string& name, | 84 void GetRemoteInterface(const std::string& name, |
| 85 mojo::ScopedInterfaceEndpointHandle handle); | 85 mojo::ScopedInterfaceEndpointHandle handle); |
| 86 | 86 |
| 87 mojom::Channel* sender() const { return sender_.get(); } | 87 mojom::ChannelAssociatedPtr& sender() { return sender_; } |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 void OnPipeClosed(); | 90 void OnPipeClosed(); |
| 91 void OnPipeError(MojoResult error); | 91 void OnPipeError(MojoResult error); |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // mojom::Channel: | 94 // mojom::Channel: |
| 95 void SetPeerPid(int32_t peer_pid) override; | 95 void SetPeerPid(int32_t peer_pid) override; |
| 96 void Receive( | 96 void Receive( |
| 97 const std::vector<uint8_t>& data, | 97 const std::vector<uint8_t>& data, |
| 98 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override; | 98 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override; |
| 99 void GetAssociatedInterface( | 99 void GetAssociatedInterface( |
| 100 const std::string& name, | 100 const std::string& name, |
| 101 mojom::GenericInterfaceAssociatedRequest request) override; | 101 mojom::GenericInterfaceAssociatedRequest request) override; |
| 102 | 102 |
| 103 // |delegate_| is null once the message pipe is closed. | 103 // |delegate_| is null once the message pipe is closed. |
| 104 Delegate* delegate_; | 104 Delegate* delegate_; |
| 105 mojom::ChannelAssociatedPtr sender_; | 105 mojom::ChannelAssociatedPtr sender_; |
| 106 mojo::AssociatedBinding<mojom::Channel> binding_; | 106 mojo::AssociatedBinding<mojom::Channel> binding_; |
| 107 base::ThreadChecker thread_checker_; | 107 base::ThreadChecker thread_checker_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); | 109 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace internal | 112 } // namespace internal |
| 113 } // namespace IPC | 113 } // namespace IPC |
| 114 | 114 |
| 115 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_ | 115 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_ |
| OLD | NEW |