| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (m_backgroundEvents.isEmpty()) | 87 if (m_backgroundEvents.isEmpty()) |
| 88 return; | 88 return; |
| 89 events.reserveCapacity(m_backgroundEvents.capacity()); | 89 events.reserveCapacity(m_backgroundEvents.capacity()); |
| 90 m_backgroundEvents.swap(events); | 90 m_backgroundEvents.swap(events); |
| 91 } | 91 } |
| 92 for (size_t eventIndex = 0, size = events.size(); eventIndex < size; ++event
Index) { | 92 for (size_t eventIndex = 0, size = events.size(); eventIndex < size; ++event
Index) { |
| 93 const TraceEvent& event = events[eventIndex]; | 93 const TraceEvent& event = events[eventIndex]; |
| 94 ListenersMap::iterator it = m_listeners->find(std::make_pair(event.name(
), event.phase())); | 94 ListenersMap::iterator it = m_listeners->find(std::make_pair(event.name(
), event.phase())); |
| 95 if (it == m_listeners->end()) | 95 if (it == m_listeners->end()) |
| 96 continue; | 96 continue; |
| 97 WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >& listeners = *
it->value.get(); | 97 WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener>>& listeners = *i
t->value.get(); |
| 98 for (size_t listenerIndex = 0; listenerIndex < listeners.size(); ++liste
nerIndex) | 98 for (size_t listenerIndex = 0; listenerIndex < listeners.size(); ++liste
nerIndex) |
| 99 listeners[listenerIndex]->call(event); | 99 listeners[listenerIndex]->call(event); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 void TraceEventDispatcher::addListener(const char* name, char phase, PassOwnPtrW
illBeRawPtr<TraceEventListener> listener, InspectorClient* client) | 103 void TraceEventDispatcher::addListener(const char* name, char phase, PassOwnPtrW
illBeRawPtr<TraceEventListener> listener, InspectorClient* client) |
| 104 { | 104 { |
| 105 static const char CategoryFilter[] = "-*," TRACE_DISABLED_BY_DEFAULT("devtoo
ls.timeline") "," TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame"); | 105 static const char CategoryFilter[] = "-*," TRACE_DISABLED_BY_DEFAULT("devtoo
ls.timeline") "," TRACE_DISABLED_BY_DEFAULT("devtools.timeline.frame"); |
| 106 | 106 |
| 107 ASSERT(isMainThread()); | 107 ASSERT(isMainThread()); |
| 108 MutexLocker locker(m_mutex); | 108 MutexLocker locker(m_mutex); |
| 109 if (m_listeners->isEmpty()) | 109 if (m_listeners->isEmpty()) |
| 110 client->setTraceEventCallback(CategoryFilter, dispatchEventOnAnyThread); | 110 client->setTraceEventCallback(CategoryFilter, dispatchEventOnAnyThread); |
| 111 ListenersMap::iterator it = m_listeners->find(std::make_pair(name, phase)); | 111 ListenersMap::iterator it = m_listeners->find(std::make_pair(name, phase)); |
| 112 if (it == m_listeners->end()) | 112 if (it == m_listeners->end()) |
| 113 m_listeners->add(std::make_pair(name, phase), adoptPtrWillBeNoop(new Wil
lBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >())).storedValue->value->a
ppend(listener); | 113 m_listeners->add(std::make_pair(name, phase), adoptPtrWillBeNoop(new Wil
lBeHeapVector<OwnPtrWillBeMember<TraceEventListener>>())).storedValue->value->ap
pend(listener); |
| 114 else | 114 else |
| 115 it->value->append(listener); | 115 it->value->append(listener); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void TraceEventDispatcher::removeAllListeners(void* eventTarget, InspectorClient
* client) | 118 void TraceEventDispatcher::removeAllListeners(void* eventTarget, InspectorClient
* client) |
| 119 { | 119 { |
| 120 ASSERT(isMainThread()); | 120 ASSERT(isMainThread()); |
| 121 processBackgroundEvents(); | 121 processBackgroundEvents(); |
| 122 { | 122 { |
| 123 MutexLocker locker(m_mutex); | 123 MutexLocker locker(m_mutex); |
| 124 | 124 |
| 125 ListenersMap remainingListeners; | 125 ListenersMap remainingListeners; |
| 126 for (auto& listener : *m_listeners) { | 126 for (auto& listener : *m_listeners) { |
| 127 WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener> >& listeners
= *listener.value.get(); | 127 WillBeHeapVector<OwnPtrWillBeMember<TraceEventListener>>& listeners
= *listener.value.get(); |
| 128 for (size_t j = 0; j < listeners.size();) { | 128 for (size_t j = 0; j < listeners.size();) { |
| 129 if (listeners[j]->target() == eventTarget) | 129 if (listeners[j]->target() == eventTarget) |
| 130 listeners.remove(j); | 130 listeners.remove(j); |
| 131 else | 131 else |
| 132 ++j; | 132 ++j; |
| 133 } | 133 } |
| 134 if (!listeners.isEmpty()) | 134 if (!listeners.isEmpty()) |
| 135 remainingListeners.add(listener.key, listener.value.release()); | 135 remainingListeners.add(listener.key, listener.value.release()); |
| 136 } | 136 } |
| 137 m_listeners->swap(remainingListeners); | 137 m_listeners->swap(remainingListeners); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 156 ASSERT(isMainThread()); | 156 ASSERT(isMainThread()); |
| 157 if (index == kNotFound || m_argumentTypes[index] != expectedType) { | 157 if (index == kNotFound || m_argumentTypes[index] != expectedType) { |
| 158 ASSERT_NOT_REACHED(); | 158 ASSERT_NOT_REACHED(); |
| 159 return missingValue; | 159 return missingValue; |
| 160 } | 160 } |
| 161 return m_argumentValues[index]; | 161 return m_argumentValues[index]; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace blink | 164 } // namespace blink |
| 165 | 165 |
| OLD | NEW |