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

Side by Side Diff: third_party/WebKit/Source/core/frame/DOMTimerCoordinator.cpp

Issue 1959013002: Eagerly remove disposed DOMTimers as observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « third_party/WebKit/Source/core/frame/DOMTimer.cpp ('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 "core/frame/DOMTimerCoordinator.h" 5 #include "core/frame/DOMTimerCoordinator.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
8 #include "core/frame/DOMTimer.h" 8 #include "core/frame/DOMTimer.h"
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 18 matching lines...) Expand all
29 timer->suspendIfNeeded(); 29 timer->suspendIfNeeded();
30 30
31 return timeoutID; 31 return timeoutID;
32 } 32 }
33 33
34 void DOMTimerCoordinator::removeTimeoutByID(int timeoutID) 34 void DOMTimerCoordinator::removeTimeoutByID(int timeoutID)
35 { 35 {
36 if (timeoutID <= 0) 36 if (timeoutID <= 0)
37 return; 37 return;
38 38
39 if (DOMTimer* removedTimer = m_timers.get(timeoutID)) 39 if (DOMTimer* removedTimer = m_timers.take(timeoutID))
40 removedTimer->disposeTimer(); 40 removedTimer->disposeTimer();
41
42 m_timers.remove(timeoutID);
43 } 41 }
44 42
45 DEFINE_TRACE(DOMTimerCoordinator) 43 DEFINE_TRACE(DOMTimerCoordinator)
46 { 44 {
47 visitor->trace(m_timers); 45 visitor->trace(m_timers);
48 } 46 }
49 47
50 int DOMTimerCoordinator::nextID() 48 int DOMTimerCoordinator::nextID()
51 { 49 {
52 while (true) { 50 while (true) {
53 ++m_circularSequentialID; 51 ++m_circularSequentialID;
54 52
55 if (m_circularSequentialID <= 0) 53 if (m_circularSequentialID <= 0)
56 m_circularSequentialID = 1; 54 m_circularSequentialID = 1;
57 55
58 if (!m_timers.contains(m_circularSequentialID)) 56 if (!m_timers.contains(m_circularSequentialID))
59 return m_circularSequentialID; 57 return m_circularSequentialID;
60 } 58 }
61 } 59 }
62 60
63 void DOMTimerCoordinator::setTimerTaskRunner(PassOwnPtr<WebTaskRunner> timerTask Runner) 61 void DOMTimerCoordinator::setTimerTaskRunner(PassOwnPtr<WebTaskRunner> timerTask Runner)
64 { 62 {
65 m_timerTaskRunner = std::move(timerTaskRunner); 63 m_timerTaskRunner = std::move(timerTaskRunner);
66 } 64 }
67 65
68 } // namespace blink 66 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/DOMTimer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698