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

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

Issue 334253005: Custom Elements: Encapsulates Async and Sync Queues into one class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/dom/custom/CustomElementMicrotaskQueueBase.h"
7
8 #include "core/dom/custom/CustomElementCallbackDispatcher.h"
9
10 namespace WebCore {
11
12 class MicrotaskQueueInvocationScope {
13 public:
14 #if defined(NDEBUG)
15 explicit MicrotaskQueueInvocationScope(CustomElementMicrotaskQueueBase*) { }
16 #else
17 explicit MicrotaskQueueInvocationScope(CustomElementMicrotaskQueueBase* queu e)
18 : m_parent(s_top)
19 , m_queue(queue)
20 {
21 s_top = this;
22 ASSERT(m_queue->isEmpty() || !hasReenter());
dominicc (has gone to gerrit) 2014/06/18 00:11:28 Depending on doDispatch, is it worth making this A
Hajime Morrita 2014/06/18 00:57:05 Done.
23 }
24
25 ~MicrotaskQueueInvocationScope()
26 {
27 s_top = m_parent;
28 }
29
30 private:
31 bool hasReenter() const
dominicc (has gone to gerrit) 2014/06/18 00:11:28 This looks like a move, but consider renaming this
Hajime Morrita 2014/06/18 00:57:05 Done.
32 {
33 for (MicrotaskQueueInvocationScope* scope = this->m_parent; scope; scope = scope->m_parent) {
34 if (scope->m_queue == m_queue)
35 return true;
36 }
37
38 return false;
39 }
40
41 MicrotaskQueueInvocationScope* m_parent;
42 CustomElementMicrotaskQueueBase* m_queue;
43
44 static MicrotaskQueueInvocationScope* s_top;
45 #endif
46 };
47
48 #if !defined(NDEBUG)
49 MicrotaskQueueInvocationScope* MicrotaskQueueInvocationScope::s_top = 0;
50 #endif
51
52 void CustomElementMicrotaskQueueBase::dispatch()
53 {
54 MicrotaskQueueInvocationScope scope(this);
dominicc (has gone to gerrit) 2014/06/18 00:11:28 Why do all of this when a simple bool m_inDispatch
Hajime Morrita 2014/06/18 00:57:05 Done.
55 doDispatch();
56 }
57
58 void CustomElementMicrotaskQueueBase::trace(Visitor* visitor)
59 {
60 visitor->trace(m_queue);
61 }
62
63 #if !defined(NDEBUG)
64 void CustomElementMicrotaskQueueBase::show(unsigned indent)
65 {
66 for (unsigned q = 0; q < m_queue.size(); ++q) {
67 if (m_queue[q])
68 m_queue[q]->show(indent);
69 else
70 fprintf(stderr, "%*snull\n", indent, "");
71 }
72 }
73 #endif
74
75 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698