| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 class WebLeakDetectorImpl final : public WebLeakDetector { | 53 class WebLeakDetectorImpl final : public WebLeakDetector { |
| 54 WTF_MAKE_NONCOPYABLE(WebLeakDetectorImpl); | 54 WTF_MAKE_NONCOPYABLE(WebLeakDetectorImpl); |
| 55 public: | 55 public: |
| 56 explicit WebLeakDetectorImpl(WebLeakDetectorClient* client) | 56 explicit WebLeakDetectorImpl(WebLeakDetectorClient* client) |
| 57 : m_client(client) | 57 : m_client(client) |
| 58 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) | 58 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) |
| 59 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) | 59 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) |
| 60 , m_numberOfGCNeeded(0) | 60 , m_numberOfGCNeeded(0) |
| 61 { | 61 { |
| 62 ASSERT(m_client); | 62 DCHECK(m_client); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ~WebLeakDetectorImpl() override {} | 65 ~WebLeakDetectorImpl() override {} |
| 66 | 66 |
| 67 void prepareForLeakDetection(WebFrame*) override; | 67 void prepareForLeakDetection(WebFrame*) override; |
| 68 void collectGarbageAndReport() override; | 68 void collectGarbageAndReport() override; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 void delayedGCAndReport(Timer<WebLeakDetectorImpl>*); | 71 void delayedGCAndReport(Timer<WebLeakDetectorImpl>*); |
| 72 void delayedReport(Timer<WebLeakDetectorImpl>*); | 72 void delayedReport(Timer<WebLeakDetectorImpl>*); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 // Inspect counters on the next event loop. | 133 // Inspect counters on the next event loop. |
| 134 if (--m_numberOfGCNeeded) | 134 if (--m_numberOfGCNeeded) |
| 135 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 135 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 136 else | 136 else |
| 137 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); | 137 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) | 140 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) |
| 141 { | 141 { |
| 142 ASSERT(m_client); | 142 DCHECK(m_client); |
| 143 | 143 |
| 144 WebLeakDetectorClient::Result result; | 144 WebLeakDetectorClient::Result result; |
| 145 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); | 145 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); |
| 146 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); | 146 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); |
| 147 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); | 147 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); |
| 148 result.numberOfLiveLayoutObjects = InstanceCounters::counterValue(InstanceCo
unters::LayoutObjectCounter); | 148 result.numberOfLiveLayoutObjects = InstanceCounters::counterValue(InstanceCo
unters::LayoutObjectCounter); |
| 149 result.numberOfLiveResources = InstanceCounters::counterValue(InstanceCounte
rs::ResourceCounter); | 149 result.numberOfLiveResources = InstanceCounters::counterValue(InstanceCounte
rs::ResourceCounter); |
| 150 result.numberOfLiveActiveDOMObjects = InstanceCounters::counterValue(Instanc
eCounters::ActiveDOMObjectCounter); | 150 result.numberOfLiveActiveDOMObjects = InstanceCounters::counterValue(Instanc
eCounters::ActiveDOMObjectCounter); |
| 151 result.numberOfLiveScriptPromises = InstanceCounters::counterValue(InstanceC
ounters::ScriptPromiseCounter); | 151 result.numberOfLiveScriptPromises = InstanceCounters::counterValue(InstanceC
ounters::ScriptPromiseCounter); |
| 152 result.numberOfLiveFrames = InstanceCounters::counterValue(InstanceCounters:
:FrameCounter); | 152 result.numberOfLiveFrames = InstanceCounters::counterValue(InstanceCounters:
:FrameCounter); |
| 153 result.numberOfLiveV8PerContextData = InstanceCounters::counterValue(Instanc
eCounters::V8PerContextDataCounter); | 153 result.numberOfLiveV8PerContextData = InstanceCounters::counterValue(Instanc
eCounters::V8PerContextDataCounter); |
| 154 | 154 |
| 155 m_client->onLeakDetectionComplete(result); | 155 m_client->onLeakDetectionComplete(result); |
| 156 | 156 |
| 157 #ifndef NDEBUG | 157 #ifndef NDEBUG |
| 158 showLiveDocumentInstances(); | 158 showLiveDocumentInstances(); |
| 159 #endif | 159 #endif |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace | 162 } // namespace |
| 163 | 163 |
| 164 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) | 164 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) |
| 165 { | 165 { |
| 166 return new WebLeakDetectorImpl(client); | 166 return new WebLeakDetectorImpl(client); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |