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 contains tests that are shared between different implementations of | 5 // This file contains tests that are shared between different implementations of |
6 // |DataPipeImpl|. | 6 // |DataPipeImpl|. |
7 | 7 |
8 #include "mojo/edk/system/data_pipe_impl.h" | 8 #include "mojo/edk/system/data_pipe_impl.h" |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/message_loop/message_loop.h" | |
18 #include "mojo/edk/embedder/platform_channel_pair.h" | 17 #include "mojo/edk/embedder/platform_channel_pair.h" |
19 #include "mojo/edk/embedder/simple_platform_support.h" | 18 #include "mojo/edk/embedder/simple_platform_support.h" |
20 #include "mojo/edk/system/channel.h" | 19 #include "mojo/edk/system/channel.h" |
21 #include "mojo/edk/system/channel_endpoint.h" | 20 #include "mojo/edk/system/channel_endpoint.h" |
22 #include "mojo/edk/system/data_pipe.h" | 21 #include "mojo/edk/system/data_pipe.h" |
23 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" | 22 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
24 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 23 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
25 #include "mojo/edk/system/memory.h" | 24 #include "mojo/edk/system/memory.h" |
26 #include "mojo/edk/system/message_pipe.h" | 25 #include "mojo/edk/system/message_pipe.h" |
27 #include "mojo/edk/system/raw_channel.h" | 26 #include "mojo/edk/system/raw_channel.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (!message_pipes_[i]) | 315 if (!message_pipes_[i]) |
317 return; | 316 return; |
318 message_pipes_[i]->Close(0); | 317 message_pipes_[i]->Close(0); |
319 message_pipes_[i] = nullptr; | 318 message_pipes_[i] = nullptr; |
320 } | 319 } |
321 | 320 |
322 // TODO(vtl): The arguments should be rvalue references, but that doesn't | 321 // TODO(vtl): The arguments should be rvalue references, but that doesn't |
323 // currently work correctly with base::Bind. | 322 // currently work correctly with base::Bind. |
324 void SetUpOnIOThread(RefPtr<ChannelEndpoint> ep0, | 323 void SetUpOnIOThread(RefPtr<ChannelEndpoint> ep0, |
325 RefPtr<ChannelEndpoint> ep1) { | 324 RefPtr<ChannelEndpoint> ep1) { |
326 CHECK_EQ(base::MessageLoop::current(), io_thread_.message_loop()); | 325 CHECK(io_thread_.IsCurrentAndRunning()); |
327 | 326 |
328 embedder::PlatformChannelPair channel_pair; | 327 embedder::PlatformChannelPair channel_pair; |
329 channels_[0] = MakeRefCounted<Channel>(&platform_support_); | 328 channels_[0] = MakeRefCounted<Channel>(&platform_support_); |
330 channels_[0]->Init(RawChannel::Create(channel_pair.PassServerHandle())); | 329 channels_[0]->Init(RawChannel::Create(channel_pair.PassServerHandle())); |
331 channels_[0]->SetBootstrapEndpoint(std::move(ep0)); | 330 channels_[0]->SetBootstrapEndpoint(std::move(ep0)); |
332 channels_[1] = MakeRefCounted<Channel>(&platform_support_); | 331 channels_[1] = MakeRefCounted<Channel>(&platform_support_); |
333 channels_[1]->Init(RawChannel::Create(channel_pair.PassClientHandle())); | 332 channels_[1]->Init(RawChannel::Create(channel_pair.PassClientHandle())); |
334 channels_[1]->SetBootstrapEndpoint(std::move(ep1)); | 333 channels_[1]->SetBootstrapEndpoint(std::move(ep1)); |
335 } | 334 } |
336 | 335 |
337 void TearDownOnIOThread() { | 336 void TearDownOnIOThread() { |
338 CHECK_EQ(base::MessageLoop::current(), io_thread_.message_loop()); | 337 CHECK(io_thread_.IsCurrentAndRunning()); |
339 | 338 |
340 if (channels_[0]) { | 339 if (channels_[0]) { |
341 channels_[0]->Shutdown(); | 340 channels_[0]->Shutdown(); |
342 channels_[0] = nullptr; | 341 channels_[0] = nullptr; |
343 } | 342 } |
344 if (channels_[1]) { | 343 if (channels_[1]) { |
345 channels_[1]->Shutdown(); | 344 channels_[1]->Shutdown(); |
346 channels_[1] = nullptr; | 345 channels_[1] = nullptr; |
347 } | 346 } |
348 } | 347 } |
(...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 test::Sleep(10u); | 2494 test::Sleep(10u); |
2496 | 2495 |
2497 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); | 2496 EXPECT_EQ(MOJO_RESULT_OK, this->ConsumerEndReadData(num_bytes)); |
2498 | 2497 |
2499 this->ConsumerClose(); | 2498 this->ConsumerClose(); |
2500 } | 2499 } |
2501 | 2500 |
2502 } // namespace | 2501 } // namespace |
2503 } // namespace system | 2502 } // namespace system |
2504 } // namespace mojo | 2503 } // namespace mojo |
OLD | NEW |