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

Side by Side Diff: Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp

Issue 296703009: Oilpan: move custom element objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use LinkedHashSet for ElementSet instead. Created 6 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
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 "config.h" 5 #include "config.h"
6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h" 6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
7 7
8 #include "core/dom/Microtask.h" 8 #include "core/dom/Microtask.h"
9 #include "core/dom/custom/CustomElementCallbackDispatcher.h" 9 #include "core/dom/custom/CustomElementCallbackDispatcher.h"
10 #include "core/dom/custom/CustomElementCallbackQueue.h" 10 #include "core/dom/custom/CustomElementCallbackQueue.h"
11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h"
12 #include "core/dom/custom/CustomElementMicrotaskQueue.h" 12 #include "core/dom/custom/CustomElementMicrotaskQueue.h"
13 #include "core/dom/custom/CustomElementScheduler.h" 13 #include "core/dom/custom/CustomElementScheduler.h"
14 #include "core/html/imports/HTMLImportLoader.h" 14 #include "core/html/imports/HTMLImportLoader.h"
15 #include "wtf/MainThread.h" 15 #include "wtf/MainThread.h"
16 16
17 namespace WebCore { 17 namespace WebCore {
18 18
19 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0; 19 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0;
20 20
21 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher() 21 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher()
22 : m_hasScheduledMicrotask(false) 22 : m_hasScheduledMicrotask(false)
23 , m_phase(Quiescent) 23 , m_phase(Quiescent)
24 , m_resolutionAndImports(CustomElementMicrotaskQueue::create()) 24 , m_resolutionAndImports(CustomElementMicrotaskQueue::create())
25 { 25 {
26 } 26 }
27 27
28 CustomElementMicrotaskDispatcher& CustomElementMicrotaskDispatcher::instance() 28 CustomElementMicrotaskDispatcher& CustomElementMicrotaskDispatcher::instance()
29 { 29 {
30 #if ENABLE(OILPAN)
31 DEFINE_STATIC_LOCAL(Persistent<CustomElementMicrotaskDispatcher>, instance, (new CustomElementMicrotaskDispatcher()));
32 return *instance;
33 #else
30 DEFINE_STATIC_LOCAL(CustomElementMicrotaskDispatcher, instance, ()); 34 DEFINE_STATIC_LOCAL(CustomElementMicrotaskDispatcher, instance, ());
31 return instance; 35 return instance;
36 #endif
32 } 37 }
33 38
34 void CustomElementMicrotaskDispatcher::enqueue(HTMLImportLoader* importLoader, P assOwnPtr<CustomElementMicrotaskStep> step) 39 void CustomElementMicrotaskDispatcher::enqueue(HTMLImportLoader* importLoader, P assOwnPtrWillBeRawPtr<CustomElementMicrotaskStep> step)
35 { 40 {
36 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks); 41 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks);
37 ensureMicrotaskScheduled(); 42 ensureMicrotaskScheduled();
38 if (importLoader) 43 if (importLoader)
39 importLoader->microtaskQueue()->enqueue(step); 44 importLoader->microtaskQueue()->enqueue(step);
40 else 45 else
41 m_resolutionAndImports->enqueue(step); 46 m_resolutionAndImports->enqueue(step);
42 } 47 }
43 48
44 void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue ) 49 void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue )
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 82
78 // Finishing microtask work deletes all 83 // Finishing microtask work deletes all
79 // CustomElementCallbackQueues. Being in a callback delivery scope 84 // CustomElementCallbackQueues. Being in a callback delivery scope
80 // implies those queues could still be in use. 85 // implies those queues could still be in use.
81 ASSERT_WITH_SECURITY_IMPLICATION(!CustomElementCallbackDispatcher::inCallbac kDeliveryScope()); 86 ASSERT_WITH_SECURITY_IMPLICATION(!CustomElementCallbackDispatcher::inCallbac kDeliveryScope());
82 87
83 m_phase = Resolving; 88 m_phase = Resolving;
84 m_resolutionAndImports->dispatch(); 89 m_resolutionAndImports->dispatch();
85 90
86 m_phase = DispatchingCallbacks; 91 m_phase = DispatchingCallbacks;
87 for (Vector<CustomElementCallbackQueue*>::iterator it = m_elements.begin();i t != m_elements.end(); ++it) { 92 for (WillBeHeapVector<RawPtrWillBeMember<CustomElementCallbackQueue> >::iter ator it = m_elements.begin();it != m_elements.end(); ++it) {
haraken 2014/05/26 15:40:23 Nit: One space needed after "begin();"
sof 2014/05/26 16:41:08 Tidied.
88 // Created callback may enqueue an attached callback. 93 // Created callback may enqueue an attached callback.
89 CustomElementCallbackDispatcher::CallbackDeliveryScope scope; 94 CustomElementCallbackDispatcher::CallbackDeliveryScope scope;
90 (*it)->processInElementQueue(kMicrotaskQueueId); 95 (*it)->processInElementQueue(kMicrotaskQueueId);
91 } 96 }
92 97
93 m_elements.clear(); 98 m_elements.clear();
94 CustomElementScheduler::microtaskDispatcherDidFinish(); 99 CustomElementScheduler::microtaskDispatcherDidFinish();
95 m_phase = Quiescent; 100 m_phase = Quiescent;
96 } 101 }
97 102
103 void CustomElementMicrotaskDispatcher::trace(Visitor* visitor)
104 {
105 visitor->trace(m_resolutionAndImports);
106 #if ENABLE(OILPAN)
107 visitor->trace(m_elements);
108 #endif
109 }
110
98 #if !defined(NDEBUG) 111 #if !defined(NDEBUG)
99 void CustomElementMicrotaskDispatcher::show() 112 void CustomElementMicrotaskDispatcher::show()
100 { 113 {
101 fprintf(stderr, "Dispatcher:\n"); 114 fprintf(stderr, "Dispatcher:\n");
102 m_resolutionAndImports->show(1); 115 m_resolutionAndImports->show(1);
103 } 116 }
104 #endif 117 #endif
105 118
106 } // namespace WebCore 119 } // namespace WebCore
107 120
108 #if !defined(NDEBUG) 121 #if !defined(NDEBUG)
109 void showCEMD() 122 void showCEMD()
110 { 123 {
111 WebCore::CustomElementMicrotaskDispatcher::instance().show(); 124 WebCore::CustomElementMicrotaskDispatcher::instance().show();
112 } 125 }
113 #endif 126 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698