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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 test_io_thread_.Start(); | 52 test_io_thread_.Start(); |
53 test_io_thread_.PostTaskAndWait( | 53 test_io_thread_.PostTaskAndWait( |
54 FROM_HERE, | 54 FROM_HERE, |
55 base::Bind(&ChannelThread::InitChannelOnIOThread, | 55 base::Bind(&ChannelThread::InitChannelOnIOThread, |
56 base::Unretained(this), | 56 base::Unretained(this), |
57 base::Passed(&platform_handle), | 57 base::Passed(&platform_handle), |
58 message_pipe)); | 58 message_pipe)); |
59 } | 59 } |
60 | 60 |
61 void Stop() { | 61 void Stop() { |
62 if (channel_) { | 62 if (channel_.get()) { |
63 // Hack to flush write buffers before quitting. | 63 // Hack to flush write buffers before quitting. |
64 // TODO(vtl): Remove this once |Channel| has a | 64 // TODO(vtl): Remove this once |Channel| has a |
65 // |FlushWriteBufferAndShutdown()| (or whatever). | 65 // |FlushWriteBufferAndShutdown()| (or whatever). |
66 while (!channel_->IsWriteBufferEmpty()) | 66 while (!channel_->IsWriteBufferEmpty()) |
67 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); | 67 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); |
68 | 68 |
69 test_io_thread_.PostTaskAndWait( | 69 test_io_thread_.PostTaskAndWait( |
70 FROM_HERE, | 70 FROM_HERE, |
71 base::Bind(&ChannelThread::ShutdownChannelOnIOThread, | 71 base::Bind(&ChannelThread::ShutdownChannelOnIOThread, |
72 base::Unretained(this))); | 72 base::Unretained(this))); |
(...skipping 18 matching lines...) Expand all Loading... |
91 // receive/process messages (which it can do as soon as it's hooked up to | 91 // receive/process messages (which it can do as soon as it's hooked up to |
92 // the IO thread message loop, and that message loop runs) before the | 92 // the IO thread message loop, and that message loop runs) before the |
93 // message pipe endpoint is attached. | 93 // message pipe endpoint is attached. |
94 CHECK_EQ(channel_->AttachMessagePipeEndpoint(message_pipe, 1), | 94 CHECK_EQ(channel_->AttachMessagePipeEndpoint(message_pipe, 1), |
95 Channel::kBootstrapEndpointId); | 95 Channel::kBootstrapEndpointId); |
96 CHECK(channel_->RunMessagePipeEndpoint(Channel::kBootstrapEndpointId, | 96 CHECK(channel_->RunMessagePipeEndpoint(Channel::kBootstrapEndpointId, |
97 Channel::kBootstrapEndpointId)); | 97 Channel::kBootstrapEndpointId)); |
98 } | 98 } |
99 | 99 |
100 void ShutdownChannelOnIOThread() { | 100 void ShutdownChannelOnIOThread() { |
101 CHECK(channel_); | 101 CHECK(channel_.get()); |
102 channel_->Shutdown(); | 102 channel_->Shutdown(); |
103 channel_ = NULL; | 103 channel_ = NULL; |
104 } | 104 } |
105 | 105 |
106 embedder::PlatformSupport* const platform_support_; | 106 embedder::PlatformSupport* const platform_support_; |
107 test::TestIOThread test_io_thread_; | 107 test::TestIOThread test_io_thread_; |
108 scoped_refptr<Channel> channel_; | 108 scoped_refptr<Channel> channel_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(ChannelThread); | 110 DISALLOW_COPY_AND_ASSIGN(ChannelThread); |
111 }; | 111 }; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 Init(mp); | 435 Init(mp); |
436 | 436 |
437 // Make a shared buffer. | 437 // Make a shared buffer. |
438 scoped_refptr<SharedBufferDispatcher> dispatcher; | 438 scoped_refptr<SharedBufferDispatcher> dispatcher; |
439 EXPECT_EQ(MOJO_RESULT_OK, | 439 EXPECT_EQ(MOJO_RESULT_OK, |
440 SharedBufferDispatcher::Create( | 440 SharedBufferDispatcher::Create( |
441 platform_support(), | 441 platform_support(), |
442 SharedBufferDispatcher::kDefaultCreateOptions, | 442 SharedBufferDispatcher::kDefaultCreateOptions, |
443 100, | 443 100, |
444 &dispatcher)); | 444 &dispatcher)); |
445 ASSERT_TRUE(dispatcher); | 445 ASSERT_TRUE(dispatcher.get()); |
446 | 446 |
447 // Make a mapping. | 447 // Make a mapping. |
448 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; | 448 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping; |
449 EXPECT_EQ(MOJO_RESULT_OK, | 449 EXPECT_EQ(MOJO_RESULT_OK, |
450 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); | 450 dispatcher->MapBuffer(0, 100, MOJO_MAP_BUFFER_FLAG_NONE, &mapping)); |
451 ASSERT_TRUE(mapping); | 451 ASSERT_TRUE(mapping); |
452 ASSERT_TRUE(mapping->GetBase()); | 452 ASSERT_TRUE(mapping->GetBase()); |
453 ASSERT_EQ(100u, mapping->GetLength()); | 453 ASSERT_EQ(100u, mapping->GetLength()); |
454 | 454 |
455 // Send the shared buffer. | 455 // Send the shared buffer. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 EXPECT_EQ(0u, hss.satisfiable_signals); | 630 EXPECT_EQ(0u, hss.satisfiable_signals); |
631 | 631 |
632 mp->Close(0); | 632 mp->Close(0); |
633 | 633 |
634 EXPECT_EQ(0, helper()->WaitForChildShutdown()); | 634 EXPECT_EQ(0, helper()->WaitForChildShutdown()); |
635 } | 635 } |
636 | 636 |
637 } // namespace | 637 } // namespace |
638 } // namespace system | 638 } // namespace system |
639 } // namespace mojo | 639 } // namespace mojo |
OLD | NEW |