| OLD | NEW |
| 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/core.h" | 5 #include "mojo/system/core.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 MojoReadMessageFlags flags) { | 266 MojoReadMessageFlags flags) { |
| 267 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle)); | 267 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(message_pipe_handle)); |
| 268 if (!dispatcher) | 268 if (!dispatcher) |
| 269 return MOJO_RESULT_INVALID_ARGUMENT; | 269 return MOJO_RESULT_INVALID_ARGUMENT; |
| 270 | 270 |
| 271 uint32_t num_handles_value = num_handles.IsNull() ? 0 : num_handles.Get(); | 271 uint32_t num_handles_value = num_handles.IsNull() ? 0 : num_handles.Get(); |
| 272 | 272 |
| 273 MojoResult rv; | 273 MojoResult rv; |
| 274 if (num_handles_value == 0) { | 274 if (num_handles_value == 0) { |
| 275 // Easy case: won't receive any handles. | 275 // Easy case: won't receive any handles. |
| 276 rv = dispatcher->ReadMessage(bytes.GetPointerUnsafe(), | 276 rv = dispatcher->ReadMessage(bytes, num_bytes, NULL, &num_handles_value, |
| 277 num_bytes.GetPointerUnsafe(), NULL, | 277 flags); |
| 278 &num_handles_value, flags); | |
| 279 } else { | 278 } else { |
| 280 DispatcherVector dispatchers; | 279 DispatcherVector dispatchers; |
| 281 rv = dispatcher->ReadMessage(bytes.GetPointerUnsafe(), | 280 rv = dispatcher->ReadMessage(bytes, num_bytes, &dispatchers, |
| 282 num_bytes.GetPointerUnsafe(), &dispatchers, | |
| 283 &num_handles_value, flags); | 281 &num_handles_value, flags); |
| 284 if (!dispatchers.empty()) { | 282 if (!dispatchers.empty()) { |
| 285 DCHECK_EQ(rv, MOJO_RESULT_OK); | 283 DCHECK_EQ(rv, MOJO_RESULT_OK); |
| 286 DCHECK(!num_handles.IsNull()); | 284 DCHECK(!num_handles.IsNull()); |
| 287 DCHECK_LE(dispatchers.size(), static_cast<size_t>(num_handles_value)); | 285 DCHECK_LE(dispatchers.size(), static_cast<size_t>(num_handles_value)); |
| 288 | 286 |
| 289 bool success; | 287 bool success; |
| 290 UserPointer<MojoHandle>::Writer handles_writer(handles, | 288 UserPointer<MojoHandle>::Writer handles_writer(handles, |
| 291 dispatchers.size()); | 289 dispatchers.size()); |
| 292 { | 290 { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be | 559 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be |
| 562 // destroyed, but this would still be required if the waiter were in TLS.) | 560 // destroyed, but this would still be required if the waiter were in TLS.) |
| 563 for (i = 0; i < num_added; i++) | 561 for (i = 0; i < num_added; i++) |
| 564 dispatchers[i]->RemoveWaiter(&waiter); | 562 dispatchers[i]->RemoveWaiter(&waiter); |
| 565 | 563 |
| 566 return rv; | 564 return rv; |
| 567 } | 565 } |
| 568 | 566 |
| 569 } // namespace system | 567 } // namespace system |
| 570 } // namespace mojo | 568 } // namespace mojo |
| OLD | NEW |