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

Side by Side Diff: ipc/ipc_message_pipe_reader.h

Issue 2493623002: Remove IPC::Endpoint. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ipc/ipc_message.cc ('k') | ipc/ipc_message_pipe_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 30 matching lines...) Expand all
41 // The constructor automatically start listening on the pipe. 41 // The constructor automatically start listening on the pipe.
42 // 42 //
43 // All functions must be called on the IO thread, except for Send(), which can 43 // All functions must be called on the IO thread, except for Send(), which can
44 // be called on any thread. All |Delegate| functions will be called on the IO 44 // be called on any thread. All |Delegate| functions will be called on the IO
45 // thread. 45 // thread.
46 // 46 //
47 class IPC_EXPORT MessagePipeReader : public NON_EXPORTED_BASE(mojom::Channel) { 47 class IPC_EXPORT MessagePipeReader : public NON_EXPORTED_BASE(mojom::Channel) {
48 public: 48 public:
49 class Delegate { 49 class Delegate {
50 public: 50 public:
51 virtual void OnPeerPidReceived() = 0; 51 virtual void OnPeerPidReceived(int32_t peer_pid) = 0;
52 virtual void OnMessageReceived(const Message& message) = 0; 52 virtual void OnMessageReceived(const Message& message) = 0;
53 virtual void OnPipeError() = 0; 53 virtual void OnPipeError() = 0;
54 virtual void OnAssociatedInterfaceRequest( 54 virtual void OnAssociatedInterfaceRequest(
55 const std::string& name, 55 const std::string& name,
56 mojo::ScopedInterfaceEndpointHandle handle) = 0; 56 mojo::ScopedInterfaceEndpointHandle handle) = 0;
57 }; 57 };
58 58
59 // Builds a reader that reads messages from |receive_handle| and lets 59 // Builds a reader that reads messages from |receive_handle| and lets
60 // |delegate| know. 60 // |delegate| know.
61 // 61 //
(...skipping 17 matching lines...) Expand all
79 bool IsValid() { return sender_; } 79 bool IsValid() { return sender_; }
80 80
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_; }
90
91 mojom::Channel* sender() const { return sender_.get(); } 89 mojom::Channel* sender() const { return sender_.get(); }
92 90
93 protected: 91 protected:
94 void OnPipeClosed(); 92 void OnPipeClosed();
95 void OnPipeError(MojoResult error); 93 void OnPipeError(MojoResult error);
96 94
97 private: 95 private:
98 // mojom::Channel: 96 // mojom::Channel:
99 void SetPeerPid(int32_t peer_pid) override; 97 void SetPeerPid(int32_t peer_pid) override;
100 void Receive( 98 void Receive(
101 const std::vector<uint8_t>& data, 99 const std::vector<uint8_t>& data,
102 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override; 100 base::Optional<std::vector<mojom::SerializedHandlePtr>> handles) override;
103 void GetAssociatedInterface( 101 void GetAssociatedInterface(
104 const std::string& name, 102 const std::string& name,
105 mojom::GenericInterfaceAssociatedRequest request) override; 103 mojom::GenericInterfaceAssociatedRequest request) override;
106 104
107 // |delegate_| is null once the message pipe is closed. 105 // |delegate_| is null once the message pipe is closed.
108 Delegate* delegate_; 106 Delegate* delegate_;
109 base::ProcessId peer_pid_ = base::kNullProcessId;
110 mojom::ChannelAssociatedPtr sender_; 107 mojom::ChannelAssociatedPtr sender_;
111 mojo::AssociatedBinding<mojom::Channel> binding_; 108 mojo::AssociatedBinding<mojom::Channel> binding_;
112 base::ThreadChecker thread_checker_; 109 base::ThreadChecker thread_checker_;
113 110
114 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); 111 DISALLOW_COPY_AND_ASSIGN(MessagePipeReader);
115 }; 112 };
116 113
117 } // namespace internal 114 } // namespace internal
118 } // namespace IPC 115 } // namespace IPC
119 116
120 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_ 117 #endif // IPC_IPC_MESSAGE_PIPE_READER_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message.cc ('k') | ipc/ipc_message_pipe_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698