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

Side by Side Diff: third_party/WebKit/Source/platform/Timer.cpp

Issue 2290243002: Make blink::TimerBase own the WebTaskRunner for timer task (Closed)
Patch Set: use adoptRef Created 4 years, 3 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
OLDNEW
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 26 matching lines...) Expand all
37 #include <limits.h> 37 #include <limits.h>
38 #include <limits> 38 #include <limits>
39 #include <math.h> 39 #include <math.h>
40 40
41 namespace blink { 41 namespace blink {
42 42
43 TimerBase::TimerBase(WebTaskRunner* webTaskRunner) 43 TimerBase::TimerBase(WebTaskRunner* webTaskRunner)
44 : m_nextFireTime(0) 44 : m_nextFireTime(0)
45 , m_repeatInterval(0) 45 , m_repeatInterval(0)
46 , m_cancellableTimerTask(nullptr) 46 , m_cancellableTimerTask(nullptr)
47 , m_webTaskRunner(webTaskRunner) 47 , m_webTaskRunner(webTaskRunner->clone())
48 #if DCHECK_IS_ON() 48 #if DCHECK_IS_ON()
49 , m_thread(currentThread()) 49 , m_thread(currentThread())
50 #endif 50 #endif
51 { 51 {
52 ASSERT(m_webTaskRunner); 52 ASSERT(m_webTaskRunner);
53 } 53 }
54 54
55 TimerBase::~TimerBase() 55 TimerBase::~TimerBase()
56 { 56 {
57 stop(); 57 stop();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 // static 95 // static
96 WebTaskRunner* TimerBase::getUnthrottledTaskRunner() 96 WebTaskRunner* TimerBase::getUnthrottledTaskRunner()
97 { 97 {
98 return Platform::current()->currentThread()->getWebTaskRunner(); 98 return Platform::current()->currentThread()->getWebTaskRunner();
99 } 99 }
100 100
101 WebTaskRunner* TimerBase::timerTaskRunner() const 101 WebTaskRunner* TimerBase::timerTaskRunner() const
102 { 102 {
103 return m_webTaskRunner; 103 return m_webTaskRunner.get();
104 } 104 }
105 105
106 void TimerBase::setNextFireTime(double now, double delay) 106 void TimerBase::setNextFireTime(double now, double delay)
107 { 107 {
108 ASSERT(m_thread == currentThread()); 108 ASSERT(m_thread == currentThread());
109 109
110 double newTime = now + delay; 110 double newTime = now + delay;
111 111
112 if (m_nextFireTime != newTime) { 112 if (m_nextFireTime != newTime) {
113 m_nextFireTime = newTime; 113 m_nextFireTime = newTime;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return a->m_nextFireTime < b->m_nextFireTime; 152 return a->m_nextFireTime < b->m_nextFireTime;
153 } 153 }
154 154
155 // static 155 // static
156 double TimerBase::timerMonotonicallyIncreasingTime() const 156 double TimerBase::timerMonotonicallyIncreasingTime() const
157 { 157 {
158 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); 158 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds();
159 } 159 }
160 160
161 } // namespace blink 161 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Timer.h ('k') | third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698