| 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 "mojo/edk/system/channel_manager.h" | 5 #include "mojo/edk/system/channel_manager.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "base/threading/simple_thread.h" | |
| 13 #include "mojo/edk/embedder/platform_channel_pair.h" | 12 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 14 #include "mojo/edk/embedder/simple_platform_support.h" | 13 #include "mojo/edk/embedder/simple_platform_support.h" |
| 15 #include "mojo/edk/system/channel.h" | 14 #include "mojo/edk/system/channel.h" |
| 16 #include "mojo/edk/system/channel_endpoint.h" | 15 #include "mojo/edk/system/channel_endpoint.h" |
| 17 #include "mojo/edk/system/message_pipe_dispatcher.h" | 16 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 17 #include "mojo/edk/test/simple_test_thread.h" |
| 18 #include "mojo/public/cpp/system/macros.h" | 18 #include "mojo/public/cpp/system/macros.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 namespace system { | 22 namespace system { |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class ChannelManagerTest : public testing::Test { | 25 class ChannelManagerTest : public testing::Test { |
| 26 public: | 26 public: |
| 27 ChannelManagerTest() | 27 ChannelManagerTest() |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 channel_manager().ShutdownChannelOnIOThread(id1); | 96 channel_manager().ShutdownChannelOnIOThread(id1); |
| 97 EXPECT_TRUE(ch1->HasOneRef()); | 97 EXPECT_TRUE(ch1->HasOneRef()); |
| 98 channel_manager().ShutdownChannelOnIOThread(id2); | 98 channel_manager().ShutdownChannelOnIOThread(id2); |
| 99 EXPECT_TRUE(ch2->HasOneRef()); | 99 EXPECT_TRUE(ch2->HasOneRef()); |
| 100 | 100 |
| 101 EXPECT_EQ(MOJO_RESULT_OK, d1->Close()); | 101 EXPECT_EQ(MOJO_RESULT_OK, d1->Close()); |
| 102 EXPECT_EQ(MOJO_RESULT_OK, d2->Close()); | 102 EXPECT_EQ(MOJO_RESULT_OK, d2->Close()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 class OtherThread : public base::SimpleThread { | 105 class OtherThread : public mojo::test::SimpleTestThread { |
| 106 public: | 106 public: |
| 107 // Note: There should be no other refs to the channel identified by | 107 // Note: There should be no other refs to the channel identified by |
| 108 // |channel_id| outside the channel manager. | 108 // |channel_id| outside the channel manager. |
| 109 OtherThread(scoped_refptr<base::TaskRunner> task_runner, | 109 OtherThread(scoped_refptr<base::TaskRunner> task_runner, |
| 110 ChannelManager* channel_manager, | 110 ChannelManager* channel_manager, |
| 111 ChannelId channel_id, | 111 ChannelId channel_id, |
| 112 const base::Closure& quit_closure) | 112 const base::Closure& quit_closure) |
| 113 : base::SimpleThread("other_thread"), | 113 : task_runner_(task_runner), |
| 114 task_runner_(task_runner), | |
| 115 channel_manager_(channel_manager), | 114 channel_manager_(channel_manager), |
| 116 channel_id_(channel_id), | 115 channel_id_(channel_id), |
| 117 quit_closure_(quit_closure) {} | 116 quit_closure_(quit_closure) {} |
| 118 ~OtherThread() override {} | 117 ~OtherThread() override {} |
| 119 | 118 |
| 120 private: | 119 private: |
| 121 void Run() override { | 120 void Run() override { |
| 122 // TODO(vtl): Once we have a way of creating a channel from off the I/O | 121 // TODO(vtl): Once we have a way of creating a channel from off the I/O |
| 123 // thread, do that here instead. | 122 // thread, do that here instead. |
| 124 | 123 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 166 |
| 168 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); | 167 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); |
| 169 } | 168 } |
| 170 | 169 |
| 171 // TODO(vtl): Test |CreateChannelWithoutBootstrapOnIOThread()|. (This will | 170 // TODO(vtl): Test |CreateChannelWithoutBootstrapOnIOThread()|. (This will |
| 172 // require additional functionality in |Channel|.) | 171 // require additional functionality in |Channel|.) |
| 173 | 172 |
| 174 } // namespace | 173 } // namespace |
| 175 } // namespace system | 174 } // namespace system |
| 176 } // namespace mojo | 175 } // namespace mojo |
| OLD | NEW |