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

Side by Side Diff: Source/core/events/DOMWindowEventQueue.cpp

Issue 333333002: DevTools: Instrument DOMWindowEventQueue for async stacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « LayoutTests/inspector/sources/debugger/async-callstack-events-expected.txt ('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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 * 24 *
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/events/DOMWindowEventQueue.h" 28 #include "core/events/DOMWindowEventQueue.h"
29 29
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/events/Event.h" 31 #include "core/events/Event.h"
32 #include "core/frame/DOMWindow.h" 32 #include "core/frame/DOMWindow.h"
33 #include "core/frame/SuspendableTimer.h" 33 #include "core/frame/SuspendableTimer.h"
34 #include "core/inspector/InspectorInstrumentation.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 class DOMWindowEventQueueTimer : public NoBaseWillBeGarbageCollectedFinalized<DO MWindowEventQueueTimer>, public SuspendableTimer { 38 class DOMWindowEventQueueTimer : public NoBaseWillBeGarbageCollectedFinalized<DO MWindowEventQueueTimer>, public SuspendableTimer {
38 WTF_MAKE_NONCOPYABLE(DOMWindowEventQueueTimer); 39 WTF_MAKE_NONCOPYABLE(DOMWindowEventQueueTimer);
39 public: 40 public:
40 DOMWindowEventQueueTimer(DOMWindowEventQueue* eventQueue, ExecutionContext* context) 41 DOMWindowEventQueueTimer(DOMWindowEventQueue* eventQueue, ExecutionContext* context)
41 : SuspendableTimer(context) 42 : SuspendableTimer(context)
42 , m_eventQueue(eventQueue) { } 43 , m_eventQueue(eventQueue) { }
43 void trace(Visitor* visitor) { visitor->trace(m_eventQueue); } 44 void trace(Visitor* visitor) { visitor->trace(m_eventQueue); }
(...skipping 26 matching lines...) Expand all
70 visitor->trace(m_queuedEvents); 71 visitor->trace(m_queuedEvents);
71 EventQueue::trace(visitor); 72 EventQueue::trace(visitor);
72 } 73 }
73 74
74 bool DOMWindowEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) 75 bool DOMWindowEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event)
75 { 76 {
76 if (m_isClosed) 77 if (m_isClosed)
77 return false; 78 return false;
78 79
79 ASSERT(event->target()); 80 ASSERT(event->target());
81 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get());
82
80 bool wasAdded = m_queuedEvents.add(event).isNewEntry; 83 bool wasAdded = m_queuedEvents.add(event).isNewEntry;
81 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. 84 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
82 85
83 if (!m_pendingEventTimer->isActive()) 86 if (!m_pendingEventTimer->isActive())
84 m_pendingEventTimer->startOneShot(0, FROM_HERE); 87 m_pendingEventTimer->startOneShot(0, FROM_HERE);
85 88
86 return true; 89 return true;
87 } 90 }
88 91
89 bool DOMWindowEventQueue::cancelEvent(Event* event) 92 bool DOMWindowEventQueue::cancelEvent(Event* event)
90 { 93 {
91 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_queued Events.find(event); 94 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_queued Events.find(event);
92 bool found = it != m_queuedEvents.end(); 95 bool found = it != m_queuedEvents.end();
93 if (found) 96 if (found) {
97 InspectorInstrumentation::didDispatchEvent(event->target(), event);
yurys 2014/06/17 07:34:26 Don't we need to distinguish cancel operation from
aandrey 2014/06/17 10:34:18 Renamed to didRemoveEvent.
94 m_queuedEvents.remove(it); 98 m_queuedEvents.remove(it);
99 }
95 if (m_queuedEvents.isEmpty()) 100 if (m_queuedEvents.isEmpty())
96 m_pendingEventTimer->stop(); 101 m_pendingEventTimer->stop();
97 return found; 102 return found;
98 } 103 }
99 104
100 void DOMWindowEventQueue::close() 105 void DOMWindowEventQueue::close()
101 { 106 {
102 m_isClosed = true; 107 m_isClosed = true;
103 m_pendingEventTimer->stop(); 108 m_pendingEventTimer->stop();
109
110 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_queued Events.begin();
111 for (; it != m_queuedEvents.end(); ++it)
112 InspectorInstrumentation::didDispatchEvent((*it)->target(), it->get());
yurys 2014/06/17 07:34:26 We shouldn't iterate over the queued events unless
aandrey 2014/06/17 10:34:18 Done.
104 m_queuedEvents.clear(); 113 m_queuedEvents.clear();
105 } 114 }
106 115
107 void DOMWindowEventQueue::pendingEventTimerFired() 116 void DOMWindowEventQueue::pendingEventTimerFired()
108 { 117 {
109 ASSERT(!m_pendingEventTimer->isActive()); 118 ASSERT(!m_pendingEventTimer->isActive());
110 ASSERT(!m_queuedEvents.isEmpty()); 119 ASSERT(!m_queuedEvents.isEmpty());
111 120
112 // Insert a marker for where we should stop. 121 // Insert a marker for where we should stop.
113 ASSERT(!m_queuedEvents.contains(nullptr)); 122 ASSERT(!m_queuedEvents.contains(nullptr));
114 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; 123 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry;
115 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. 124 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
116 125
117 RefPtrWillBeRawPtr<DOMWindowEventQueue> protector(this); 126 RefPtrWillBeRawPtr<DOMWindowEventQueue> protector(this);
118 127
119 while (!m_queuedEvents.isEmpty()) { 128 while (!m_queuedEvents.isEmpty()) {
120 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator iter = m_ queuedEvents.begin(); 129 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator iter = m_ queuedEvents.begin();
121 RefPtrWillBeRawPtr<Event> event = *iter; 130 RefPtrWillBeRawPtr<Event> event = *iter;
122 m_queuedEvents.remove(iter); 131 m_queuedEvents.remove(iter);
123 if (!event) 132 if (!event)
124 break; 133 break;
125 dispatchEvent(event.get()); 134 dispatchEvent(event.get());
135 InspectorInstrumentation::didDispatchEvent(event->target(), event.get()) ;
126 } 136 }
127 } 137 }
128 138
129 void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) 139 void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
130 { 140 {
131 EventTarget* eventTarget = event->target(); 141 EventTarget* eventTarget = event->target();
132 if (eventTarget->toDOMWindow()) 142 if (eventTarget->toDOMWindow())
133 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr); 143 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr);
134 else 144 else
135 eventTarget->dispatchEvent(event); 145 eventTarget->dispatchEvent(event);
136 } 146 }
137 147
138 } 148 }
OLDNEW
« no previous file with comments | « LayoutTests/inspector/sources/debugger/async-callstack-events-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698