| 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 <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" |
| 11 #include "mojo/edk/embedder/embedder_internal.h" | 11 #include "mojo/edk/embedder/embedder_internal.h" |
| 12 #include "mojo/edk/embedder/platform_channel_pair.h" | 12 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 13 #include "mojo/edk/embedder/platform_shared_buffer.h" | 13 #include "mojo/edk/embedder/platform_shared_buffer.h" |
| 14 #include "mojo/edk/embedder/platform_support.h" | 14 #include "mojo/edk/embedder/platform_support.h" |
| 15 #include "mojo/edk/system/async_waiter.h" | 15 #include "mojo/edk/system/async_waiter.h" |
| 16 #include "mojo/edk/system/broker.h" |
| 16 #include "mojo/edk/system/configuration.h" | 17 #include "mojo/edk/system/configuration.h" |
| 17 #include "mojo/edk/system/data_pipe.h" | 18 #include "mojo/edk/system/data_pipe.h" |
| 18 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" | 19 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
| 19 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 20 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| 20 #include "mojo/edk/system/dispatcher.h" | 21 #include "mojo/edk/system/dispatcher.h" |
| 21 #include "mojo/edk/system/handle_signals_state.h" | 22 #include "mojo/edk/system/handle_signals_state.h" |
| 22 #include "mojo/edk/system/message_pipe_dispatcher.h" | 23 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 23 #include "mojo/edk/system/shared_buffer_dispatcher.h" | 24 #include "mojo/edk/system/shared_buffer_dispatcher.h" |
| 24 #include "mojo/edk/system/waiter.h" | 25 #include "mojo/edk/system/waiter.h" |
| 25 #include "mojo/public/c/system/macros.h" | 26 #include "mojo/public/c/system/macros.h" |
| 26 #include "mojo/public/cpp/system/macros.h" | 27 #include "mojo/public/cpp/system/macros.h" |
| 27 | 28 |
| 28 #if defined(OS_WIN) | |
| 29 #include "mojo/edk/system/token_serializer_win.h" | |
| 30 #endif | |
| 31 | |
| 32 namespace mojo { | 29 namespace mojo { |
| 33 namespace edk { | 30 namespace edk { |
| 34 | 31 |
| 35 // Implementation notes | 32 // Implementation notes |
| 36 // | 33 // |
| 37 // Mojo primitives are implemented by the singleton |Core| object. Most calls | 34 // Mojo primitives are implemented by the singleton |Core| object. Most calls |
| 38 // are for a "primary" handle (the first argument). |Core::GetDispatcher()| is | 35 // are for a "primary" handle (the first argument). |Core::GetDispatcher()| is |
| 39 // used to look up a |Dispatcher| object for a given handle. That object | 36 // used to look up a |Dispatcher| object for a given handle. That object |
| 40 // implements most primitives for that object. The wait primitives are not | 37 // implements most primitives for that object. The wait primitives are not |
| 41 // attached to objects and are implemented by |Core| itself. | 38 // attached to objects and are implemented by |Core| itself. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (handle_pair.first == MOJO_HANDLE_INVALID) { | 201 if (handle_pair.first == MOJO_HANDLE_INVALID) { |
| 205 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); | 202 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); |
| 206 LOG(ERROR) << "Handle table full"; | 203 LOG(ERROR) << "Handle table full"; |
| 207 dispatcher0->Close(); | 204 dispatcher0->Close(); |
| 208 dispatcher1->Close(); | 205 dispatcher1->Close(); |
| 209 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 206 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 210 } | 207 } |
| 211 | 208 |
| 212 ScopedPlatformHandle server_handle, client_handle; | 209 ScopedPlatformHandle server_handle, client_handle; |
| 213 #if defined(OS_WIN) | 210 #if defined(OS_WIN) |
| 214 internal::g_token_serializer->CreatePlatformChannelPair( | 211 internal::g_broker->CreatePlatformChannelPair(&server_handle, &client_handle); |
| 215 &server_handle, &client_handle); | |
| 216 #else | 212 #else |
| 217 PlatformChannelPair channel_pair; | 213 PlatformChannelPair channel_pair; |
| 218 server_handle = channel_pair.PassServerHandle(); | 214 server_handle = channel_pair.PassServerHandle(); |
| 219 client_handle = channel_pair.PassClientHandle(); | 215 client_handle = channel_pair.PassClientHandle(); |
| 220 #endif | 216 #endif |
| 221 dispatcher0->Init(server_handle.Pass(), nullptr, 0u, nullptr, 0u, nullptr, | 217 dispatcher0->Init(server_handle.Pass(), nullptr, 0u, nullptr, 0u, nullptr, |
| 222 nullptr); | 218 nullptr); |
| 223 dispatcher1->Init(client_handle.Pass(), nullptr, 0u, nullptr, 0u, nullptr, | 219 dispatcher1->Init(client_handle.Pass(), nullptr, 0u, nullptr, 0u, nullptr, |
| 224 nullptr); | 220 nullptr); |
| 225 | 221 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); | 368 DCHECK_EQ(handle_pair.second, MOJO_HANDLE_INVALID); |
| 373 LOG(ERROR) << "Handle table full"; | 369 LOG(ERROR) << "Handle table full"; |
| 374 producer_dispatcher->Close(); | 370 producer_dispatcher->Close(); |
| 375 consumer_dispatcher->Close(); | 371 consumer_dispatcher->Close(); |
| 376 return MOJO_RESULT_RESOURCE_EXHAUSTED; | 372 return MOJO_RESULT_RESOURCE_EXHAUSTED; |
| 377 } | 373 } |
| 378 DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID); | 374 DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID); |
| 379 | 375 |
| 380 ScopedPlatformHandle server_handle, client_handle; | 376 ScopedPlatformHandle server_handle, client_handle; |
| 381 #if defined(OS_WIN) | 377 #if defined(OS_WIN) |
| 382 internal::g_token_serializer->CreatePlatformChannelPair( | 378 internal::g_broker->CreatePlatformChannelPair(&server_handle, &client_handle); |
| 383 &server_handle, &client_handle); | |
| 384 #else | 379 #else |
| 385 PlatformChannelPair channel_pair; | 380 PlatformChannelPair channel_pair; |
| 386 server_handle = channel_pair.PassServerHandle(); | 381 server_handle = channel_pair.PassServerHandle(); |
| 387 client_handle = channel_pair.PassClientHandle(); | 382 client_handle = channel_pair.PassClientHandle(); |
| 388 #endif | 383 #endif |
| 389 producer_dispatcher->Init(server_handle.Pass(), nullptr, 0u); | 384 producer_dispatcher->Init(server_handle.Pass(), nullptr, 0u); |
| 390 consumer_dispatcher->Init(client_handle.Pass(), nullptr, 0u); | 385 consumer_dispatcher->Init(client_handle.Pass(), nullptr, 0u); |
| 391 | 386 |
| 392 *data_pipe_producer_handle = handle_pair.first; | 387 *data_pipe_producer_handle = handle_pair.first; |
| 393 *data_pipe_consumer_handle = handle_pair.second; | 388 *data_pipe_consumer_handle = handle_pair.second; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 if (signals_states) { | 606 if (signals_states) { |
| 612 for (; i < num_handles; i++) | 607 for (; i < num_handles; i++) |
| 613 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 608 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
| 614 } | 609 } |
| 615 | 610 |
| 616 return rv; | 611 return rv; |
| 617 } | 612 } |
| 618 | 613 |
| 619 } // namespace edk | 614 } // namespace edk |
| 620 } // namespace mojo | 615 } // namespace mojo |
| OLD | NEW |