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

Side by Side Diff: ipc/mojo/ipc_channel_mojo.h

Issue 679453002: ChannelMojo: Replace hand written messsages with mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing (again) Created 6 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/mojo/client_channel.mojom ('k') | ipc/mojo/ipc_channel_mojo.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_CHANNEL_MOJO_H_ 5 #ifndef IPC_IPC_CHANNEL_MOJO_H_
6 #define IPC_IPC_CHANNEL_MOJO_H_ 6 #define IPC_IPC_CHANNEL_MOJO_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // as a friend class. 107 // as a friend class.
108 static MojoResult WriteToFileDescriptorSet( 108 static MojoResult WriteToFileDescriptorSet(
109 const std::vector<MojoHandle>& handle_buffer, 109 const std::vector<MojoHandle>& handle_buffer,
110 Message* message); 110 Message* message);
111 static MojoResult ReadFromFileDescriptorSet(Message* message, 111 static MojoResult ReadFromFileDescriptorSet(Message* message,
112 std::vector<MojoHandle>* handles); 112 std::vector<MojoHandle>* handles);
113 113
114 #endif // defined(OS_POSIX) && !defined(OS_NACL) 114 #endif // defined(OS_POSIX) && !defined(OS_NACL)
115 115
116 // MojoBootstrapDelegate implementation 116 // MojoBootstrapDelegate implementation
117 void OnPipeAvailable(mojo::embedder::ScopedPlatformHandle handle) override;
118 void OnBootstrapError() override; 117 void OnBootstrapError() override;
119 118
120 // Called from MessagePipeReader implementations 119 // Called from MessagePipeReader implementations
121 void OnMessageReceived(Message& message); 120 void OnMessageReceived(Message& message);
122 void OnConnected(mojo::ScopedMessagePipeHandle pipe);
123 void OnPipeClosed(internal::MessagePipeReader* reader); 121 void OnPipeClosed(internal::MessagePipeReader* reader);
124 void OnPipeError(internal::MessagePipeReader* reader); 122 void OnPipeError(internal::MessagePipeReader* reader);
125 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; }
126 123
127 protected: 124 protected:
128 ChannelMojo(Delegate* delegate, 125 ChannelMojo(Delegate* delegate,
129 const ChannelHandle& channel_handle, 126 const ChannelHandle& channel_handle,
130 Mode mode, 127 Mode mode,
131 Listener* listener); 128 Listener* listener);
132 129
130 mojo::ScopedMessagePipeHandle CreateMessagingPipe(
131 mojo::embedder::ScopedPlatformHandle handle);
132 void InitMessageReader(mojo::ScopedMessagePipeHandle pipe, int32_t peer_pid);
133
134 Listener* listener() const { return listener_; }
135 void set_peer_pid(base::ProcessId pid) { peer_pid_ = pid; }
136
133 private: 137 private:
134 struct ChannelInfoDeleter { 138 struct ChannelInfoDeleter {
135 void operator()(mojo::embedder::ChannelInfo* ptr) const; 139 void operator()(mojo::embedder::ChannelInfo* ptr) const;
136 }; 140 };
137 141
138 // ChannelMojo needs to kill its MessagePipeReader in delayed manner 142 // ChannelMojo needs to kill its MessagePipeReader in delayed manner
139 // because the channel wants to kill these readers during the 143 // because the channel wants to kill these readers during the
140 // notifications invoked by them. 144 // notifications invoked by them.
141 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter; 145 typedef internal::MessagePipeReader::DelayedDeleter ReaderDeleter;
142 146
143 void InitDelegate(ChannelMojo::Delegate* delegate); 147 void InitDelegate(ChannelMojo::Delegate* delegate);
144 void InitControlReader(mojo::embedder::ScopedPlatformHandle handle);
145 148
146 scoped_ptr<MojoBootstrap> bootstrap_; 149 scoped_ptr<MojoBootstrap> bootstrap_;
147 base::WeakPtr<Delegate> delegate_; 150 base::WeakPtr<Delegate> delegate_;
148 Mode mode_; 151 Mode mode_;
149 Listener* listener_; 152 Listener* listener_;
150 base::ProcessId peer_pid_; 153 base::ProcessId peer_pid_;
151 scoped_ptr<mojo::embedder::ChannelInfo, 154 scoped_ptr<mojo::embedder::ChannelInfo,
152 ChannelInfoDeleter> channel_info_; 155 ChannelInfoDeleter> channel_info_;
153 156
154 scoped_ptr<internal::ControlReader, ReaderDeleter> control_reader_;
155 scoped_ptr<internal::MessageReader, ReaderDeleter> message_reader_; 157 scoped_ptr<internal::MessageReader, ReaderDeleter> message_reader_;
156 ScopedVector<Message> pending_messages_; 158 ScopedVector<Message> pending_messages_;
157 159
158 base::WeakPtrFactory<ChannelMojo> weak_factory_; 160 base::WeakPtrFactory<ChannelMojo> weak_factory_;
159 161
160 DISALLOW_COPY_AND_ASSIGN(ChannelMojo); 162 DISALLOW_COPY_AND_ASSIGN(ChannelMojo);
161 }; 163 };
162 164
163 } // namespace IPC 165 } // namespace IPC
164 166
165 #endif // IPC_IPC_CHANNEL_MOJO_H_ 167 #endif // IPC_IPC_CHANNEL_MOJO_H_
OLDNEW
« no previous file with comments | « ipc/mojo/client_channel.mojom ('k') | ipc/mojo/ipc_channel_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698