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

Side by Side Diff: media/base/fake_single_thread_task_runner.h

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 years, 8 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 | « ios/web/web_thread_impl.cc ('k') | media/base/fake_single_thread_task_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_ 5 #ifndef MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_
6 #define MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_ 6 #define MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/test/simple_test_tick_clock.h" 13 #include "base/test/simple_test_tick_clock.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { 17 class FakeSingleThreadTaskRunner : public base::SingleThreadTaskRunner {
18 public: 18 public:
19 explicit FakeSingleThreadTaskRunner(base::SimpleTestTickClock* clock); 19 explicit FakeSingleThreadTaskRunner(base::SimpleTestTickClock* clock);
20 20
21 void RunTasks(); 21 void RunTasks();
22 22
23 // Note: Advances |clock_|. 23 // Note: Advances |clock_|.
24 void Sleep(base::TimeDelta t); 24 void Sleep(base::TimeDelta t);
25 25
26 // base::SingleThreadTaskRunner implementation. 26 // base::SingleThreadTaskRunner implementation.
27 bool PostDelayedTask(const tracked_objects::Location& from_here, 27 bool PostDelayedTask(const tracked_objects::Location& from_here,
28 base::Closure task, 28 base::OnceClosure task,
29 base::TimeDelta delay) final; 29 base::TimeDelta delay) final;
30 30
31 bool RunsTasksOnCurrentThread() const final; 31 bool RunsTasksOnCurrentThread() const final;
32 32
33 // This function is currently not used, and will return false. 33 // This function is currently not used, and will return false.
34 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 34 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
35 base::Closure task, 35 base::OnceClosure task,
36 base::TimeDelta delay) final; 36 base::TimeDelta delay) final;
37 37
38 protected: 38 protected:
39 ~FakeSingleThreadTaskRunner() final; 39 ~FakeSingleThreadTaskRunner() final;
40 40
41 private: 41 private:
42 base::SimpleTestTickClock* const clock_; 42 base::SimpleTestTickClock* const clock_;
43 43
44 // A compound key is used to ensure FIFO execution of delayed tasks scheduled 44 // A compound key is used to ensure FIFO execution of delayed tasks scheduled
45 // for the same point-in-time. The second part of the key is simply a FIFO 45 // for the same point-in-time. The second part of the key is simply a FIFO
46 // sequence number. 46 // sequence number.
47 using TaskKey = std::pair<base::TimeTicks, unsigned int>; 47 using TaskKey = std::pair<base::TimeTicks, unsigned int>;
48 48
49 // Note: The std::map data structure was chosen because the entire 49 // Note: The std::map data structure was chosen because the entire
50 // cast_unittests suite performed 20% faster than when using 50 // cast_unittests suite performed 20% faster than when using
51 // std::priority_queue. http://crbug.com/530842 51 // std::priority_queue. http://crbug.com/530842
52 std::map<TaskKey, base::Closure> tasks_; 52 std::map<TaskKey, base::OnceClosure> tasks_;
53 53
54 bool fail_on_next_task_; 54 bool fail_on_next_task_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner); 56 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner);
57 }; 57 };
58 58
59 } // namespace media 59 } // namespace media
60 60
61 #endif // MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_ 61 #endif // MEDIA_BASE_FAKE_SINGLE_THREAD_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « ios/web/web_thread_impl.cc ('k') | media/base/fake_single_thread_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698