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

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

Issue 1468443002: Reduce the number of delayed tasks on chromium run loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Weak pointer Created 5 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
« no previous file with comments | « components/scheduler/base/virtual_time_domain.h ('k') | no next file » | 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/virtual_time_domain.h" 5 #include "components/scheduler/base/virtual_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_delegate.h" 9 #include "components/scheduler/base/task_queue_manager_delegate.h"
10 10
11 namespace scheduler { 11 namespace scheduler {
12 12
13 VirtualTimeDomain::VirtualTimeDomain(base::TimeTicks initial_time) 13 VirtualTimeDomain::VirtualTimeDomain(base::TimeTicks initial_time)
14 : now_(initial_time) {} 14 : now_(initial_time) {}
15 15
16 VirtualTimeDomain::~VirtualTimeDomain() {} 16 VirtualTimeDomain::~VirtualTimeDomain() {}
17 17
18 void VirtualTimeDomain::OnRegisterWithTaskQueueManager(
19 TaskQueueManagerDelegate* task_queue_manager_delegate,
20 base::Closure do_work_closure) {
21 task_queue_manager_delegate_ = task_queue_manager_delegate;
22 do_work_closure_ = do_work_closure;
23 DCHECK(task_queue_manager_delegate_);
24 }
25
18 LazyNow VirtualTimeDomain::CreateLazyNow() { 26 LazyNow VirtualTimeDomain::CreateLazyNow() {
19 base::AutoLock lock(lock_); 27 base::AutoLock lock(lock_);
20 return LazyNow(now_); 28 return LazyNow(now_);
21 } 29 }
22 30
23 void VirtualTimeDomain::RequestWakeup(base::TimeDelta delay) { 31 void VirtualTimeDomain::RequestWakeup(LazyNow* lazy_now,
24 // We don't need to do anything here because AdvanceTo triggers delayed tasks. 32 base::TimeDelta delay) {
33 // We don't need to do anything here because AdvanceTo posts a DoWork.
25 } 34 }
26 35
27 bool VirtualTimeDomain::MaybeAdvanceTime() { 36 bool VirtualTimeDomain::MaybeAdvanceTime() {
28 return false; 37 return false;
29 } 38 }
30 39
31 void VirtualTimeDomain::AsValueIntoInternal( 40 void VirtualTimeDomain::AsValueIntoInternal(
32 base::trace_event::TracedValue* state) const {} 41 base::trace_event::TracedValue* state) const {}
33 42
34 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) { 43 void VirtualTimeDomain::AdvanceTo(base::TimeTicks now) {
35 base::AutoLock lock(lock_); 44 base::AutoLock lock(lock_);
36 DCHECK_GE(now, now_); 45 DCHECK_GE(now, now_);
37 now_ = now; 46 now_ = now;
38 LazyNow lazy_now(now_); 47 task_queue_manager_delegate_->PostTask(FROM_HERE, do_work_closure_);
39 WakeupReadyDelayedQueues(&lazy_now);
40 } 48 }
41 49
42 const char* VirtualTimeDomain::GetName() const { 50 const char* VirtualTimeDomain::GetName() const {
43 return "VirtualTimeDomain"; 51 return "VirtualTimeDomain";
44 } 52 }
45 53
46 } // namespace scheduler 54 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/virtual_time_domain.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698