OLD | NEW |
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_CAST_TEST_FAKE_TASK_RUNNER_H_ | 5 #ifndef MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ |
6 #define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ | 6 #define MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 const base::Closure& task, | 28 const base::Closure& 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 const base::Closure& task, | 35 const base::Closure& task, |
36 base::TimeDelta delay) final; | 36 base::TimeDelta delay) final; |
37 | 37 |
| 38 std::string GetThreadName() const override; |
| 39 |
38 protected: | 40 protected: |
39 ~FakeSingleThreadTaskRunner() final; | 41 ~FakeSingleThreadTaskRunner() final; |
40 | 42 |
41 private: | 43 private: |
42 base::SimpleTestTickClock* const clock_; | 44 base::SimpleTestTickClock* const clock_; |
43 | 45 |
44 // A compound key is used to ensure FIFO execution of delayed tasks scheduled | 46 // 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 | 47 // for the same point-in-time. The second part of the key is simply a FIFO |
46 // sequence number. | 48 // sequence number. |
47 using TaskKey = std::pair<base::TimeTicks, unsigned int>; | 49 using TaskKey = std::pair<base::TimeTicks, unsigned int>; |
48 | 50 |
49 // Note: The std::map data structure was chosen because the entire | 51 // Note: The std::map data structure was chosen because the entire |
50 // cast_unittests suite performed 20% faster than when using | 52 // cast_unittests suite performed 20% faster than when using |
51 // std::priority_queue. http://crbug.com/530842 | 53 // std::priority_queue. http://crbug.com/530842 |
52 std::map<TaskKey, base::Closure> tasks_; | 54 std::map<TaskKey, base::Closure> tasks_; |
53 | 55 |
54 bool fail_on_next_task_; | 56 bool fail_on_next_task_; |
55 | 57 |
56 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner); | 58 DISALLOW_COPY_AND_ASSIGN(FakeSingleThreadTaskRunner); |
57 }; | 59 }; |
58 | 60 |
59 } // namespace media | 61 } // namespace media |
60 | 62 |
61 #endif // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ | 63 #endif // MEDIA_CAST_TEST_FAKE_TASK_RUNNER_H_ |
OLD | NEW |