| 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/edk/system/core.h" | 5 #include "mojo/edk/system/core.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1); | 215 handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1); |
| 216 } | 216 } |
| 217 if (handle_pair.first == MOJO_HANDLE_INVALID) { | 217 if (handle_pair.first == MOJO_HANDLE_INVALID) { |
| 218 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); | 218 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); |
| 219 LOG(ERROR) << "Handle table full"; | 219 LOG(ERROR) << "Handle table full"; |
| 220 dispatcher0->Close(); | 220 dispatcher0->Close(); |
| 221 dispatcher1->Close(); | 221 dispatcher1->Close(); |
| 222 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 222 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 223 } | 223 } |
| 224 | 224 |
| 225 scoped_refptr<MessagePipe> message_pipe(MessagePipe::CreateLocalLocal()); | 225 auto message_pipe = MessagePipe::CreateLocalLocal(); |
| 226 dispatcher0->Init(message_pipe, 0); | 226 dispatcher0->Init(message_pipe.Clone(), 0); |
| 227 dispatcher1->Init(message_pipe, 1); | 227 dispatcher1->Init(std::move(message_pipe), 1); |
| 228 | 228 |
| 229 message_pipe_handle0.Put(handle_pair.first); | 229 message_pipe_handle0.Put(handle_pair.first); |
| 230 message_pipe_handle1.Put(handle_pair.second); | 230 message_pipe_handle1.Put(handle_pair.second); |
| 231 return MOJO_RESULT_OK; | 231 return MOJO_RESULT_OK; |
| 232 } | 232 } |
| 233 | 233 |
| 234 // Implementation note: To properly cancel waiters and avoid other races, this | 234 // Implementation note: To properly cancel waiters and avoid other races, this |
| 235 // does not transfer dispatchers from one handle to another, even when sending a | 235 // does not transfer dispatchers from one handle to another, even when sending a |
| 236 // message in-process. Instead, it must transfer the "contents" of the | 236 // message in-process. Instead, it must transfer the "contents" of the |
| 237 // dispatcher to a new dispatcher, and then close the old dispatcher. If this | 237 // dispatcher to a new dispatcher, and then close the old dispatcher. If this |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 383 } |
| 384 if (handle_pair.first == MOJO_HANDLE_INVALID) { | 384 if (handle_pair.first == MOJO_HANDLE_INVALID) { |
| 385 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); | 385 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); |
| 386 LOG(ERROR) << "Handle table full"; | 386 LOG(ERROR) << "Handle table full"; |
| 387 producer_dispatcher->Close(); | 387 producer_dispatcher->Close(); |
| 388 consumer_dispatcher->Close(); | 388 consumer_dispatcher->Close(); |
| 389 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 389 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 390 } | 390 } |
| 391 DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID); | 391 DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID); |
| 392 | 392 |
| 393 scoped_refptr<DataPipe> data_pipe(DataPipe::CreateLocal(validated_options)); | 393 auto data_pipe = DataPipe::CreateLocal(validated_options); |
| 394 producer_dispatcher->Init(data_pipe); | 394 producer_dispatcher->Init(data_pipe.Clone()); |
| 395 consumer_dispatcher->Init(data_pipe); | 395 consumer_dispatcher->Init(std::move(data_pipe)); |
| 396 | 396 |
| 397 data_pipe_producer_handle.Put(handle_pair.first); | 397 data_pipe_producer_handle.Put(handle_pair.first); |
| 398 data_pipe_consumer_handle.Put(handle_pair.second); | 398 data_pipe_consumer_handle.Put(handle_pair.second); |
| 399 return MOJO_RESULT_OK; | 399 return MOJO_RESULT_OK; |
| 400 } | 400 } |
| 401 | 401 |
| 402 MojoResult Core::WriteData(MojoHandle data_pipe_producer_handle, | 402 MojoResult Core::WriteData(MojoHandle data_pipe_producer_handle, |
| 403 UserPointer<const void> elements, | 403 UserPointer<const void> elements, |
| 404 UserPointer<uint32_t> num_bytes, | 404 UserPointer<uint32_t> num_bytes, |
| 405 MojoWriteDataFlags flags) { | 405 MojoWriteDataFlags flags) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 if (signals_states) { | 609 if (signals_states) { |
| 610 for (; i < num_handles; i++) | 610 for (; i < num_handles; i++) |
| 611 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 611 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
| 612 } | 612 } |
| 613 | 613 |
| 614 return rv; | 614 return rv; |
| 615 } | 615 } |
| 616 | 616 |
| 617 } // namespace system | 617 } // namespace system |
| 618 } // namespace mojo | 618 } // namespace mojo |
| OLD | NEW |