| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 close(); | 51 close(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 class WorkerEventQueue::EventDispatcherTask : public ScriptExecutionContext::Tas
k { | 54 class WorkerEventQueue::EventDispatcherTask : public ScriptExecutionContext::Tas
k { |
| 55 public: | 55 public: |
| 56 static PassOwnPtr<EventDispatcherTask> create(PassRefPtr<Event> event, Worke
rEventQueue* eventQueue) | 56 static PassOwnPtr<EventDispatcherTask> create(PassRefPtr<Event> event, Worke
rEventQueue* eventQueue) |
| 57 { | 57 { |
| 58 return adoptPtr(new EventDispatcherTask(event, eventQueue)); | 58 return adoptPtr(new EventDispatcherTask(event, eventQueue)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual ~EventDispatcherTask() |
| 62 { |
| 63 if (m_event) |
| 64 m_eventQueue->removeEvent(m_event.get()); |
| 65 } |
| 66 |
| 61 void dispatchEvent(ScriptExecutionContext*, PassRefPtr<Event> event) | 67 void dispatchEvent(ScriptExecutionContext*, PassRefPtr<Event> event) |
| 62 { | 68 { |
| 63 event->target()->dispatchEvent(event); | 69 event->target()->dispatchEvent(event); |
| 64 } | 70 } |
| 65 | 71 |
| 66 virtual void performTask(ScriptExecutionContext* context) | 72 virtual void performTask(ScriptExecutionContext* context) |
| 67 { | 73 { |
| 68 if (m_isCancelled) | 74 if (m_isCancelled) |
| 69 return; | 75 return; |
| 70 m_eventQueue->removeEvent(m_event.get()); | 76 m_eventQueue->removeEvent(m_event.get()); |
| 71 dispatchEvent(context, m_event); | 77 dispatchEvent(context, m_event); |
| 78 m_event.clear(); |
| 72 } | 79 } |
| 73 | 80 |
| 74 void cancel() | 81 void cancel() |
| 75 { | 82 { |
| 76 m_isCancelled = true; | 83 m_isCancelled = true; |
| 77 m_event.clear(); | 84 m_event.clear(); |
| 78 } | 85 } |
| 79 | 86 |
| 80 private: | 87 private: |
| 81 EventDispatcherTask(PassRefPtr<Event> event, WorkerEventQueue* eventQueue) | 88 EventDispatcherTask(PassRefPtr<Event> event, WorkerEventQueue* eventQueue) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 { | 127 { |
| 121 m_isClosed = true; | 128 m_isClosed = true; |
| 122 for (EventTaskMap::iterator it = m_eventTaskMap.begin(); it != m_eventTaskMa
p.end(); ++it) { | 129 for (EventTaskMap::iterator it = m_eventTaskMap.begin(); it != m_eventTaskMa
p.end(); ++it) { |
| 123 EventDispatcherTask* task = it->second; | 130 EventDispatcherTask* task = it->second; |
| 124 task->cancel(); | 131 task->cancel(); |
| 125 } | 132 } |
| 126 m_eventTaskMap.clear(); | 133 m_eventTaskMap.clear(); |
| 127 } | 134 } |
| 128 | 135 |
| 129 } | 136 } |
| OLD | NEW |