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 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/inspector/AsyncCallTracker.h" | 32 #include "core/inspector/AsyncCallTracker.h" |
33 | 33 |
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/timing/PerformanceObserver.h" |
41 #include "core/xmlhttprequest/XMLHttpRequest.h" | 42 #include "core/xmlhttprequest/XMLHttpRequest.h" |
42 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" | 43 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" |
43 #include "platform/ScriptForbiddenScope.h" | 44 #include "platform/ScriptForbiddenScope.h" |
44 #include "wtf/MainThread.h" | 45 #include "wtf/MainThread.h" |
45 #include "wtf/Optional.h" | 46 #include "wtf/Optional.h" |
46 #include "wtf/text/StringBuilder.h" | 47 #include "wtf/text/StringBuilder.h" |
47 #include "wtf/text/StringHash.h" | 48 #include "wtf/text/StringHash.h" |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 static const char setTimeoutName[] = "setTimeout"; | 52 static const char setTimeoutName[] = "setTimeout"; |
52 static const char setIntervalName[] = "setInterval"; | 53 static const char setIntervalName[] = "setInterval"; |
53 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 54 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
54 static const char xhrSendName[] = "XMLHttpRequest.send"; | 55 static const char xhrSendName[] = "XMLHttpRequest.send"; |
55 static const char enqueueMutationRecordName[] = "Mutation"; | 56 static const char enqueueMutationRecordName[] = "Mutation"; |
| 57 static const char enqueuePerformanceObservationsName[] = "PerformanceObservation
"; |
56 | 58 |
57 } | 59 } |
58 | 60 |
59 namespace blink { | 61 namespace blink { |
60 | 62 |
61 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC
ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { | 63 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC
ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { |
62 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData
); | 64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData
); |
63 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(AsyncCallTracker::ExecutionContextDa
ta); | 65 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(AsyncCallTracker::ExecutionContextDa
ta); |
64 public: | 66 public: |
65 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) | 67 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) |
66 : ContextLifecycleObserver(executionContext) | 68 : ContextLifecycleObserver(executionContext) |
67 , m_tracker(tracker) | 69 , m_tracker(tracker) |
68 , m_timerCallChains(tracker->m_debuggerAgent) | 70 , m_timerCallChains(tracker->m_debuggerAgent) |
69 , m_animationFrameCallChains(tracker->m_debuggerAgent) | 71 , m_animationFrameCallChains(tracker->m_debuggerAgent) |
70 , m_eventCallChains(tracker->m_debuggerAgent) | 72 , m_eventCallChains(tracker->m_debuggerAgent) |
71 , m_xhrCallChains(tracker->m_debuggerAgent) | 73 , m_xhrCallChains(tracker->m_debuggerAgent) |
72 , m_mutationObserverCallChains(tracker->m_debuggerAgent) | 74 , m_mutationObserverCallChains(tracker->m_debuggerAgent) |
| 75 , m_performanceObserverCallChains(tracker->m_debuggerAgent) |
73 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) | 76 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) |
74 , m_asyncOperations(tracker->m_debuggerAgent) | 77 , m_asyncOperations(tracker->m_debuggerAgent) |
75 { | 78 { |
76 } | 79 } |
77 | 80 |
78 void contextDestroyed() override | 81 void contextDestroyed() override |
79 { | 82 { |
80 ASSERT(executionContext()); | 83 ASSERT(executionContext()); |
81 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); | 84 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); |
82 ASSERT_UNUSED(self, self == this); | 85 ASSERT_UNUSED(self, self == this); |
(...skipping 12 matching lines...) Expand all Loading... |
95 visitor->trace(m_tracker); | 98 visitor->trace(m_tracker); |
96 #if ENABLE(OILPAN) | 99 #if ENABLE(OILPAN) |
97 visitor->trace(m_timerCallChains); | 100 visitor->trace(m_timerCallChains); |
98 visitor->trace(m_animationFrameCallChains); | 101 visitor->trace(m_animationFrameCallChains); |
99 visitor->trace(m_eventCallChains); | 102 visitor->trace(m_eventCallChains); |
100 visitor->trace(m_xhrCallChains); | 103 visitor->trace(m_xhrCallChains); |
101 visitor->trace(m_mutationObserverCallChains); | 104 visitor->trace(m_mutationObserverCallChains); |
102 visitor->trace(m_executionContextTaskCallChains); | 105 visitor->trace(m_executionContextTaskCallChains); |
103 visitor->trace(m_asyncOperations); | 106 visitor->trace(m_asyncOperations); |
104 #endif | 107 #endif |
| 108 visitor->trace(m_performanceObserverCallChains); |
105 ContextLifecycleObserver::trace(visitor); | 109 ContextLifecycleObserver::trace(visitor); |
106 } | 110 } |
107 | 111 |
108 RawPtrWillBeMember<AsyncCallTracker> m_tracker; | 112 RawPtrWillBeMember<AsyncCallTracker> m_tracker; |
109 HashSet<int> m_intervalTimerIds; | 113 HashSet<int> m_intervalTimerIds; |
110 AsyncOperationMap<int> m_timerCallChains; | 114 AsyncOperationMap<int> m_timerCallChains; |
111 AsyncOperationMap<int> m_animationFrameCallChains; | 115 AsyncOperationMap<int> m_animationFrameCallChains; |
112 AsyncOperationMap<RawPtrWillBeMember<Event> > m_eventCallChains; | 116 AsyncOperationMap<RawPtrWillBeMember<Event> > m_eventCallChains; |
113 AsyncOperationMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; | 117 AsyncOperationMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; |
114 AsyncOperationMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC
allChains; | 118 AsyncOperationMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC
allChains; |
| 119 AsyncOperationMap<Member<PerformanceObserver>, HeapHashMap<Member<Performanc
eObserver>, int>> m_performanceObserverCallChains; |
115 AsyncOperationMap<ExecutionContextTask*> m_executionContextTaskCallChains; | 120 AsyncOperationMap<ExecutionContextTask*> m_executionContextTaskCallChains; |
116 AsyncOperationMap<int> m_asyncOperations; | 121 AsyncOperationMap<int> m_asyncOperations; |
117 | 122 |
118 private: | 123 private: |
119 void disposeCallChains() | 124 void disposeCallChains() |
120 { | 125 { |
121 m_timerCallChains.dispose(); | 126 m_timerCallChains.dispose(); |
122 m_animationFrameCallChains.dispose(); | 127 m_animationFrameCallChains.dispose(); |
123 m_eventCallChains.dispose(); | 128 m_eventCallChains.dispose(); |
124 m_xhrCallChains.dispose(); | 129 m_xhrCallChains.dispose(); |
125 m_mutationObserverCallChains.dispose(); | 130 m_mutationObserverCallChains.dispose(); |
| 131 m_performanceObserverCallChains.dispose(); |
126 m_executionContextTaskCallChains.dispose(); | 132 m_executionContextTaskCallChains.dispose(); |
127 m_asyncOperations.dispose(); | 133 m_asyncOperations.dispose(); |
128 } | 134 } |
129 }; | 135 }; |
130 | 136 |
131 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 137 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
132 { | 138 { |
133 const AtomicString& interfaceName = eventTarget->interfaceName(); | 139 const AtomicString& interfaceName = eventTarget->interfaceName(); |
134 if (interfaceName == EventTargetNames::XMLHttpRequest) | 140 if (interfaceName == EventTargetNames::XMLHttpRequest) |
135 return static_cast<XMLHttpRequest*>(eventTarget); | 141 return static_cast<XMLHttpRequest*>(eventTarget); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 ASSERT(context); | 333 ASSERT(context); |
328 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 334 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
329 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 335 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
330 willFireAsyncCall(data->m_mutationObserverCallChains.get(observer)); | 336 willFireAsyncCall(data->m_mutationObserverCallChains.get(observer)); |
331 data->m_mutationObserverCallChains.remove(observer); | 337 data->m_mutationObserverCallChains.remove(observer); |
332 } else { | 338 } else { |
333 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); | 339 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); |
334 } | 340 } |
335 } | 341 } |
336 | 342 |
| 343 void AsyncCallTracker::didEnqueuePerformanceObserverEntries(ExecutionContext* co
ntext, PerformanceObserver* observer) |
| 344 { |
| 345 ASSERT(context); |
| 346 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 347 ExecutionContextData* data = createContextDataIfNeeded(context); |
| 348 if (data->m_performanceObserverCallChains.contains(observer)) |
| 349 return; |
| 350 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueuePerfor
manceObservationsName); |
| 351 data->m_performanceObserverCallChains.set(observer, operationId); |
| 352 } |
| 353 |
| 354 void AsyncCallTracker::didClearAllPerformanceObservations(ExecutionContext* cont
ext, PerformanceObserver* observer) |
| 355 { |
| 356 ASSERT(context); |
| 357 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 358 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 359 data->m_performanceObserverCallChains.remove(observer); |
| 360 } |
| 361 |
| 362 void AsyncCallTracker::willDeliverPerformanceObservations(ExecutionContext* cont
ext, PerformanceObserver* observer) |
| 363 { |
| 364 ASSERT(context); |
| 365 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 366 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
| 367 willFireAsyncCall(data->m_performanceObserverCallChains.get(observer)); |
| 368 data->m_performanceObserverCallChains.remove(observer); |
| 369 } else { |
| 370 willFireAsyncCall(V8DebuggerAgent::unknownAsyncOperationId); |
| 371 } |
| 372 } |
| 373 |
337 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) | 374 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) |
338 { | 375 { |
339 ASSERT(context); | 376 ASSERT(context); |
340 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 377 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
341 if (task->taskNameForInstrumentation().isEmpty()) | 378 if (task->taskNameForInstrumentation().isEmpty()) |
342 return; | 379 return; |
343 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam
eForInstrumentation()); | 380 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam
eForInstrumentation()); |
344 ExecutionContextData* data = createContextDataIfNeeded(context); | 381 ExecutionContextData* data = createContextDataIfNeeded(context); |
345 data->m_executionContextTaskCallChains.set(task, operationId); | 382 data->m_executionContextTaskCallChains.set(task, operationId); |
346 } | 383 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 { | 471 { |
435 #if ENABLE(OILPAN) | 472 #if ENABLE(OILPAN) |
436 visitor->trace(m_executionContextDataMap); | 473 visitor->trace(m_executionContextDataMap); |
437 visitor->trace(m_debuggerAgent); | 474 visitor->trace(m_debuggerAgent); |
438 visitor->trace(m_instrumentingAgents); | 475 visitor->trace(m_instrumentingAgents); |
439 #endif | 476 #endif |
440 V8DebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 477 V8DebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
441 } | 478 } |
442 | 479 |
443 } // namespace blink | 480 } // namespace blink |
OLD | NEW |