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

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

Issue 2151933003: Change WTF::TemporaryChange to be an alias for AutoReset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TemporaryChange -> AutoReset 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/PlatformEventDispatcher.h" 5 #include "core/frame/PlatformEventDispatcher.h"
6 6
7 #include "core/frame/PlatformEventController.h" 7 #include "core/frame/PlatformEventController.h"
8 #include "wtf/TemporaryChange.h" 8 #include "wtf/AutoReset.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 PlatformEventDispatcher::PlatformEventDispatcher() 12 PlatformEventDispatcher::PlatformEventDispatcher()
13 : m_isDispatching(false) 13 : m_isDispatching(false)
14 , m_isListening(false) 14 , m_isListening(false)
15 { 15 {
16 } 16 }
17 17
18 void PlatformEventDispatcher::addController(PlatformEventController* controller) 18 void PlatformEventDispatcher::addController(PlatformEventController* controller)
(...skipping 22 matching lines...) Expand all
41 m_isListening = false; 41 m_isListening = false;
42 } 42 }
43 } 43 }
44 44
45 void PlatformEventDispatcher::notifyControllers() 45 void PlatformEventDispatcher::notifyControllers()
46 { 46 {
47 if (m_controllers.isEmpty()) 47 if (m_controllers.isEmpty())
48 return; 48 return;
49 49
50 { 50 {
51 TemporaryChange<bool> changeIsDispatching(m_isDispatching, true); 51 AutoReset<bool> changeIsDispatching(&m_isDispatching, true);
52 // HashSet m_controllers can be updated during an iteration, and it stop s the iteration. 52 // HashSet m_controllers can be updated during an iteration, and it stop s the iteration.
53 // Thus we store it into a Vector to access all elements. 53 // Thus we store it into a Vector to access all elements.
54 HeapVector<Member<PlatformEventController>> snapshotVector; 54 HeapVector<Member<PlatformEventController>> snapshotVector;
55 copyToVector(m_controllers, snapshotVector); 55 copyToVector(m_controllers, snapshotVector);
56 for (PlatformEventController* controller : snapshotVector) { 56 for (PlatformEventController* controller : snapshotVector) {
57 if (m_controllers.contains(controller)) 57 if (m_controllers.contains(controller))
58 controller->didUpdateData(); 58 controller->didUpdateData();
59 } 59 }
60 } 60 }
61 61
62 if (m_controllers.isEmpty()) { 62 if (m_controllers.isEmpty()) {
63 stopListening(); 63 stopListening();
64 m_isListening = false; 64 m_isListening = false;
65 } 65 }
66 } 66 }
67 67
68 DEFINE_TRACE(PlatformEventDispatcher) 68 DEFINE_TRACE(PlatformEventDispatcher)
69 { 69 {
70 visitor->trace(m_controllers); 70 visitor->trace(m_controllers);
71 } 71 }
72 72
73 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698