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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 53 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
| 54 static const char xhrSendName[] = "XMLHttpRequest.send"; | 54 static const char xhrSendName[] = "XMLHttpRequest.send"; |
| 55 static const char enqueueMutationRecordName[] = "Mutation"; | 55 static const char enqueueMutationRecordName[] = "Mutation"; |
| 56 | 56 |
| 57 } | 57 } |
| 58 | 58 |
| 59 namespace blink { | 59 namespace blink { |
| 60 | 60 |
| 61 template <class K> | 61 template <class K> |
| 62 class AsyncCallStackTracker::AsyncCallChainMap final { | 62 class AsyncCallStackTracker::AsyncCallChainMap final { |
| 63 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 63 public: | 64 public: |
| 64 typedef HashMap<K, RefPtr<AsyncCallStackTracker::AsyncCallChain> > MapType; | 65 using MapType = WillBeHeapHashMap<K, RefPtrWillBeMember<AsyncCallStackTracke r::AsyncCallChain>>; |
| 65 explicit AsyncCallChainMap(AsyncCallStackTracker* tracker) : m_tracker(track er) { } | 66 explicit AsyncCallChainMap(AsyncCallStackTracker* tracker) : m_tracker(track er) { } |
| 66 | 67 |
| 67 ~AsyncCallChainMap() | 68 ~AsyncCallChainMap() |
| 68 { | 69 { |
| 69 clear(); | 70 clear(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void clear() | 73 void clear() |
| 73 { | 74 { |
| 74 for (auto it : m_asyncCallChains) { | 75 for (auto it : m_asyncCallChains) { |
|
haraken
2014/12/11 16:22:14
Is it OK to touch m_asyncCallChains in AsyncCallCh
sof
2014/12/11 16:27:38
Certainly isn't, thanks for catching. What a mess,
aandrey
2014/12/11 20:43:29
Could you please elaborate why it is not OK? Is it
| |
| 75 if (AsyncCallStackTracker::Listener* listener = m_tracker->m_listene r) | 76 if (AsyncCallStackTracker::Listener* listener = m_tracker->m_listene r) |
| 76 listener->didRemoveAsyncCallChain(it.value.get()); | 77 listener->didRemoveAsyncCallChain(it.value.get()); |
| 77 else | 78 else |
| 78 break; | 79 break; |
| 79 } | 80 } |
| 80 m_asyncCallChains.clear(); | 81 m_asyncCallChains.clear(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void set(typename MapType::KeyPeekInType key, PassRefPtrWillBeRawPtr<AsyncCa llChain> chain) | 84 void set(typename MapType::KeyPeekInType key, PassRefPtrWillBeRawPtr<AsyncCa llChain> chain) |
| 84 { | 85 { |
| 85 m_asyncCallChains.set(key, chain); | 86 m_asyncCallChains.set(key, chain); |
| 86 } | 87 } |
| 87 | 88 |
| 88 bool contains(typename MapType::KeyPeekInType key) const | 89 bool contains(typename MapType::KeyPeekInType key) const |
| 89 { | 90 { |
| 90 return m_asyncCallChains.contains(key); | 91 return m_asyncCallChains.contains(key); |
| 91 } | 92 } |
| 92 | 93 |
| 93 PassRefPtrWillBeRawPtr<AsyncCallChain> get(typename MapType::KeyPeekInType k ey) const | 94 PassRefPtrWillBeRawPtr<AsyncCallChain> get(typename MapType::KeyPeekInType k ey) const |
| 94 { | 95 { |
| 95 return m_asyncCallChains.get(key); | 96 return m_asyncCallChains.get(key); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void remove(typename MapType::KeyPeekInType key) | 99 void remove(typename MapType::KeyPeekInType key) |
| 99 { | 100 { |
| 100 RefPtr<AsyncCallStackTracker::AsyncCallChain> chain = m_asyncCallChains. take(key); | 101 RefPtrWillBeRawPtr<AsyncCallStackTracker::AsyncCallChain> chain = m_asyn cCallChains.take(key); |
| 101 if (chain && m_tracker->m_listener) | 102 if (chain && m_tracker->m_listener) |
| 102 m_tracker->m_listener->didRemoveAsyncCallChain(chain.get()); | 103 m_tracker->m_listener->didRemoveAsyncCallChain(chain.get()); |
| 103 } | 104 } |
| 104 | 105 |
| 106 void trace(Visitor* visitor) | |
| 107 { | |
| 108 visitor->trace(m_asyncCallChains); | |
| 109 } | |
| 110 | |
| 105 private: | 111 private: |
| 106 AsyncCallStackTracker* m_tracker; | 112 AsyncCallStackTracker* m_tracker; |
| 107 MapType m_asyncCallChains; | 113 MapType m_asyncCallChains; |
| 108 }; | 114 }; |
| 109 | 115 |
| 110 class AsyncCallStackTracker::ExecutionContextData final : public NoBaseWillBeGar bageCollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { | 116 class AsyncCallStackTracker::ExecutionContextData final : public NoBaseWillBeGar bageCollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { |
| 111 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 117 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 112 public: | 118 public: |
| 113 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext) | 119 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext) |
| 114 : ContextLifecycleObserver(executionContext) | 120 : ContextLifecycleObserver(executionContext) |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 | 603 |
| 598 void AsyncCallStackTracker::trace(Visitor* visitor) | 604 void AsyncCallStackTracker::trace(Visitor* visitor) |
| 599 { | 605 { |
| 600 visitor->trace(m_currentAsyncCallChain); | 606 visitor->trace(m_currentAsyncCallChain); |
| 601 #if ENABLE(OILPAN) | 607 #if ENABLE(OILPAN) |
| 602 visitor->trace(m_executionContextDataMap); | 608 visitor->trace(m_executionContextDataMap); |
| 603 #endif | 609 #endif |
| 604 } | 610 } |
| 605 | 611 |
| 606 } // namespace blink | 612 } // namespace blink |
| OLD | NEW |