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

Side by Side Diff: sky/engine/core/events/GenericEventQueue.cpp

Issue 691663002: Unfork Sky's trace events (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/events/EventDispatcher.cpp ('k') | sky/engine/core/fetch/ResourceFetcher.cpp » ('j') | 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) 2012 Victor Carbune (victor@rosedu.org) 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event) 58 bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event)
59 { 59 {
60 if (m_isClosed) 60 if (m_isClosed)
61 return false; 61 return false;
62 62
63 if (event->target() == m_owner) 63 if (event->target() == m_owner)
64 event->setTarget(nullptr); 64 event->setTarget(nullptr);
65 65
66 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge t(), "type", event->type().ascii()); 66 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge t(), "type", event->type().ascii().data());
67 m_pendingEvents.append(event); 67 m_pendingEvents.append(event);
68 68
69 if (!m_timer.isActive()) 69 if (!m_timer.isActive())
70 m_timer.startOneShot(0, FROM_HERE); 70 m_timer.startOneShot(0, FROM_HERE);
71 71
72 return true; 72 return true;
73 } 73 }
74 74
75 bool GenericEventQueue::cancelEvent(Event* event) 75 bool GenericEventQueue::cancelEvent(Event* event)
76 { 76 {
77 bool found = m_pendingEvents.contains(event); 77 bool found = m_pendingEvents.contains(event);
78 78
79 if (found) { 79 if (found) {
80 m_pendingEvents.remove(m_pendingEvents.find(event)); 80 m_pendingEvents.remove(m_pendingEvents.find(event));
81 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii(), "status", "cancelled"); 81 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii().data(), "status", "cancelled");
82 } 82 }
83 83
84 if (m_pendingEvents.isEmpty()) 84 if (m_pendingEvents.isEmpty())
85 m_timer.stop(); 85 m_timer.stop();
86 86
87 return found; 87 return found;
88 } 88 }
89 89
90 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) 90 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*)
91 { 91 {
92 ASSERT(!m_timer.isActive()); 92 ASSERT(!m_timer.isActive());
93 ASSERT(!m_pendingEvents.isEmpty()); 93 ASSERT(!m_pendingEvents.isEmpty());
94 94
95 Vector<RefPtr<Event> > pendingEvents; 95 Vector<RefPtr<Event> > pendingEvents;
96 m_pendingEvents.swap(pendingEvents); 96 m_pendingEvents.swap(pendingEvents);
97 97
98 RefPtr<EventTarget> protect(m_owner.get()); 98 RefPtr<EventTarget> protect(m_owner.get());
99 for (size_t i = 0; i < pendingEvents.size(); ++i) { 99 for (size_t i = 0; i < pendingEvents.size(); ++i) {
100 Event* event = pendingEvents[i].get(); 100 Event* event = pendingEvents[i].get();
101 EventTarget* target = event->target() ? event->target() : m_owner.get(); 101 EventTarget* target = event->target() ? event->target() : m_owner.get();
102 CString type(event->type().ascii()); 102 CString type(event->type().ascii());
103 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type); 103 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type.data());
104 target->dispatchEvent(pendingEvents[i]); 104 target->dispatchEvent(pendingEvents[i]);
105 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type); 105 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type.data());
106 } 106 }
107 } 107 }
108 108
109 void GenericEventQueue::close() 109 void GenericEventQueue::close()
110 { 110 {
111 m_isClosed = true; 111 m_isClosed = true;
112 cancelAllEvents(); 112 cancelAllEvents();
113 } 113 }
114 114
115 void GenericEventQueue::cancelAllEvents() 115 void GenericEventQueue::cancelAllEvents()
116 { 116 {
117 m_timer.stop(); 117 m_timer.stop();
118 118
119 for (size_t i = 0; i < m_pendingEvents.size(); ++i) { 119 for (size_t i = 0; i < m_pendingEvents.size(); ++i) {
120 Event* event = m_pendingEvents[i].get(); 120 Event* event = m_pendingEvents[i].get();
121 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii(), "status", "cancelled"); 121 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii().data(), "status", "cancelled");
122 } 122 }
123 m_pendingEvents.clear(); 123 m_pendingEvents.clear();
124 } 124 }
125 125
126 bool GenericEventQueue::hasPendingEvents() const 126 bool GenericEventQueue::hasPendingEvents() const
127 { 127 {
128 return m_pendingEvents.size(); 128 return m_pendingEvents.size();
129 } 129 }
130 130
131 } 131 }
OLDNEW
« no previous file with comments | « sky/engine/core/events/EventDispatcher.cpp ('k') | sky/engine/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698