Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/AsyncCallStackTracker.h" | 32 #include "core/inspector/AsyncCallStackTracker.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/V8Binding.h" | 34 #include "bindings/core/v8/V8Binding.h" |
| 35 #include "bindings/core/v8/V8RecursionScope.h" | 35 #include "bindings/core/v8/V8RecursionScope.h" |
| 36 #include "core/dom/ContextLifecycleObserver.h" | |
| 36 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/dom/ExecutionContextTask.h" | 38 #include "core/dom/ExecutionContextTask.h" |
| 38 #include "core/dom/Microtask.h" | 39 #include "core/dom/Microtask.h" |
| 39 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 40 #include "core/events/EventTarget.h" | 41 #include "core/events/EventTarget.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 "wtf/text/StringBuilder.h" | 44 #include "wtf/text/StringBuilder.h" |
| 44 #include "wtf/text/StringHash.h" | 45 #include "wtf/text/StringHash.h" |
| 45 #include <v8.h> | 46 #include <v8.h> |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| 48 | 49 |
| 49 static const char setTimeoutName[] = "setTimeout"; | 50 static const char setTimeoutName[] = "setTimeout"; |
| 50 static const char setIntervalName[] = "setInterval"; | 51 static const char setIntervalName[] = "setInterval"; |
| 51 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 52 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
| 52 static const char xhrSendName[] = "XMLHttpRequest.send"; | 53 static const char xhrSendName[] = "XMLHttpRequest.send"; |
| 53 static const char enqueueMutationRecordName[] = "Mutation"; | 54 static const char enqueueMutationRecordName[] = "Mutation"; |
| 54 | 55 |
| 55 } | 56 } |
| 56 | 57 |
| 57 namespace blink { | 58 namespace blink { |
| 58 | 59 |
| 59 void AsyncCallStackTracker::ExecutionContextData::contextDestroyed() | 60 class AsyncCallStackTracker::ExecutionContextData final : public NoBaseWillBeGar bageCollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { |
| 60 { | 61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 61 ASSERT(executionContext()); | 62 public: |
| 62 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionContex tDataMap.take(executionContext()); | 63 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext) |
| 63 ASSERT_UNUSED(self, self == this); | 64 : ContextLifecycleObserver(executionContext) |
| 64 ContextLifecycleObserver::contextDestroyed(); | 65 , m_circularSequentialID(0) |
| 65 } | 66 , m_tracker(tracker) |
| 67 { | |
| 68 } | |
| 66 | 69 |
| 67 int AsyncCallStackTracker::ExecutionContextData::circularSequentialID() | 70 virtual void contextDestroyed() override |
| 68 { | 71 { |
| 69 ++m_circularSequentialID; | 72 ASSERT(executionContext()); |
| 70 if (m_circularSequentialID <= 0) | 73 OwnPtrWillBeRawPtr<ExecutionContextData> self = adoptPtrWillBeNoop(m_tra cker->m_executionContextDataMap.take(executionContext())); |
| 71 m_circularSequentialID = 1; | 74 ASSERT_UNUSED(self, self == this); |
| 72 return m_circularSequentialID; | 75 ContextLifecycleObserver::contextDestroyed(); |
| 73 } | 76 } |
| 74 | 77 |
| 75 void AsyncCallStackTracker::ExecutionContextData::trace(Visitor* visitor) | 78 int circularSequentialID() |
| 76 { | 79 { |
| 77 visitor->trace(m_tracker); | 80 ++m_circularSequentialID; |
| 81 if (m_circularSequentialID <= 0) | |
| 82 m_circularSequentialID = 1; | |
| 83 return m_circularSequentialID; | |
| 84 } | |
| 85 | |
| 86 void trace(Visitor* visitor) | |
| 87 { | |
| 88 visitor->trace(m_tracker); | |
| 78 #if ENABLE(OILPAN) | 89 #if ENABLE(OILPAN) |
| 79 visitor->trace(m_timerCallChains); | 90 visitor->trace(m_timerCallChains); |
| 80 visitor->trace(m_animationFrameCallChains); | 91 visitor->trace(m_animationFrameCallChains); |
| 81 visitor->trace(m_eventCallChains); | 92 visitor->trace(m_eventCallChains); |
| 82 visitor->trace(m_xhrCallChains); | 93 visitor->trace(m_xhrCallChains); |
| 83 visitor->trace(m_mutationObserverCallChains); | 94 visitor->trace(m_mutationObserverCallChains); |
| 84 visitor->trace(m_executionContextTaskCallChains); | 95 visitor->trace(m_executionContextTaskCallChains); |
| 85 visitor->trace(m_v8AsyncTaskCallChains); | 96 visitor->trace(m_v8AsyncTaskCallChains); |
| 86 visitor->trace(m_asyncOperationCallChains); | 97 visitor->trace(m_asyncOperationCallChains); |
| 87 #endif | 98 #endif |
| 88 } | 99 } |
| 100 | |
| 101 private: | |
| 102 int m_circularSequentialID; | |
| 103 | |
| 104 public: | |
|
yurys
2014/11/11 12:31:37
Just move these fields above the private: section
| |
| 105 RawPtrWillBeMember<AsyncCallStackTracker> m_tracker; | |
| 106 HashSet<int> m_intervalTimerIds; | |
| 107 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallChain s; | |
| 108 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationFrame CallChains; | |
| 109 WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCallCha in> > m_eventCallChains; | |
| 110 WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<AsyncC allChain> > m_xhrCallChains; | |
| 111 WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMember<A syncCallChain> > m_mutationObserverCallChains; | |
| 112 WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallChain> > m_executionContextTaskCallChains; | |
| 113 WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8AsyncTask CallChains; | |
| 114 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOperation CallChains; | |
| 115 }; | |
| 89 | 116 |
| 90 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 117 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
| 91 { | 118 { |
| 92 const AtomicString& interfaceName = eventTarget->interfaceName(); | 119 const AtomicString& interfaceName = eventTarget->interfaceName(); |
| 93 if (interfaceName == EventTargetNames::XMLHttpRequest) | 120 if (interfaceName == EventTargetNames::XMLHttpRequest) |
| 94 return static_cast<XMLHttpRequest*>(eventTarget); | 121 return static_cast<XMLHttpRequest*>(eventTarget); |
| 95 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) | 122 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) |
| 96 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; | 123 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; |
| 97 return 0; | 124 return 0; |
| 98 } | 125 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 | 474 |
| 448 bool AsyncCallStackTracker::validateCallFrames(const ScriptValue& callFrames) | 475 bool AsyncCallStackTracker::validateCallFrames(const ScriptValue& callFrames) |
| 449 { | 476 { |
| 450 return !callFrames.isEmpty() || m_currentAsyncCallChain; | 477 return !callFrames.isEmpty() || m_currentAsyncCallChain; |
| 451 } | 478 } |
| 452 | 479 |
| 453 AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex tDataIfNeeded(ExecutionContext* context) | 480 AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex tDataIfNeeded(ExecutionContext* context) |
| 454 { | 481 { |
| 455 ExecutionContextData* data = m_executionContextDataMap.get(context); | 482 ExecutionContextData* data = m_executionContextDataMap.get(context); |
| 456 if (!data) { | 483 if (!data) { |
| 457 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy ncCallStackTracker::ExecutionContextData(this, context))) | 484 data = new AsyncCallStackTracker::ExecutionContextData(this, context); |
|
yurys
2014/11/11 12:31:37
Please revert this. The code before your change fo
| |
| 458 .storedValue->value.get(); | 485 m_executionContextDataMap.set(context, data); |
| 459 } | 486 } |
| 460 return data; | 487 return data; |
| 461 } | 488 } |
| 462 | 489 |
| 463 void AsyncCallStackTracker::clear() | 490 void AsyncCallStackTracker::clear() |
| 464 { | 491 { |
| 465 m_currentAsyncCallChain.clear(); | 492 m_currentAsyncCallChain.clear(); |
| 466 m_nestedAsyncCallCount = 0; | 493 m_nestedAsyncCallCount = 0; |
| 494 #if ENABLE(OILPAN) | |
| 467 m_executionContextDataMap.clear(); | 495 m_executionContextDataMap.clear(); |
| 496 #else | |
| 497 ExecutionContextDataMap copy; | |
| 498 m_executionContextDataMap.swap(copy); | |
| 499 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e nd(); ++it) | |
| 500 delete it->value; | |
| 501 #endif | |
| 468 } | 502 } |
| 469 | 503 |
| 470 void AsyncCallStackTracker::trace(Visitor* visitor) | 504 void AsyncCallStackTracker::trace(Visitor* visitor) |
| 471 { | 505 { |
| 472 visitor->trace(m_currentAsyncCallChain); | 506 visitor->trace(m_currentAsyncCallChain); |
| 473 #if ENABLE(OILPAN) | 507 #if ENABLE(OILPAN) |
| 474 visitor->trace(m_executionContextDataMap); | 508 visitor->trace(m_executionContextDataMap); |
| 475 #endif | 509 #endif |
| 476 } | 510 } |
| 477 | 511 |
| 478 } // namespace blink | 512 } // namespace blink |
| OLD | NEW |