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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (it == m_handlers.end()) | 93 if (it == m_handlers.end()) |
94 continue; | 94 continue; |
95 Vector<BoundTraceEventHandler>& handlers = it->value; | 95 Vector<BoundTraceEventHandler>& handlers = it->value; |
96 for (size_t handlerIndex = 0; handlerIndex < handlers.size(); ++handlerI
ndex) | 96 for (size_t handlerIndex = 0; handlerIndex < handlers.size(); ++handlerI
ndex) |
97 (handlers[handlerIndex].instance->*(handlers[handlerIndex].method))(
event); | 97 (handlers[handlerIndex].instance->*(handlers[handlerIndex].method))(
event); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 void TraceEventDispatcher::innerAddListener(const char* name, char phase, TraceE
ventTargetBase* instance, TraceEventHandlerMethod method, InspectorClient* clien
t) | 101 void TraceEventDispatcher::innerAddListener(const char* name, char phase, TraceE
ventTargetBase* instance, TraceEventHandlerMethod method, InspectorClient* clien
t) |
102 { | 102 { |
| 103 static const char CategoryFilter[] = "devtools,webkit"; |
| 104 |
103 ASSERT(isMainThread()); | 105 ASSERT(isMainThread()); |
104 MutexLocker locker(m_mutex); | 106 MutexLocker locker(m_mutex); |
105 if (m_handlers.isEmpty()) | 107 if (m_handlers.isEmpty()) |
106 client->setTraceEventCallback(dispatchEventOnAnyThread); | 108 client->setTraceEventCallback(CategoryFilter, dispatchEventOnAnyThread); |
107 HandlersMap::iterator it = m_handlers.find(std::make_pair(name, phase)); | 109 HandlersMap::iterator it = m_handlers.find(std::make_pair(name, phase)); |
108 if (it == m_handlers.end()) | 110 if (it == m_handlers.end()) |
109 m_handlers.add(std::make_pair(name, phase), Vector<BoundTraceEventHandle
r>()).storedValue->value.append(BoundTraceEventHandler(instance, method)); | 111 m_handlers.add(std::make_pair(name, phase), Vector<BoundTraceEventHandle
r>()).storedValue->value.append(BoundTraceEventHandler(instance, method)); |
110 else | 112 else |
111 it->value.append(BoundTraceEventHandler(instance, method)); | 113 it->value.append(BoundTraceEventHandler(instance, method)); |
112 } | 114 } |
113 | 115 |
114 void TraceEventDispatcher::removeAllListeners(TraceEventTargetBase* instance, In
spectorClient* client) | 116 void TraceEventDispatcher::removeAllListeners(TraceEventTargetBase* instance, In
spectorClient* client) |
115 { | 117 { |
116 ASSERT(isMainThread()); | 118 ASSERT(isMainThread()); |
117 processBackgroundEvents(); | 119 processBackgroundEvents(); |
118 { | 120 { |
119 MutexLocker locker(m_mutex); | 121 MutexLocker locker(m_mutex); |
120 | 122 |
121 HandlersMap remainingHandlers; | 123 HandlersMap remainingHandlers; |
122 for (HandlersMap::iterator it = m_handlers.begin(); it != m_handlers.end
(); ++it) { | 124 for (HandlersMap::iterator it = m_handlers.begin(); it != m_handlers.end
(); ++it) { |
123 Vector<BoundTraceEventHandler>& handlers = it->value; | 125 Vector<BoundTraceEventHandler>& handlers = it->value; |
124 for (size_t j = 0; j < handlers.size();) { | 126 for (size_t j = 0; j < handlers.size();) { |
125 if (handlers[j].instance == instance) | 127 if (handlers[j].instance == instance) |
126 handlers.remove(j); | 128 handlers.remove(j); |
127 else | 129 else |
128 ++j; | 130 ++j; |
129 } | 131 } |
130 if (!handlers.isEmpty()) | 132 if (!handlers.isEmpty()) |
131 remainingHandlers.add(it->key, it->value); | 133 remainingHandlers.add(it->key, it->value); |
132 } | 134 } |
133 m_handlers.swap(remainingHandlers); | 135 m_handlers.swap(remainingHandlers); |
134 } | 136 } |
135 if (m_handlers.isEmpty()) | 137 if (m_handlers.isEmpty()) |
136 client->setTraceEventCallback(0); | 138 client->resetTraceEventCallback(); |
137 } | 139 } |
138 | 140 |
139 size_t TraceEventDispatcher::TraceEvent::findParameter(const char* name) const | 141 size_t TraceEventDispatcher::TraceEvent::findParameter(const char* name) const |
140 { | 142 { |
141 for (int i = 0; i < m_argumentCount; ++i) { | 143 for (int i = 0; i < m_argumentCount; ++i) { |
142 if (!strcmp(name, m_argumentNames[i])) | 144 if (!strcmp(name, m_argumentNames[i])) |
143 return i; | 145 return i; |
144 } | 146 } |
145 return kNotFound; | 147 return kNotFound; |
146 } | 148 } |
147 | 149 |
148 const TraceEvent::TraceValueUnion& TraceEventDispatcher::TraceEvent::parameter(c
onst char* name, unsigned char expectedType) const | 150 const TraceEvent::TraceValueUnion& TraceEventDispatcher::TraceEvent::parameter(c
onst char* name, unsigned char expectedType) const |
149 { | 151 { |
150 static WebCore::TraceEvent::TraceValueUnion missingValue; | 152 static WebCore::TraceEvent::TraceValueUnion missingValue; |
151 size_t index = findParameter(name); | 153 size_t index = findParameter(name); |
152 if (index == kNotFound || m_argumentTypes[index] != expectedType) { | 154 if (index == kNotFound || m_argumentTypes[index] != expectedType) { |
153 ASSERT_NOT_REACHED(); | 155 ASSERT_NOT_REACHED(); |
154 return missingValue; | 156 return missingValue; |
155 } | 157 } |
156 return *reinterpret_cast<const WebCore::TraceEvent::TraceValueUnion*>(m_argu
mentValues + index); | 158 return *reinterpret_cast<const WebCore::TraceEvent::TraceValueUnion*>(m_argu
mentValues + index); |
157 } | 159 } |
158 | 160 |
159 } // namespace WebCore | 161 } // namespace WebCore |
160 | 162 |
OLD | NEW |