| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ipc/ipc_channel_mojo.h" | 5 #include "ipc/ipc_channel_mojo.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 EXPECT_TRUE(iter.ReadInt(&should_be_expected)); | 802 EXPECT_TRUE(iter.ReadInt(&should_be_expected)); |
| 803 EXPECT_EQ(should_be_expected, next_expected_value_); | 803 EXPECT_EQ(should_be_expected, next_expected_value_); |
| 804 num_messages_received_++; | 804 num_messages_received_++; |
| 805 return true; | 805 return true; |
| 806 } | 806 } |
| 807 | 807 |
| 808 void OnChannelError() override { | 808 void OnChannelError() override { |
| 809 DCHECK(received_quit_); | 809 DCHECK(received_quit_); |
| 810 } | 810 } |
| 811 | 811 |
| 812 void RegisterInterfaceFactory(IPC::ChannelProxy* proxy) { | 812 void OnAssociatedInterfaceRequest( |
| 813 proxy->AddAssociatedInterface( | 813 const std::string& interface_name, |
| 814 base::Bind(&ListenerWithSimpleProxyAssociatedInterface::BindRequest, | 814 mojo::ScopedInterfaceEndpointHandle handle) override { |
| 815 base::Unretained(this))); | 815 DCHECK_EQ(interface_name, IPC::mojom::SimpleTestDriver::Name_); |
| 816 IPC::mojom::SimpleTestDriverAssociatedRequest request; |
| 817 request.Bind(std::move(handle)); |
| 818 binding_.Bind(std::move(request)); |
| 816 } | 819 } |
| 817 | 820 |
| 818 bool received_all_messages() const { | 821 bool received_all_messages() const { |
| 819 return num_messages_received_ == kNumMessages && received_quit_; | 822 return num_messages_received_ == kNumMessages && received_quit_; |
| 820 } | 823 } |
| 821 | 824 |
| 822 private: | 825 private: |
| 823 // IPC::mojom::SimpleTestDriver: | 826 // IPC::mojom::SimpleTestDriver: |
| 824 void ExpectValue(int32_t value) override { | 827 void ExpectValue(int32_t value) override { |
| 825 next_expected_value_ = value; | 828 next_expected_value_ = value; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 852 mojo::AssociatedBinding<IPC::mojom::SimpleTestDriver> binding_; | 855 mojo::AssociatedBinding<IPC::mojom::SimpleTestDriver> binding_; |
| 853 }; | 856 }; |
| 854 | 857 |
| 855 const int ListenerWithSimpleProxyAssociatedInterface::kNumMessages = 1000; | 858 const int ListenerWithSimpleProxyAssociatedInterface::kNumMessages = 1000; |
| 856 | 859 |
| 857 TEST_F(IPCChannelProxyMojoTest, ProxyThreadAssociatedInterface) { | 860 TEST_F(IPCChannelProxyMojoTest, ProxyThreadAssociatedInterface) { |
| 858 InitWithMojo("ProxyThreadAssociatedInterfaceClient"); | 861 InitWithMojo("ProxyThreadAssociatedInterfaceClient"); |
| 859 | 862 |
| 860 ListenerWithSimpleProxyAssociatedInterface listener; | 863 ListenerWithSimpleProxyAssociatedInterface listener; |
| 861 CreateProxy(&listener); | 864 CreateProxy(&listener); |
| 862 listener.RegisterInterfaceFactory(proxy()); | |
| 863 RunProxy(); | 865 RunProxy(); |
| 864 | 866 |
| 865 base::RunLoop().Run(); | 867 base::RunLoop().Run(); |
| 866 | 868 |
| 867 EXPECT_TRUE(WaitForClientShutdown()); | 869 EXPECT_TRUE(WaitForClientShutdown()); |
| 868 EXPECT_TRUE(listener.received_all_messages()); | 870 EXPECT_TRUE(listener.received_all_messages()); |
| 869 | 871 |
| 870 DestroyProxy(); | 872 DestroyProxy(); |
| 871 } | 873 } |
| 872 | 874 |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 Connect(&listener); | 1499 Connect(&listener); |
| 1498 | 1500 |
| 1499 base::RunLoop().Run(); | 1501 base::RunLoop().Run(); |
| 1500 | 1502 |
| 1501 Close(); | 1503 Close(); |
| 1502 } | 1504 } |
| 1503 | 1505 |
| 1504 #endif // OS_LINUX | 1506 #endif // OS_LINUX |
| 1505 | 1507 |
| 1506 } // namespace | 1508 } // namespace |
| OLD | NEW |