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

Side by Side Diff: components/scheduler/base/real_time_domain.cc

Issue 2155143002: Fix a bug that could occasionaly cause setInterval to stop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ClearExpiredWakeups tweak. Created 4 years, 5 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 | « components/scheduler/base/real_time_domain.h ('k') | components/scheduler/base/task_queue.h » ('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 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 "components/scheduler/base/real_time_domain.h" 5 #include "components/scheduler/base/real_time_domain.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/scheduler/base/task_queue_impl.h" 8 #include "components/scheduler/base/task_queue_impl.h"
9 #include "components/scheduler/base/task_queue_manager.h" 9 #include "components/scheduler/base/task_queue_manager.h"
10 #include "components/scheduler/base/task_queue_manager_delegate.h" 10 #include "components/scheduler/base/task_queue_manager_delegate.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 13
14 RealTimeDomain::RealTimeDomain(const char* tracing_category) 14 RealTimeDomain::RealTimeDomain(const char* tracing_category)
15 : TimeDomain(nullptr), 15 : TimeDomain(nullptr),
16 tracing_category_(tracing_category), 16 tracing_category_(tracing_category),
17 task_queue_manager_(nullptr) {} 17 task_queue_manager_(nullptr) {}
18 18
19 RealTimeDomain::RealTimeDomain(TimeDomain::Observer* observer,
20 const char* tracing_category)
21 : TimeDomain(observer),
22 tracing_category_(tracing_category),
23 task_queue_manager_(nullptr) {}
24
19 RealTimeDomain::~RealTimeDomain() {} 25 RealTimeDomain::~RealTimeDomain() {}
20 26
21 void RealTimeDomain::OnRegisterWithTaskQueueManager( 27 void RealTimeDomain::OnRegisterWithTaskQueueManager(
22 TaskQueueManager* task_queue_manager) { 28 TaskQueueManager* task_queue_manager) {
23 task_queue_manager_ = task_queue_manager; 29 task_queue_manager_ = task_queue_manager;
24 DCHECK(task_queue_manager_); 30 DCHECK(task_queue_manager_);
25 } 31 }
26 32
27 LazyNow RealTimeDomain::CreateLazyNow() const { 33 LazyNow RealTimeDomain::CreateLazyNow() const {
28 return task_queue_manager_->CreateLazyNow(); 34 return task_queue_manager_->CreateLazyNow();
29 } 35 }
30 36
31 base::TimeTicks RealTimeDomain::Now() const { 37 base::TimeTicks RealTimeDomain::Now() const {
32 return task_queue_manager_->delegate()->NowTicks(); 38 return task_queue_manager_->delegate()->NowTicks();
33 } 39 }
34 40
35 base::TimeTicks RealTimeDomain::ComputeDelayedRunTime(
36 base::TimeTicks time_domain_now,
37 base::TimeDelta delay) const {
38 return time_domain_now + delay;
39 }
40
41 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) { 41 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) {
42 // NOTE this is only called if the scheduled runtime is sooner than any 42 // NOTE this is only called if the scheduled runtime is sooner than any
43 // previously scheduled runtime, or there is no (outstanding) previously 43 // previously scheduled runtime, or there is no (outstanding) previously
44 // scheduled runtime. 44 // scheduled runtime.
45 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); 45 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay);
46 } 46 }
47 47
48 bool RealTimeDomain::MaybeAdvanceTime() { 48 bool RealTimeDomain::MaybeAdvanceTime() {
49 base::TimeTicks next_run_time; 49 base::TimeTicks next_run_time;
50 if (!NextScheduledRunTime(&next_run_time)) 50 if (!NextScheduledRunTime(&next_run_time))
(...skipping 13 matching lines...) Expand all
64 return false; 64 return false;
65 } 65 }
66 66
67 void RealTimeDomain::AsValueIntoInternal( 67 void RealTimeDomain::AsValueIntoInternal(
68 base::trace_event::TracedValue* state) const {} 68 base::trace_event::TracedValue* state) const {}
69 69
70 const char* RealTimeDomain::GetName() const { 70 const char* RealTimeDomain::GetName() const {
71 return "RealTimeDomain"; 71 return "RealTimeDomain";
72 } 72 }
73 } // namespace scheduler 73 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/real_time_domain.h ('k') | components/scheduler/base/task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698