| 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 // This file tests both |RemoteProducerDataPipeImpl| and | 5 // This file tests both |RemoteProducerDataPipeImpl| and |
| 6 // |RemoteConsumerDataPipeImpl|. | 6 // |RemoteConsumerDataPipeImpl|. |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | |
| 15 #include "mojo/edk/embedder/platform_channel_pair.h" | 14 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 16 #include "mojo/edk/embedder/simple_platform_support.h" | 15 #include "mojo/edk/embedder/simple_platform_support.h" |
| 17 #include "mojo/edk/system/channel.h" | 16 #include "mojo/edk/system/channel.h" |
| 18 #include "mojo/edk/system/channel_endpoint.h" | 17 #include "mojo/edk/system/channel_endpoint.h" |
| 19 #include "mojo/edk/system/data_pipe.h" | 18 #include "mojo/edk/system/data_pipe.h" |
| 20 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" | 19 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
| 21 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 20 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| 22 #include "mojo/edk/system/memory.h" | 21 #include "mojo/edk/system/memory.h" |
| 23 #include "mojo/edk/system/message_pipe.h" | 22 #include "mojo/edk/system/message_pipe.h" |
| 24 #include "mojo/edk/system/raw_channel.h" | 23 #include "mojo/edk/system/raw_channel.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return; | 83 return; |
| 85 message_pipes_[i]->Close(0); | 84 message_pipes_[i]->Close(0); |
| 86 message_pipes_[i] = nullptr; | 85 message_pipes_[i] = nullptr; |
| 87 } | 86 } |
| 88 | 87 |
| 89 private: | 88 private: |
| 90 // TODO(vtl): The arguments should be rvalue references, but that doesn't | 89 // TODO(vtl): The arguments should be rvalue references, but that doesn't |
| 91 // currently work correctly with base::Bind. | 90 // currently work correctly with base::Bind. |
| 92 void SetUpOnIOThread(RefPtr<ChannelEndpoint> ep0, | 91 void SetUpOnIOThread(RefPtr<ChannelEndpoint> ep0, |
| 93 RefPtr<ChannelEndpoint> ep1) { | 92 RefPtr<ChannelEndpoint> ep1) { |
| 94 CHECK_EQ(base::MessageLoop::current(), io_thread_.message_loop()); | 93 CHECK(io_thread_.IsCurrentAndRunning()); |
| 95 | 94 |
| 96 embedder::PlatformChannelPair channel_pair; | 95 embedder::PlatformChannelPair channel_pair; |
| 97 channels_[0] = MakeRefCounted<Channel>(&platform_support_); | 96 channels_[0] = MakeRefCounted<Channel>(&platform_support_); |
| 98 channels_[0]->Init(RawChannel::Create(channel_pair.PassServerHandle())); | 97 channels_[0]->Init(RawChannel::Create(channel_pair.PassServerHandle())); |
| 99 channels_[0]->SetBootstrapEndpoint(std::move(ep0)); | 98 channels_[0]->SetBootstrapEndpoint(std::move(ep0)); |
| 100 channels_[1] = MakeRefCounted<Channel>(&platform_support_); | 99 channels_[1] = MakeRefCounted<Channel>(&platform_support_); |
| 101 channels_[1]->Init(RawChannel::Create(channel_pair.PassClientHandle())); | 100 channels_[1]->Init(RawChannel::Create(channel_pair.PassClientHandle())); |
| 102 channels_[1]->SetBootstrapEndpoint(std::move(ep1)); | 101 channels_[1]->SetBootstrapEndpoint(std::move(ep1)); |
| 103 } | 102 } |
| 104 | 103 |
| 105 void TearDownOnIOThread() { | 104 void TearDownOnIOThread() { |
| 106 CHECK_EQ(base::MessageLoop::current(), io_thread_.message_loop()); | 105 CHECK(io_thread_.IsCurrentAndRunning()); |
| 107 | 106 |
| 108 if (channels_[0]) { | 107 if (channels_[0]) { |
| 109 channels_[0]->Shutdown(); | 108 channels_[0]->Shutdown(); |
| 110 channels_[0] = nullptr; | 109 channels_[0] = nullptr; |
| 111 } | 110 } |
| 112 if (channels_[1]) { | 111 if (channels_[1]) { |
| 113 channels_[1]->Shutdown(); | 112 channels_[1]->Shutdown(); |
| 114 channels_[1] = nullptr; | 113 channels_[1] = nullptr; |
| 115 } | 114 } |
| 116 } | 115 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 EXPECT_EQ(123456, elements[0]); | 501 EXPECT_EQ(123456, elements[0]); |
| 503 EXPECT_EQ(789012, elements[1]); | 502 EXPECT_EQ(789012, elements[1]); |
| 504 EXPECT_EQ(0, elements[2]); | 503 EXPECT_EQ(0, elements[2]); |
| 505 | 504 |
| 506 consumer->Close(); | 505 consumer->Close(); |
| 507 } | 506 } |
| 508 | 507 |
| 509 } // namespace | 508 } // namespace |
| 510 } // namespace system | 509 } // namespace system |
| 511 } // namespace mojo | 510 } // namespace mojo |
| OLD | NEW |