OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/message_pipe_dispatcher.h" | 5 #include "mojo/edk/system/message_pipe_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "mojo/edk/embedder/embedder_internal.h" | 10 #include "mojo/edk/embedder/embedder_internal.h" |
11 #include "mojo/edk/embedder/platform_handle_utils.h" | 11 #include "mojo/edk/embedder/platform_handle_utils.h" |
12 #include "mojo/edk/embedder/platform_shared_buffer.h" | 12 #include "mojo/edk/embedder/platform_shared_buffer.h" |
13 #include "mojo/edk/embedder/platform_support.h" | 13 #include "mojo/edk/embedder/platform_support.h" |
| 14 #include "mojo/edk/system/broker.h" |
14 #include "mojo/edk/system/configuration.h" | 15 #include "mojo/edk/system/configuration.h" |
15 #include "mojo/edk/system/message_in_transit.h" | 16 #include "mojo/edk/system/message_in_transit.h" |
16 #include "mojo/edk/system/options_validation.h" | 17 #include "mojo/edk/system/options_validation.h" |
17 #include "mojo/edk/system/transport_data.h" | 18 #include "mojo/edk/system/transport_data.h" |
18 | 19 |
19 #if defined(OS_WIN) | |
20 #include "mojo/edk/system/token_serializer_win.h" | |
21 #endif | |
22 | |
23 namespace mojo { | 20 namespace mojo { |
24 namespace edk { | 21 namespace edk { |
25 | 22 |
26 // TODO(jam): do more tests on using channel on same thread if it supports it ( | 23 // TODO(jam): do more tests on using channel on same thread if it supports it ( |
27 // i.e. with USE_CHROME_EDK and Windows). Also see ipc_channel_mojo.cc | 24 // i.e. with USE_CHROME_EDK and Windows). Also see ipc_channel_mojo.cc |
28 bool g_use_channel_on_io_thread_only = true; | 25 bool g_use_channel_on_io_thread_only = true; |
29 | 26 |
30 namespace { | 27 namespace { |
31 | 28 |
32 const size_t kInvalidMessagePipeHandleIndex = static_cast<size_t>(-1); | 29 const size_t kInvalidMessagePipeHandleIndex = static_cast<size_t>(-1); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // (since we can be sure that the shell will respond to our IPCs, compared to | 172 // (since we can be sure that the shell will respond to our IPCs, compared to |
176 // the other end where we're sending the MP to, which may not be reading...). | 173 // the other end where we're sending the MP to, which may not be reading...). |
177 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 174 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
178 size_t num_platform_handles, | 175 size_t num_platform_handles, |
179 const void* platform_handle_table) { | 176 const void* platform_handle_table) { |
180 ScopedPlatformHandleVectorPtr rv(new PlatformHandleVector()); | 177 ScopedPlatformHandleVectorPtr rv(new PlatformHandleVector()); |
181 rv->resize(num_platform_handles); | 178 rv->resize(num_platform_handles); |
182 | 179 |
183 const uint64_t* tokens = | 180 const uint64_t* tokens = |
184 static_cast<const uint64_t*>(platform_handle_table); | 181 static_cast<const uint64_t*>(platform_handle_table); |
185 internal::g_token_serializer->TokenToHandle( | 182 internal::g_broker->TokenToHandle(tokens, num_platform_handles, &rv->at(0)); |
186 tokens, num_platform_handles, &rv->at(0)); | |
187 return rv.Pass(); | 183 return rv.Pass(); |
188 } | 184 } |
189 #endif | 185 #endif |
190 | 186 |
191 scoped_refptr<MessagePipeDispatcher> MessagePipeDispatcher::Deserialize( | 187 scoped_refptr<MessagePipeDispatcher> MessagePipeDispatcher::Deserialize( |
192 const void* source, | 188 const void* source, |
193 size_t size, | 189 size_t size, |
194 PlatformHandleVector* platform_handles) { | 190 PlatformHandleVector* platform_handles) { |
195 if (size != sizeof(SerializedMessagePipeHandleDispatcher)) { | 191 if (size != sizeof(SerializedMessagePipeHandleDispatcher)) { |
196 LOG(ERROR) << "Invalid serialized message pipe dispatcher (bad size)"; | 192 LOG(ERROR) << "Invalid serialized message pipe dispatcher (bad size)"; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // cont'd | 430 // cont'd |
435 if (transport_data_buffer_size != 0) { | 431 if (transport_data_buffer_size != 0) { |
436 // TODO(jam): copied from RawChannelWin::WriteNoLock( | 432 // TODO(jam): copied from RawChannelWin::WriteNoLock( |
437 PlatformHandleVector* all_platform_handles = | 433 PlatformHandleVector* all_platform_handles = |
438 message->transport_data()->platform_handles(); | 434 message->transport_data()->platform_handles(); |
439 if (all_platform_handles) { | 435 if (all_platform_handles) { |
440 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
441 uint64_t* tokens = reinterpret_cast<uint64_t*>( | 437 uint64_t* tokens = reinterpret_cast<uint64_t*>( |
442 static_cast<char*>(message->transport_data()->buffer()) + | 438 static_cast<char*>(message->transport_data()->buffer()) + |
443 message->transport_data()->platform_handle_table_offset()); | 439 message->transport_data()->platform_handle_table_offset()); |
444 internal::g_token_serializer->HandleToToken( | 440 internal::g_broker->HandleToToken( |
445 &all_platform_handles->at(0), all_platform_handles->size(), tokens); | 441 &all_platform_handles->at(0), all_platform_handles->size(), tokens); |
446 for (size_t i = 0; i < all_platform_handles->size(); i++) | 442 for (size_t i = 0; i < all_platform_handles->size(); i++) |
447 all_platform_handles->at(i) = PlatformHandle(); | 443 all_platform_handles->at(i) = PlatformHandle(); |
448 #else | 444 #else |
449 for (size_t i = 0; i < all_platform_handles->size(); i++) { | 445 for (size_t i = 0; i < all_platform_handles->size(); i++) { |
450 serialized_fds_.push_back(all_platform_handles->at(i).fd); | 446 serialized_fds_.push_back(all_platform_handles->at(i).fd); |
451 serialized_message_fds_length_++; | 447 serialized_message_fds_length_++; |
452 all_platform_handles->at(i) = PlatformHandle(); | 448 all_platform_handles->at(i) = PlatformHandle(); |
453 } | 449 } |
454 #endif | 450 #endif |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 LOG(WARNING) << "Enqueueing null dispatcher"; | 851 LOG(WARNING) << "Enqueueing null dispatcher"; |
856 dispatchers->push_back(nullptr); | 852 dispatchers->push_back(nullptr); |
857 } | 853 } |
858 } | 854 } |
859 message->SetDispatchers(dispatchers.Pass()); | 855 message->SetDispatchers(dispatchers.Pass()); |
860 return MOJO_RESULT_OK; | 856 return MOJO_RESULT_OK; |
861 } | 857 } |
862 | 858 |
863 } // namespace edk | 859 } // namespace edk |
864 } // namespace mojo | 860 } // namespace mojo |
OLD | NEW |