Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: mojo/edk/system/test/test_io_thread.cc

Issue 1473413002: EDK: Add a TestIOThread::IsCurrentAndRunning(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/test/test_io_thread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/edk/system/test/test_io_thread.h" 5 #include "mojo/edk/system/test/test_io_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/edk/util/waitable_event.h" 8 #include "mojo/edk/util/waitable_event.h"
9 9
10 using mojo::util::AutoResetWaitableEvent; 10 using mojo::util::AutoResetWaitableEvent;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 io_task_runner_ = MakeRefCounted<base_edk::PlatformTaskRunnerImpl>( 48 io_task_runner_ = MakeRefCounted<base_edk::PlatformTaskRunnerImpl>(
49 message_loop()->task_runner()); 49 message_loop()->task_runner());
50 } 50 }
51 51
52 void TestIOThread::Stop() { 52 void TestIOThread::Stop() {
53 // Note: It's okay to call |Stop()| even if the thread isn't running. 53 // Note: It's okay to call |Stop()| even if the thread isn't running.
54 io_thread_.Stop(); 54 io_thread_.Stop();
55 io_thread_started_ = false; 55 io_thread_started_ = false;
56 } 56 }
57 57
58 bool TestIOThread::IsCurrentAndRunning() const {
59 return base::MessageLoop::current() == io_thread_.message_loop() &&
60 io_thread_.message_loop()->is_running();
61 }
62
58 void TestIOThread::PostTask(const base::Closure& task) { 63 void TestIOThread::PostTask(const base::Closure& task) {
59 io_task_runner_->PostTask(task); 64 io_task_runner_->PostTask(task);
60 } 65 }
61 66
62 void TestIOThread::PostTaskAndWait(const base::Closure& task) { 67 void TestIOThread::PostTaskAndWait(const base::Closure& task) {
63 AutoResetWaitableEvent event; 68 AutoResetWaitableEvent event;
64 io_task_runner_->PostTask(base::Bind(&PostTaskAndWaitHelper, &event, task)); 69 io_task_runner_->PostTask(base::Bind(&PostTaskAndWaitHelper, &event, task));
65 event.Wait(); 70 event.Wait();
66 } 71 }
67 72
68 } // namespace test 73 } // namespace test
69 } // namespace system 74 } // namespace system
70 } // namespace mojo 75 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/test/test_io_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698