summaryrefslogtreecommitdiffstats
path: root/remoting/host/chromoting_host_context_unittest.cc
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 23:40:51 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-05 23:40:51 +0000
commit32debfbf3a9e2e5784f34907eaaf1132cfbf02f5 (patch)
tree19d8c1c8a680511c9aaaf615fff14166e11d1cba /remoting/host/chromoting_host_context_unittest.cc
parent0b53a370894631f31d1ef02bac9aaff270da4700 (diff)
downloadchromium_src-32debfbf3a9e2e5784f34907eaaf1132cfbf02f5.zip
chromium_src-32debfbf3a9e2e5784f34907eaaf1132cfbf02f5.tar.gz
chromium_src-32debfbf3a9e2e5784f34907eaaf1132cfbf02f5.tar.bz2
Use AutoThread in ChromotingHostContext & NPAPI plugin.
Callers now create ChromotingHostContext to create a set of threads for host tasks to run on, and pass the threads' TaskRunners to each host component explicitly. The ChromotingHostContext can then be torn down as soon as the caller no longer needs to create new components using the threads, and the threads themselves will exit only when the created components no longer require them. This is a re-re-land of 11094056; the re-land failed due to a rebasing typo, and some over-zealous thread checking in ChromotingHostContext. BUG=145856 TEST=Chromoting IT2Me & Me2Me hosts start correctly, can be connected to, and shutdown cleanly. Unit-tests pass. Review URL: https://chromiumcodereview.appspot.com/11412305 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171358 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/chromoting_host_context_unittest.cc')
-rw-r--r--remoting/host/chromoting_host_context_unittest.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/remoting/host/chromoting_host_context_unittest.cc b/remoting/host/chromoting_host_context_unittest.cc
index 3c3858e..7e1b251 100644
--- a/remoting/host/chromoting_host_context_unittest.cc
+++ b/remoting/host/chromoting_host_context_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/message_loop.h"
-#include "base/message_loop_proxy.h"
+#include "base/run_loop.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -14,17 +14,25 @@ namespace remoting {
// operates properly and all threads and message loops are valid.
TEST(ChromotingHostContextTest, StartAndStop) {
MessageLoopForUI message_loop;
- ChromotingHostContext context(new AutoThreadTaskRunner(
- base::MessageLoopProxy::current()));
+ base::RunLoop run_loop;
- context.Start();
- EXPECT_TRUE(context.audio_task_runner());
- EXPECT_TRUE(context.video_capture_task_runner());
- EXPECT_TRUE(context.video_encode_task_runner());
- EXPECT_TRUE(context.file_task_runner());
- EXPECT_TRUE(context.input_task_runner());
- EXPECT_TRUE(context.network_task_runner());
- EXPECT_TRUE(context.ui_task_runner());
+ scoped_ptr<ChromotingHostContext> context =
+ ChromotingHostContext::Create(new AutoThreadTaskRunner(
+ message_loop.message_loop_proxy(), run_loop.QuitClosure()));
+
+ EXPECT_TRUE(context);
+ if (!context)
+ return;
+ EXPECT_TRUE(context->audio_task_runner());
+ EXPECT_TRUE(context->video_capture_task_runner());
+ EXPECT_TRUE(context->video_encode_task_runner());
+ EXPECT_TRUE(context->file_task_runner());
+ EXPECT_TRUE(context->input_task_runner());
+ EXPECT_TRUE(context->network_task_runner());
+ EXPECT_TRUE(context->ui_task_runner());
+
+ context.reset();
+ run_loop.Run();
}
} // namespace remoting