OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 DCHECK(IsActive()); | 81 DCHECK(IsActive()); |
82 double current = TimerMonotonicallyIncreasingTime(); | 82 double current = TimerMonotonicallyIncreasingTime(); |
83 if (next_fire_time_ < current) | 83 if (next_fire_time_ < current) |
84 return 0; | 84 return 0; |
85 return next_fire_time_ - current; | 85 return next_fire_time_ - current; |
86 } | 86 } |
87 | 87 |
88 void TimerBase::MoveToNewTaskRunner(RefPtr<WebTaskRunner> task_runner) { | 88 void TimerBase::MoveToNewTaskRunner(RefPtr<WebTaskRunner> task_runner) { |
89 #if DCHECK_IS_ON() | 89 #if DCHECK_IS_ON() |
90 DCHECK_EQ(thread_, CurrentThread()); | 90 DCHECK_EQ(thread_, CurrentThread()); |
91 DCHECK(task_runner->RunsTasksOnCurrentThread()); | 91 DCHECK(task_runner->RunsTasksInCurrentSequence()); |
92 #endif | 92 #endif |
93 // If the underlying task runner stays the same, ignore it. | 93 // If the underlying task runner stays the same, ignore it. |
94 if (web_task_runner_->ToSingleThreadTaskRunner() == | 94 if (web_task_runner_->ToSingleThreadTaskRunner() == |
95 task_runner->ToSingleThreadTaskRunner()) { | 95 task_runner->ToSingleThreadTaskRunner()) { |
96 return; | 96 return; |
97 } | 97 } |
98 | 98 |
99 bool active = IsActive(); | 99 bool active = IsActive(); |
100 weak_ptr_factory_.RevokeAll(); | 100 weak_ptr_factory_.RevokeAll(); |
101 web_task_runner_ = std::move(task_runner); | 101 web_task_runner_ = std::move(task_runner); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const TimerBase* b) const { | 178 const TimerBase* b) const { |
179 return a->next_fire_time_ < b->next_fire_time_; | 179 return a->next_fire_time_ < b->next_fire_time_; |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
183 double TimerBase::TimerMonotonicallyIncreasingTime() const { | 183 double TimerBase::TimerMonotonicallyIncreasingTime() const { |
184 return TimerTaskRunner()->MonotonicallyIncreasingVirtualTimeSeconds(); | 184 return TimerTaskRunner()->MonotonicallyIncreasingVirtualTimeSeconds(); |
185 } | 185 } |
186 | 186 |
187 } // namespace blink | 187 } // namespace blink |
OLD | NEW |