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

Side by Side Diff: base/test/test_mock_time_task_runner.cc

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/test/test_mock_time_task_runner.h" 5 #include "base/test/test_mock_time_task_runner.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/threading/thread_task_runner_handle.h"
11 #include "base/time/clock.h" 13 #include "base/time/clock.h"
12 #include "base/time/tick_clock.h" 14 #include "base/time/tick_clock.h"
13 15
14 namespace base { 16 namespace base {
15 17
16 namespace { 18 namespace {
17 19
18 // MockTickClock -------------------------------------------------------------- 20 // MockTickClock --------------------------------------------------------------
19 21
20 // TickClock that always returns the then-current mock time ticks of 22 // TickClock that always returns the then-current mock time ticks of
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 AutoLock scoped_lock(tasks_lock_); 261 AutoLock scoped_lock(tasks_lock_);
260 if (!tasks_.empty() && 262 if (!tasks_.empty() &&
261 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { 263 (tasks_.top().GetTimeToRun() - reference) <= max_delta) {
262 *next_task = tasks_.top(); 264 *next_task = tasks_.top();
263 tasks_.pop(); 265 tasks_.pop();
264 return true; 266 return true;
265 } 267 }
266 return false; 268 return false;
267 } 269 }
268 270
271 // ScopedTestMockTimeTaskRunner -----------------------------------------------
272
273 ScopedMockTaskRunnerWrapper::ScopedMockTaskRunnerWrapper() {
gab 2016/11/15 19:52:01 DCHECK(base::MessageLoop::current());
gab 2016/11/15 19:52:01 : task_runner_(new base::TestMockTimeTaskRunner),
bruthig 2016/11/15 21:52:44 Done.
bruthig 2016/11/15 21:52:44 Done.
274 task_runner_ = new base::TestMockTimeTaskRunner;
275 previous_task_runner_ = base::ThreadTaskRunnerHandle::Get();
276 base::MessageLoop::current()->SetTaskRunner(task_runner_);
277 }
278
279 ScopedMockTaskRunnerWrapper::~ScopedMockTaskRunnerWrapper() {
gab 2016/11/15 19:52:01 DCHECK(previous_task_runner_->RunsTasksOnCurrentTh
bruthig 2016/11/15 21:52:44 Done.
280 DCHECK_EQ(task_runner_, base::ThreadTaskRunnerHandle::Get());
281 task_runner_->ClearPendingTasks();
gab 2016/11/15 19:52:01 This feels wrong. Remaining tasks should be transf
bruthig 2016/11/15 21:52:44 Not exactly sure if I implemented what you were as
282 base::MessageLoop::current()->SetTaskRunner(previous_task_runner_);
gab 2016/11/15 19:52:01 ->SetTaskRunner(std::move(previous_task_runner_));
bruthig 2016/11/15 21:52:44 Done.
283 }
284
269 } // namespace base 285 } // namespace base
OLDNEW
« base/test/test_mock_time_task_runner.h ('K') | « base/test/test_mock_time_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698