| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // leak detector runs, leaks may flakily be reported as the requests keep | 91 // leak detector runs, leaks may flakily be reported as the requests keep |
| 92 // their associated element (and document) alive. | 92 // their associated element (and document) alive. |
| 93 // | 93 // |
| 94 // Stop the spellchecker to prevent this. | 94 // Stop the spellchecker to prevent this. |
| 95 if (frame->isWebLocalFrame()) { | 95 if (frame->isWebLocalFrame()) { |
| 96 WebLocalFrameImpl* localFrame = toWebLocalFrameImpl(frame); | 96 WebLocalFrameImpl* localFrame = toWebLocalFrameImpl(frame); |
| 97 SpellChecker& spellChecker = localFrame->frame()->spellChecker(); | 97 SpellChecker& spellChecker = localFrame->frame()->spellChecker(); |
| 98 spellChecker.prepareForLeakDetection(); | 98 spellChecker.prepareForLeakDetection(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // FIXME: HTML5 Notification should be closed because notification affects the
result of number of DOM objects. | 101 // FIXME: HTML5 Notification should be closed because notification affects the |
| 102 // result of number of DOM objects. |
| 102 | 103 |
| 103 V8PerIsolateData::from(isolate)->clearScriptRegexpContext(); | 104 V8PerIsolateData::from(isolate)->clearScriptRegexpContext(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void WebLeakDetectorImpl::collectGarbageAndReport() { | 107 void WebLeakDetectorImpl::collectGarbageAndReport() { |
| 107 V8GCController::collectAllGarbageForTesting( | 108 V8GCController::collectAllGarbageForTesting( |
| 108 V8PerIsolateData::mainThreadIsolate()); | 109 V8PerIsolateData::mainThreadIsolate()); |
| 109 AbstractAnimationWorkletThread::collectAllGarbage(); | 110 AbstractAnimationWorkletThread::collectAllGarbage(); |
| 110 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 111 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
| 111 | 112 |
| 112 // Task queue may contain delayed object destruction tasks. | 113 // Task queue may contain delayed object destruction tasks. |
| 113 // This method is called from navigation hook inside FrameLoader, | 114 // This method is called from navigation hook inside FrameLoader, |
| 114 // so previous document is still held by the loader until the next event loop. | 115 // so previous document is still held by the loader until the next event loop. |
| 115 // Complete all pending tasks before proceeding to gc. | 116 // Complete all pending tasks before proceeding to gc. |
| 116 m_numberOfGCNeeded = 2; | 117 m_numberOfGCNeeded = 2; |
| 117 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 118 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void WebLeakDetectorImpl::delayedGCAndReport(TimerBase*) { | 121 void WebLeakDetectorImpl::delayedGCAndReport(TimerBase*) { |
| 121 // We do a second and third GC here to address flakiness | 122 // We do a second and third GC here to address flakiness |
| 122 // The second GC is necessary as Resource GC may have postponed clean-up tasks
to next event loop. | 123 // The second GC is necessary as Resource GC may have postponed clean-up tasks |
| 123 // The third GC is necessary for cleaning up Document after worker object died
. | 124 // to next event loop. The third GC is necessary for cleaning up Document |
| 125 // after worker object died. |
| 124 | 126 |
| 125 V8GCController::collectAllGarbageForTesting( | 127 V8GCController::collectAllGarbageForTesting( |
| 126 V8PerIsolateData::mainThreadIsolate()); | 128 V8PerIsolateData::mainThreadIsolate()); |
| 127 AbstractAnimationWorkletThread::collectAllGarbage(); | 129 AbstractAnimationWorkletThread::collectAllGarbage(); |
| 128 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 130 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
| 129 | 131 |
| 130 // Inspect counters on the next event loop. | 132 // Inspect counters on the next event loop. |
| 131 if (--m_numberOfGCNeeded > 0) { | 133 if (--m_numberOfGCNeeded > 0) { |
| 132 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 134 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 133 } else if (m_numberOfGCNeeded > -1 && | 135 } else if (m_numberOfGCNeeded > -1 && |
| 134 InProcessWorkerMessagingProxy::proxyCount()) { | 136 InProcessWorkerMessagingProxy::proxyCount()) { |
| 135 // It is possible that all posted tasks for finalizing in-process proxy obje
cts | 137 // It is possible that all posted tasks for finalizing in-process proxy |
| 136 // will not have run before the final round of GCs started. If so, do yet | 138 // objects will not have run before the final round of GCs started. If so, |
| 137 // another pass, letting these tasks run and then afterwards perform a GC to
tidy up. | 139 // do yet another pass, letting these tasks run and then afterwards perform |
| 140 // a GC to tidy up. |
| 138 // | 141 // |
| 139 // TODO(sof): use proxyCount() to always decide if another GC needs to be sc
heduled. | 142 // TODO(sof): use proxyCount() to always decide if another GC needs to be |
| 140 // Some debug bots running browser unit tests disagree (crbug.com/616714) | 143 // scheduled. Some debug bots running browser unit tests disagree |
| 144 // (crbug.com/616714) |
| 141 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 145 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 142 } else { | 146 } else { |
| 143 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); | 147 m_delayedReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 144 } | 148 } |
| 145 } | 149 } |
| 146 | 150 |
| 147 void WebLeakDetectorImpl::delayedReport(TimerBase*) { | 151 void WebLeakDetectorImpl::delayedReport(TimerBase*) { |
| 148 DCHECK(m_client); | 152 DCHECK(m_client); |
| 149 | 153 |
| 150 WebLeakDetectorClient::Result result; | 154 WebLeakDetectorClient::Result result; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 176 #endif | 180 #endif |
| 177 } | 181 } |
| 178 | 182 |
| 179 } // namespace | 183 } // namespace |
| 180 | 184 |
| 181 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) { | 185 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) { |
| 182 return new WebLeakDetectorImpl(client); | 186 return new WebLeakDetectorImpl(client); |
| 183 } | 187 } |
| 184 | 188 |
| 185 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |