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

Unified Diff: content/shell/renderer/leak_detector.cc

Issue 142043010: Modify the format output when a DOM-object leak is detected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 months 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
« no previous file with comments | « content/shell/common/shell_messages.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/leak_detector.cc
diff --git a/content/shell/renderer/leak_detector.cc b/content/shell/renderer/leak_detector.cc
index 2af12beaff222f662db6030f6cc54ecef1164eae..53ecdb262f345226e9b29ad3b9624769cdea1a2f 100644
--- a/content/shell/renderer/leak_detector.cc
+++ b/content/shell/renderer/leak_detector.cc
@@ -4,7 +4,9 @@
#include "content/shell/renderer/leak_detector.h"
+#include "base/json/json_writer.h"
#include "base/logging.h"
+#include "base/values.h"
#include "third_party/WebKit/public/web/WebLeakDetector.h"
using blink::WebLeakDetector;
@@ -18,20 +20,37 @@ LeakDetector::LeakDetector()
LeakDetectionResult LeakDetector::TryLeakDetection(blink::WebFrame* frame) {
LeakDetectionResult result;
- result.number_of_live_documents = 0;
- result.number_of_live_nodes = 0;
+ unsigned number_of_live_documents = 0;
+ unsigned number_of_live_nodes = 0;
WebLeakDetector::collectGarbargeAndGetDOMCounts(
- frame, &result.number_of_live_documents, &result.number_of_live_nodes);
+ frame, &number_of_live_documents, &number_of_live_nodes);
result.leaked =
previous_number_of_live_documents_ > 0 &&
previous_number_of_live_nodes_ > 0 &&
- (previous_number_of_live_documents_ < result.number_of_live_documents ||
- previous_number_of_live_nodes_ < result.number_of_live_nodes);
-
- previous_number_of_live_documents_ = result.number_of_live_documents;
- previous_number_of_live_nodes_ = result.number_of_live_nodes;
+ (previous_number_of_live_documents_ < number_of_live_documents ||
+ previous_number_of_live_nodes_ < number_of_live_nodes);
+
+ if (result.leaked) {
+ base::DictionaryValue detail;
+ base::ListValue* list = new base::ListValue();
+ list->AppendInteger(previous_number_of_live_documents_);
+ list->AppendInteger(number_of_live_documents);
+ detail.Set("numberOfLiveDocuments", list);
+
+ list = new base::ListValue();
+ list->AppendInteger(previous_number_of_live_nodes_);
+ list->AppendInteger(number_of_live_nodes);
+ detail.Set("numberOfLiveNodes", list);
+
+ std::string detail_str;
+ base::JSONWriter::Write(&detail, &detail_str);
+ result.detail = detail_str;
+ }
+
+ previous_number_of_live_documents_ = number_of_live_documents;
+ previous_number_of_live_nodes_ = number_of_live_nodes;
return result;
}
« no previous file with comments | « content/shell/common/shell_messages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698