OLD | NEW |
---|---|
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 12 matching lines...) Expand all Loading... | |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 * | 24 * |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/workers/WorkerEventQueue.h" | 28 #include "core/workers/WorkerEventQueue.h" |
29 | 29 |
30 #include "core/dom/ExecutionContext.h" | 30 #include "core/dom/ExecutionContext.h" |
31 #include "core/dom/ExecutionContextTask.h" | 31 #include "core/dom/ExecutionContextTask.h" |
32 #include "core/events/Event.h" | 32 #include "core/events/Event.h" |
33 #include "core/inspector/InspectorInstrumentation.h" | |
33 | 34 |
34 namespace WebCore { | 35 namespace WebCore { |
35 | 36 |
36 PassOwnPtrWillBeRawPtr<WorkerEventQueue> WorkerEventQueue::create(ExecutionConte xt* context) | 37 PassOwnPtrWillBeRawPtr<WorkerEventQueue> WorkerEventQueue::create(ExecutionConte xt* context) |
37 { | 38 { |
38 return adoptPtrWillBeNoop(new WorkerEventQueue(context)); | 39 return adoptPtrWillBeNoop(new WorkerEventQueue(context)); |
39 } | 40 } |
40 | 41 |
41 WorkerEventQueue::WorkerEventQueue(ExecutionContext* context) | 42 WorkerEventQueue::WorkerEventQueue(ExecutionContext* context) |
42 : m_executionContext(context) | 43 : m_executionContext(context) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 { | 98 { |
98 } | 99 } |
99 | 100 |
100 RefPtrWillBePersistent<Event> m_event; | 101 RefPtrWillBePersistent<Event> m_event; |
101 WorkerEventQueue* m_eventQueue; | 102 WorkerEventQueue* m_eventQueue; |
102 bool m_isCancelled; | 103 bool m_isCancelled; |
103 }; | 104 }; |
104 | 105 |
105 void WorkerEventQueue::removeEvent(Event* event) | 106 void WorkerEventQueue::removeEvent(Event* event) |
106 { | 107 { |
108 InspectorInstrumentation::didRemoveEvent(event->target(), event); | |
107 m_eventTaskMap.remove(event); | 109 m_eventTaskMap.remove(event); |
108 } | 110 } |
109 | 111 |
110 bool WorkerEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> prpEvent) | 112 bool WorkerEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> prpEvent) |
111 { | 113 { |
112 if (m_isClosed) | 114 if (m_isClosed) |
113 return false; | 115 return false; |
114 RefPtrWillBeRawPtr<Event> event = prpEvent; | 116 RefPtrWillBeRawPtr<Event> event = prpEvent; |
117 InspectorInstrumentation::didEnqueueEvent(event->target(), event.get()); | |
yurys
2014/06/17 11:22:14
Would be nice to have a test for this functionalit
| |
115 OwnPtr<EventDispatcherTask> task = EventDispatcherTask::create(event, this); | 118 OwnPtr<EventDispatcherTask> task = EventDispatcherTask::create(event, this); |
116 m_eventTaskMap.add(event.release(), task.get()); | 119 m_eventTaskMap.add(event.release(), task.get()); |
117 m_executionContext->postTask(task.release()); | 120 m_executionContext->postTask(task.release()); |
118 return true; | 121 return true; |
119 } | 122 } |
120 | 123 |
121 bool WorkerEventQueue::cancelEvent(Event* event) | 124 bool WorkerEventQueue::cancelEvent(Event* event) |
122 { | 125 { |
123 EventDispatcherTask* task = m_eventTaskMap.get(event); | 126 EventDispatcherTask* task = m_eventTaskMap.get(event); |
124 if (!task) | 127 if (!task) |
125 return false; | 128 return false; |
126 task->cancel(); | 129 task->cancel(); |
127 removeEvent(event); | 130 removeEvent(event); |
128 return true; | 131 return true; |
129 } | 132 } |
130 | 133 |
131 void WorkerEventQueue::close() | 134 void WorkerEventQueue::close() |
132 { | 135 { |
133 m_isClosed = true; | 136 m_isClosed = true; |
134 for (EventTaskMap::iterator it = m_eventTaskMap.begin(); it != m_eventTaskMa p.end(); ++it) { | 137 for (EventTaskMap::iterator it = m_eventTaskMap.begin(); it != m_eventTaskMa p.end(); ++it) { |
138 Event* event = it->key.get(); | |
135 EventDispatcherTask* task = it->value; | 139 EventDispatcherTask* task = it->value; |
140 InspectorInstrumentation::didRemoveEvent(event->target(), event); | |
136 task->cancel(); | 141 task->cancel(); |
137 } | 142 } |
138 m_eventTaskMap.clear(); | 143 m_eventTaskMap.clear(); |
139 } | 144 } |
140 | 145 |
141 } | 146 } |
OLD | NEW |