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

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

Issue 1367523003: EDK: mostly style fix: change TestIOThread::Mode to an enum class. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months 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/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/test/test_io_thread.h" 5 #include "mojo/edk/test/test_io_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace test { 12 namespace test {
13 13
14 namespace { 14 namespace {
15 15
16 void PostTaskAndWaitHelper(base::WaitableEvent* event, 16 void PostTaskAndWaitHelper(base::WaitableEvent* event,
17 const base::Closure& task) { 17 const base::Closure& task) {
18 task.Run(); 18 task.Run();
19 event->Signal(); 19 event->Signal();
20 } 20 }
21 21
22 } // namespace 22 } // namespace
23 23
24 TestIOThread::TestIOThread(Mode mode) 24 TestIOThread::TestIOThread(StartMode start_mode)
25 : io_thread_("test_io_thread"), io_thread_started_(false) { 25 : io_thread_("test_io_thread"), io_thread_started_(false) {
26 switch (mode) { 26 switch (start_mode) {
27 case kAutoStart: 27 case StartMode::AUTO:
28 Start(); 28 Start();
29 return; 29 return;
30 case kManualStart: 30 case StartMode::MANUAL:
31 return; 31 return;
32 } 32 }
33 CHECK(false) << "Invalid mode"; 33 CHECK(false) << "Invalid mode";
34 } 34 }
35 35
36 TestIOThread::~TestIOThread() { 36 TestIOThread::~TestIOThread() {
37 Stop(); 37 Stop();
38 } 38 }
39 39
40 void TestIOThread::Start() { 40 void TestIOThread::Start() {
(...skipping 17 matching lines...) Expand all
58 void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here, 58 void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here,
59 const base::Closure& task) { 59 const base::Closure& task) {
60 base::WaitableEvent event(false, false); 60 base::WaitableEvent event(false, false);
61 task_runner()->PostTask(from_here, 61 task_runner()->PostTask(from_here,
62 base::Bind(&PostTaskAndWaitHelper, &event, task)); 62 base::Bind(&PostTaskAndWaitHelper, &event, task));
63 event.Wait(); 63 event.Wait();
64 } 64 }
65 65
66 } // namespace test 66 } // namespace test
67 } // namespace mojo 67 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/test/test_io_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698