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 16 matching lines...) Expand all Loading... |
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 "public/web/WebLeakDetector.h" | 31 #include "public/web/WebLeakDetector.h" |
32 | 32 |
33 #include "bindings/core/v8/V8GCController.h" | 33 #include "bindings/core/v8/V8GCController.h" |
34 #include "core/editing/spellcheck/SpellChecker.h" | 34 #include "core/editing/spellcheck/SpellChecker.h" |
35 #include "core/fetch/MemoryCache.h" | 35 #include "core/fetch/MemoryCache.h" |
36 #include "core/inspector/InstanceCounters.h" | 36 #include "core/inspector/InstanceCounters.h" |
| 37 #include "core/workers/InProcessWorkerMessagingProxy.h" |
37 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerThread.h" |
38 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
39 #include "public/web/WebFrame.h" | 40 #include "public/web/WebFrame.h" |
40 #include "web/WebLocalFrameImpl.h" | 41 #include "web/WebLocalFrameImpl.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 class WebLeakDetectorImpl final : public WebLeakDetector { | 47 class WebLeakDetectorImpl final : public WebLeakDetector { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) | 118 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) |
118 { | 119 { |
119 // We do a second and third GC here to address flakiness | 120 // We do a second and third GC here to address flakiness |
120 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. | 121 // The second GC is necessary as Resource GC may have postponed clean-up tas
ks to next event loop. |
121 // The third GC is necessary for cleaning up Document after worker object di
ed. | 122 // The third GC is necessary for cleaning up Document after worker object di
ed. |
122 | 123 |
123 V8GCController::collectAllGarbageForTesting(V8PerIsolateData::mainThreadIsol
ate()); | 124 V8GCController::collectAllGarbageForTesting(V8PerIsolateData::mainThreadIsol
ate()); |
124 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 125 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
125 | 126 |
126 // Inspect counters on the next event loop. | 127 // Inspect counters on the next event loop. |
127 if (--m_numberOfGCNeeded) | 128 if (--m_numberOfGCNeeded > 0) { |
128 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 129 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
129 else | 130 } else if (m_numberOfGCNeeded > -1 && InProcessWorkerMessagingProxy::proxyCo
unt()) { |
| 131 // It is possible that all posted tasks for finalizing in-process proxy
objects |
| 132 // will not have run before the final round of GCs started. If so, do ye
t |
| 133 // another pass, letting these tasks run and then afterwards perform a G
C to tidy up. |
| 134 // |
| 135 // TODO(sof): use proxyCount() to always decide if another GC needs to b
e scheduled. |
| 136 // Some debug bots running browser unit tests disagree (crbug.com/616714
) |
| 137 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 138 } else { |
130 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); | 139 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 140 } |
131 } | 141 } |
132 | 142 |
133 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) | 143 void WebLeakDetectorImpl::delayedReport(Timer<WebLeakDetectorImpl>*) |
134 { | 144 { |
135 DCHECK(m_client); | 145 DCHECK(m_client); |
136 | 146 |
137 WebLeakDetectorClient::Result result; | 147 WebLeakDetectorClient::Result result; |
138 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); | 148 result.numberOfLiveAudioNodes = InstanceCounters::counterValue(InstanceCount
ers::AudioHandlerCounter); |
139 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); | 149 result.numberOfLiveDocuments = InstanceCounters::counterValue(InstanceCounte
rs::DocumentCounter); |
140 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); | 150 result.numberOfLiveNodes = InstanceCounters::counterValue(InstanceCounters::
NodeCounter); |
(...skipping 12 matching lines...) Expand all Loading... |
153 } | 163 } |
154 | 164 |
155 } // namespace | 165 } // namespace |
156 | 166 |
157 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) | 167 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) |
158 { | 168 { |
159 return new WebLeakDetectorImpl(client); | 169 return new WebLeakDetectorImpl(client); |
160 } | 170 } |
161 | 171 |
162 } // namespace blink | 172 } // namespace blink |
OLD | NEW |