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

Side by Side Diff: mojo/system/message_pipe_dispatcher.cc

Issue 419973005: Convert WriteMessage...() to use the new user pointer handling (see r285350). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/message_pipe_dispatcher.h ('k') | mojo/system/message_pipe_dispatcher_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/system/message_pipe_dispatcher.h" 5 #include "mojo/system/message_pipe_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/system/channel.h" 8 #include "mojo/system/channel.h"
9 #include "mojo/system/constants.h" 9 #include "mojo/system/constants.h"
10 #include "mojo/system/local_message_pipe_endpoint.h" 10 #include "mojo/system/local_message_pipe_endpoint.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // too. 172 // too.
173 scoped_refptr<MessagePipeDispatcher> rv = 173 scoped_refptr<MessagePipeDispatcher> rv =
174 new MessagePipeDispatcher(kDefaultCreateOptions); 174 new MessagePipeDispatcher(kDefaultCreateOptions);
175 rv->Init(message_pipe_, port_); 175 rv->Init(message_pipe_, port_);
176 message_pipe_ = NULL; 176 message_pipe_ = NULL;
177 port_ = kInvalidPort; 177 port_ = kInvalidPort;
178 return scoped_refptr<Dispatcher>(rv.get()); 178 return scoped_refptr<Dispatcher>(rv.get());
179 } 179 }
180 180
181 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock( 181 MojoResult MessagePipeDispatcher::WriteMessageImplNoLock(
182 const void* bytes, 182 UserPointer<const void> bytes,
183 uint32_t num_bytes, 183 uint32_t num_bytes,
184 std::vector<DispatcherTransport>* transports, 184 std::vector<DispatcherTransport>* transports,
185 MojoWriteMessageFlags flags) { 185 MojoWriteMessageFlags flags) {
186 DCHECK(!transports || (transports->size() > 0 && 186 DCHECK(!transports || (transports->size() > 0 &&
187 transports->size() <= kMaxMessageNumHandles)); 187 transports->size() <= kMaxMessageNumHandles));
188 188
189 lock().AssertAcquired(); 189 lock().AssertAcquired();
190 190
191 if (!VerifyUserPointerWithSize<1>(bytes, num_bytes))
192 return MOJO_RESULT_INVALID_ARGUMENT;
193 if (num_bytes > kMaxMessageNumBytes) 191 if (num_bytes > kMaxMessageNumBytes)
194 return MOJO_RESULT_RESOURCE_EXHAUSTED; 192 return MOJO_RESULT_RESOURCE_EXHAUSTED;
195 193
196 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports, 194 return message_pipe_->WriteMessage(port_, bytes, num_bytes, transports,
197 flags); 195 flags);
198 } 196 }
199 197
200 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock( 198 MojoResult MessagePipeDispatcher::ReadMessageImplNoLock(
201 UserPointer<void> bytes, 199 UserPointer<void> bytes,
202 UserPointer<uint32_t> num_bytes, 200 UserPointer<uint32_t> num_bytes,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 262
265 // MessagePipeDispatcherTransport ---------------------------------------------- 263 // MessagePipeDispatcherTransport ----------------------------------------------
266 264
267 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport( 265 MessagePipeDispatcherTransport::MessagePipeDispatcherTransport(
268 DispatcherTransport transport) : DispatcherTransport(transport) { 266 DispatcherTransport transport) : DispatcherTransport(transport) {
269 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe); 267 DCHECK_EQ(message_pipe_dispatcher()->GetType(), Dispatcher::kTypeMessagePipe);
270 } 268 }
271 269
272 } // namespace system 270 } // namespace system
273 } // namespace mojo 271 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/message_pipe_dispatcher.h ('k') | mojo/system/message_pipe_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698