Chromium Code Reviews| Index: base/test/test_io_thread.cc |
| diff --git a/mojo/system/test_utils.cc b/base/test/test_io_thread.cc |
| similarity index 50% |
| copy from mojo/system/test_utils.cc |
| copy to base/test/test_io_thread.cc |
| index d4e8d28ea0d786ba7852a90817bd7a95d100aa81..26c8a8a020b9dd31fd4f2d701cf3c95856ebfe44 100644 |
| --- a/mojo/system/test_utils.cc |
| +++ b/base/test/test_io_thread.cc |
| @@ -1,18 +1,12 @@ |
| -// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
viettrungluu
2014/08/27 16:47:18
nit: "Copyright 2014" (note: no "(c)").
(You migh
Hajime Morrita
2014/08/27 17:47:43
Done.
|
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "mojo/system/test_utils.h" |
| +#include "base/test/test_io_thread.h" |
| #include "base/bind.h" |
| #include "base/callback.h" |
| #include "base/synchronization/waitable_event.h" |
| -#include "base/test/test_timeouts.h" |
| -#include "build/build_config.h" |
| - |
| -namespace mojo { |
| -namespace system { |
| -namespace test { |
| namespace { |
| @@ -24,32 +18,7 @@ void PostTaskAndWaitHelper(base::WaitableEvent* event, |
| } // namespace |
| -void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner, |
| - const tracked_objects::Location& from_here, |
| - const base::Closure& task) { |
| - base::WaitableEvent event(false, false); |
| - task_runner->PostTask(from_here, |
| - base::Bind(&PostTaskAndWaitHelper, &event, task)); |
| - event.Wait(); |
| -} |
| - |
| -base::TimeDelta EpsilonTimeout() { |
| -// Originally, our epsilon timeout was 10 ms, which was mostly fine but flaky on |
| -// some Windows bots. I don't recall ever seeing flakes on other bots. At 30 ms |
| -// tests seem reliable on Windows bots, but not at 25 ms. We'd like this timeout |
| -// to be as small as possible (see the description in the .h file). |
| -// |
| -// Currently, |tiny_timeout()| is usually 100 ms (possibly scaled under ASAN, |
| -// etc.). Based on this, set it to (usually be) 30 ms on Windows and 20 ms |
| -// elsewhere. |
| -#if defined(OS_WIN) |
| - return (TestTimeouts::tiny_timeout() * 3) / 10; |
| -#else |
| - return (TestTimeouts::tiny_timeout() * 2) / 10; |
| -#endif |
| -} |
| - |
| -// TestIOThread ---------------------------------------------------------------- |
| +namespace base { |
| TestIOThread::TestIOThread(Mode mode) |
| : io_thread_("test_io_thread"), io_thread_started_(false) { |
| @@ -87,9 +56,10 @@ void TestIOThread::PostTask(const tracked_objects::Location& from_here, |
| void TestIOThread::PostTaskAndWait(const tracked_objects::Location& from_here, |
| const base::Closure& task) { |
| - ::mojo::system::test::PostTaskAndWait(task_runner(), from_here, task); |
| + base::WaitableEvent event(false, false); |
| + task_runner()->PostTask(from_here, |
| + base::Bind(&PostTaskAndWaitHelper, &event, task)); |
| + event.Wait(); |
| } |
| -} // namespace test |
| -} // namespace system |
| -} // namespace mojo |
| +} // namespace base |