Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Unified Diff: third_party/WebKit/Source/web/WebLeakDetector.cpp

Issue 1472943004: Split up leak detector into two stages for better leak reporting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rephrase WebLeakDetector as two-phased Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebLeakDetector.cpp
diff --git a/third_party/WebKit/Source/web/WebLeakDetector.cpp b/third_party/WebKit/Source/web/WebLeakDetector.cpp
index e1ddecbab86bf329b6cd9c60d7956be2f3b50bd0..1c1c7952c761575948ea7db8dabd925ab9c8b021 100644
--- a/third_party/WebKit/Source/web/WebLeakDetector.cpp
+++ b/third_party/WebKit/Source/web/WebLeakDetector.cpp
@@ -59,6 +59,9 @@ public:
, m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndReport)
, m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport)
, m_numberOfGCNeeded(0)
+#if ENABLE(ASSERT)
+ , m_haveReported(false)
+#endif
{
ASSERT(m_client);
}
@@ -67,6 +70,9 @@ public:
void collectGarbageAndGetDOMCounts(WebLocalFrame*) override;
+ void prepareForLeakDetection(WebLocalFrame*) override;
+ void collectGarbageAndReport() override;
+
private:
void delayedGCAndReport(Timer<WebLeakDetectorImpl>*);
void delayedReport(Timer<WebLeakDetectorImpl>*);
@@ -75,9 +81,12 @@ private:
Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer;
Timer<WebLeakDetectorImpl> m_delayedReportTimer;
int m_numberOfGCNeeded;
+#if ENABLE(ASSERT)
+ bool m_haveReported;
+#endif
};
-void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
+void WebLeakDetectorImpl::prepareForLeakDetection(WebLocalFrame* frame)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
@@ -99,6 +108,18 @@ void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
}
// FIXME: HTML5 Notification should be closed because notification affects the result of number of DOM objects.
+}
+
+void WebLeakDetectorImpl::collectGarbageAndReport()
+{
+#if ENABLE(ASSERT)
+ // Repeated uses are not supported.
+ ASSERT(!m_haveReported);
+ m_haveReported = true;
+#endif
+
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handleScope(isolate);
V8GCController::collectAllGarbageForTesting(isolate);
// Note: Oilpan precise GC is scheduled at the end of the event loop.
@@ -113,6 +134,12 @@ void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE);
}
+void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame)
+{
+ prepareForLeakDetection(frame);
+ collectGarbageAndReport();
+}
+
void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*)
{
// We do a second and third GC here to address flakiness

Powered by Google App Engine
This is Rietveld 408576698