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 23 matching lines...) Expand all Loading... |
34 #include "core/dom/ContextLifecycleObserver.h" | 34 #include "core/dom/ContextLifecycleObserver.h" |
35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
36 #include "core/dom/ExecutionContextTask.h" | 36 #include "core/dom/ExecutionContextTask.h" |
37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
38 #include "core/events/EventTarget.h" | 38 #include "core/events/EventTarget.h" |
39 #include "core/inspector/AsyncOperationMap.h" | 39 #include "core/inspector/AsyncOperationMap.h" |
40 #include "core/inspector/V8DebuggerAgent.h" | 40 #include "core/inspector/V8DebuggerAgent.h" |
41 #include "core/xmlhttprequest/XMLHttpRequest.h" | 41 #include "core/xmlhttprequest/XMLHttpRequest.h" |
42 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" | 42 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" |
43 #include "platform/ScriptForbiddenScope.h" | 43 #include "platform/ScriptForbiddenScope.h" |
44 #include "wtf/MainThread.h" | |
45 #include "wtf/Optional.h" | |
46 #include "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
47 #include "wtf/text/StringHash.h" | 45 #include "wtf/text/StringHash.h" |
48 | 46 |
49 namespace { | 47 namespace { |
50 | 48 |
51 static const char setTimeoutName[] = "setTimeout"; | 49 static const char setTimeoutName[] = "setTimeout"; |
52 static const char setIntervalName[] = "setInterval"; | 50 static const char setIntervalName[] = "setInterval"; |
53 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 51 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
54 static const char xhrSendName[] = "XMLHttpRequest.send"; | 52 static const char xhrSendName[] = "XMLHttpRequest.send"; |
55 static const char enqueueMutationRecordName[] = "Mutation"; | 53 static const char enqueueMutationRecordName[] = "Mutation"; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } else { | 233 } else { |
236 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); | 234 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); |
237 } | 235 } |
238 return true; | 236 return true; |
239 } | 237 } |
240 | 238 |
241 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) | 239 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) |
242 { | 240 { |
243 ASSERT(eventTarget->executionContext()); | 241 ASSERT(eventTarget->executionContext()); |
244 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 242 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
245 Optional<ScriptForbiddenScope::AllowUserAgentScript> allowScripting; | 243 ScriptForbiddenScope::AllowUserAgentScript allowScripting; |
246 if (isMainThread()) | |
247 allowScripting.emplace(); | |
248 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type()
); | 244 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type()
); |
249 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); | 245 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); |
250 data->m_eventCallChains.set(event, operationId); | 246 data->m_eventCallChains.set(event, operationId); |
251 } | 247 } |
252 | 248 |
253 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) | 249 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) |
254 { | 250 { |
255 ASSERT(eventTarget->executionContext()); | 251 ASSERT(eventTarget->executionContext()); |
256 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 252 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
257 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget->
executionContext())) | 253 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget->
executionContext())) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); | 299 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); |
304 } | 300 } |
305 | 301 |
306 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) | 302 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) |
307 { | 303 { |
308 ASSERT(context); | 304 ASSERT(context); |
309 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 305 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
310 ExecutionContextData* data = createContextDataIfNeeded(context); | 306 ExecutionContextData* data = createContextDataIfNeeded(context); |
311 if (data->m_mutationObserverCallChains.contains(observer)) | 307 if (data->m_mutationObserverCallChains.contains(observer)) |
312 return; | 308 return; |
313 Optional<ScriptForbiddenScope::AllowUserAgentScript> allowScripting; | 309 ScriptForbiddenScope::AllowUserAgentScript allowScripting; |
314 if (isMainThread()) | |
315 allowScripting.emplace(); | |
316 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati
onRecordName); | 310 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati
onRecordName); |
317 data->m_mutationObserverCallChains.set(observer, operationId); | 311 data->m_mutationObserverCallChains.set(observer, operationId); |
318 } | 312 } |
319 | 313 |
320 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) | 314 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) |
321 { | 315 { |
322 ASSERT(context); | 316 ASSERT(context); |
323 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 317 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
324 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 318 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
325 data->m_mutationObserverCallChains.remove(observer); | 319 data->m_mutationObserverCallChains.remove(observer); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 { | 431 { |
438 #if ENABLE(OILPAN) | 432 #if ENABLE(OILPAN) |
439 visitor->trace(m_executionContextDataMap); | 433 visitor->trace(m_executionContextDataMap); |
440 visitor->trace(m_debuggerAgent); | 434 visitor->trace(m_debuggerAgent); |
441 visitor->trace(m_instrumentingAgents); | 435 visitor->trace(m_instrumentingAgents); |
442 #endif | 436 #endif |
443 V8DebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 437 V8DebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
444 } | 438 } |
445 | 439 |
446 } // namespace blink | 440 } // namespace blink |
OLD | NEW |