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 // TODO(vtl): The POSIX-specific bits have been factored out. Apply this test to | 5 // TODO(vtl): The POSIX-specific bits have been factored out. Apply this test to |
6 // non-POSIX once we have a non-POSIX implementation. | 6 // non-POSIX once we have a non-POSIX implementation. |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 scoped_refptr<base::TaskRunner> io_thread_task_runner() { | 86 scoped_refptr<base::TaskRunner> io_thread_task_runner() { |
87 return io_thread_message_loop()->message_loop_proxy(); | 87 return io_thread_message_loop()->message_loop_proxy(); |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 void SetUpOnIOThread() { | 91 void SetUpOnIOThread() { |
92 CHECK_EQ(base::MessageLoop::current(), io_thread_message_loop()); | 92 CHECK_EQ(base::MessageLoop::current(), io_thread_message_loop()); |
93 | 93 |
94 scoped_ptr<PlatformServerChannel> server_channel( | 94 PlatformChannelPair channel_pair; |
95 PlatformServerChannel::Create("channel")); | 95 platform_channels_[0] = channel_pair.CreateServerChannel(); |
96 CHECK(server_channel.get()); | 96 CHECK(platform_channels_[0].get()); |
97 CHECK(server_channel->is_valid()); | 97 CHECK(platform_channels_[0]->is_valid()); |
98 scoped_ptr<PlatformClientChannel> client_channel( | 98 platform_channels_[1] = channel_pair.CreateClientChannel(); |
99 server_channel->CreateClientChannel()); | 99 CHECK(platform_channels_[1].get()); |
100 CHECK(client_channel.get()); | 100 CHECK(platform_channels_[1]->is_valid()); |
101 CHECK(client_channel->is_valid()); | |
102 | |
103 platform_channels_[0] = server_channel.PassAs<PlatformChannel>(); | |
104 platform_channels_[1] = client_channel.PassAs<PlatformChannel>(); | |
105 } | 101 } |
106 | 102 |
107 void CreateAndInitChannel(unsigned channel_index) { | 103 void CreateAndInitChannel(unsigned channel_index) { |
108 CHECK_EQ(base::MessageLoop::current(), io_thread_message_loop()); | 104 CHECK_EQ(base::MessageLoop::current(), io_thread_message_loop()); |
109 CHECK(channel_index == 0 || channel_index == 1); | 105 CHECK(channel_index == 0 || channel_index == 1); |
110 CHECK(!channels_[channel_index].get()); | 106 CHECK(!channels_[channel_index].get()); |
111 | 107 |
112 channels_[channel_index] = new Channel(); | 108 channels_[channel_index] = new Channel(); |
113 CHECK(channels_[channel_index]->Init( | 109 CHECK(channels_[channel_index]->Init( |
114 platform_channels_[channel_index]->PassHandle())); | 110 platform_channels_[channel_index]->PassHandle())); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 MOJO_READ_MESSAGE_FLAG_NONE)); | 420 MOJO_READ_MESSAGE_FLAG_NONE)); |
425 EXPECT_EQ(sizeof(hello), static_cast<size_t>(buffer_size)); | 421 EXPECT_EQ(sizeof(hello), static_cast<size_t>(buffer_size)); |
426 EXPECT_EQ(0, strcmp(buffer, hello)); | 422 EXPECT_EQ(0, strcmp(buffer, hello)); |
427 | 423 |
428 // And MP 1, port 1. | 424 // And MP 1, port 1. |
429 mp_1->Close(1); | 425 mp_1->Close(1); |
430 } | 426 } |
431 } // namespace | 427 } // namespace |
432 } // namespace system | 428 } // namespace system |
433 } // namespace mojo | 429 } // namespace mojo |
OLD | NEW |