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/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/process/process.h" | 15 #include "base/process/process.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "base/win/scoped_handle.h" | 18 #include "base/win/scoped_handle.h" |
19 #include "base/win/windows_version.h" | 19 #include "base/win/windows_version.h" |
20 #include "mojo/edk/embedder/embedder_internal.h" | 20 #include "mojo/edk/embedder/embedder_internal.h" |
21 #include "mojo/edk/embedder/platform_handle.h" | 21 #include "mojo/edk/embedder/platform_handle.h" |
22 #include "mojo/edk/system/token_serializer_win.h" | 22 #include "mojo/edk/system/broker.h" |
23 #include "mojo/edk/system/transport_data.h" | 23 #include "mojo/edk/system/transport_data.h" |
24 #include "mojo/public/cpp/system/macros.h" | 24 #include "mojo/public/cpp/system/macros.h" |
25 | 25 |
26 #define STATUS_CANCELLED 0xC0000120 | 26 #define STATUS_CANCELLED 0xC0000120 |
27 #define STATUS_PIPE_BROKEN 0xC000014B | 27 #define STATUS_PIPE_BROKEN 0xC000014B |
28 | 28 |
29 namespace mojo { | 29 namespace mojo { |
30 namespace edk { | 30 namespace edk { |
31 | 31 |
32 namespace { | 32 namespace { |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 598 ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
599 size_t num_platform_handles, | 599 size_t num_platform_handles, |
600 const void* platform_handle_table) override { | 600 const void* platform_handle_table) override { |
601 DCHECK_GT(num_platform_handles, 0u); | 601 DCHECK_GT(num_platform_handles, 0u); |
602 ScopedPlatformHandleVectorPtr rv(new PlatformHandleVector()); | 602 ScopedPlatformHandleVectorPtr rv(new PlatformHandleVector()); |
603 rv->resize(num_platform_handles); | 603 rv->resize(num_platform_handles); |
604 | 604 |
605 const uint64_t* tokens = | 605 const uint64_t* tokens = |
606 static_cast<const uint64_t*>(platform_handle_table); | 606 static_cast<const uint64_t*>(platform_handle_table); |
607 internal::g_token_serializer->TokenToHandle( | 607 internal::g_broker->TokenToHandle(tokens, num_platform_handles, &rv->at(0)); |
608 tokens, num_platform_handles, &rv->at(0)); | |
609 return rv.Pass(); | 608 return rv.Pass(); |
610 } | 609 } |
611 | 610 |
612 size_t SerializePlatformHandles(std::vector<int>* fds) override { | 611 size_t SerializePlatformHandles(std::vector<int>* fds) override { |
613 if (!write_buffer_no_lock()->HavePlatformHandlesToSend()) | 612 if (!write_buffer_no_lock()->HavePlatformHandlesToSend()) |
614 return 0u; | 613 return 0u; |
615 | 614 |
616 PlatformHandle* platform_handles; | 615 PlatformHandle* platform_handles; |
617 void* serialization_data_temp; | 616 void* serialization_data_temp; |
618 size_t num_platform_handles; | 617 size_t num_platform_handles; |
619 write_buffer_no_lock()->GetPlatformHandlesToSend( | 618 write_buffer_no_lock()->GetPlatformHandlesToSend( |
620 &num_platform_handles, &platform_handles, &serialization_data_temp); | 619 &num_platform_handles, &platform_handles, &serialization_data_temp); |
621 uint64_t* tokens = static_cast<uint64_t*>(serialization_data_temp); | 620 uint64_t* tokens = static_cast<uint64_t*>(serialization_data_temp); |
622 DCHECK_GT(num_platform_handles, 0u); | 621 DCHECK_GT(num_platform_handles, 0u); |
623 DCHECK(platform_handles); | 622 DCHECK(platform_handles); |
624 | 623 |
625 internal::g_token_serializer->HandleToToken( | 624 internal::g_broker->HandleToToken( |
626 &platform_handles[0], num_platform_handles, tokens); | 625 &platform_handles[0], num_platform_handles, tokens); |
627 for (size_t i = 0; i < num_platform_handles; i++) | 626 for (size_t i = 0; i < num_platform_handles; i++) |
628 platform_handles[i] = PlatformHandle(); | 627 platform_handles[i] = PlatformHandle(); |
629 return num_platform_handles; | 628 return num_platform_handles; |
630 } | 629 } |
631 | 630 |
632 IOResult WriteNoLock(size_t* platform_handles_written, | 631 IOResult WriteNoLock(size_t* platform_handles_written, |
633 size_t* bytes_written) override { | 632 size_t* bytes_written) override { |
634 write_lock().AssertAcquired(); | 633 write_lock().AssertAcquired(); |
635 | 634 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 } else { | 768 } else { |
770 // This is to catch developer errors. Let them be caught on Vista and above, | 769 // This is to catch developer errors. Let them be caught on Vista and above, |
771 // i.e. no point in implementing this on XP since support for it will be | 770 // i.e. no point in implementing this on XP since support for it will be |
772 // removed in early 2016. | 771 // removed in early 2016. |
773 return false; | 772 return false; |
774 } | 773 } |
775 } | 774 } |
776 | 775 |
777 } // namespace edk | 776 } // namespace edk |
778 } // namespace mojo | 777 } // namespace mojo |
OLD | NEW |