summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-14 14:38:06 +0000
committerhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-14 14:38:06 +0000
commit05a79236ae01facd53bab9c2af0f72daa6e5f636 (patch)
tree34b532de135c75032b3f260611e46a5b9a6bf6c8 /content
parent986a5c89bb81fda1ab3eb5df2267514d014af723 (diff)
downloadchromium_src-05a79236ae01facd53bab9c2af0f72daa6e5f636.zip
chromium_src-05a79236ae01facd53bab9c2af0f72daa6e5f636.tar.gz
chromium_src-05a79236ae01facd53bab9c2af0f72daa6e5f636.tar.bz2
Modify the format output when a DOM-object leak is detected
Modifies the output to the following style: #LEAK renderer pid PID (DETAIL_IN_JSON_FORMAT) Now, this leaking output is not used anywhere, and this will be used by https://codereview.chromium.org/148153009/. See also: https://docs.google.com/a/chromium.org/document/d/1sFAsZxeISKnbGdXoLZlB2tDZ8pvO102ePFQx6TX4X14/edit BUG=332630 Review URL: https://codereview.chromium.org/142043010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/shell/browser/webkit_test_controller.cc8
-rw-r--r--content/shell/common/leak_detection_result.h5
-rw-r--r--content/shell/common/shell_messages.h3
-rw-r--r--content/shell/renderer/leak_detector.cc35
4 files changed, 33 insertions, 18 deletions
diff --git a/content/shell/browser/webkit_test_controller.cc b/content/shell/browser/webkit_test_controller.cc
index cd9e6ff..4d6153d 100644
--- a/content/shell/browser/webkit_test_controller.cc
+++ b/content/shell/browser/webkit_test_controller.cc
@@ -670,13 +670,9 @@ void WebKitTestController::OnLeakDetectionDone(
return;
}
- printer_->AddErrorMessage("#LEAK");
printer_->AddErrorMessage(
- base::StringPrintf(" Number of live documents: %d",
- result.number_of_live_documents));
- printer_->AddErrorMessage(
- base::StringPrintf(" Number of live nodes: %d",
- result.number_of_live_nodes));
+ base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_,
+ result.detail.c_str()));
DiscardMainWindow();
}
diff --git a/content/shell/common/leak_detection_result.h b/content/shell/common/leak_detection_result.h
index 7afcfd3..873a172 100644
--- a/content/shell/common/leak_detection_result.h
+++ b/content/shell/common/leak_detection_result.h
@@ -5,12 +5,13 @@
#ifndef CONTENT_SHELL_COMMON_LEAK_DETECTION_RESULT_H_
#define CONTENT_SHELL_COMMON_LEAK_DETECTION_RESULT_H_
+#include <string>
+
namespace content {
struct LeakDetectionResult {
bool leaked;
- unsigned number_of_live_documents;
- unsigned number_of_live_nodes;
+ std::string detail;
};
} // namespace content
diff --git a/content/shell/common/shell_messages.h b/content/shell/common/shell_messages.h
index 62fc8f9..ce563fe 100644
--- a/content/shell/common/shell_messages.h
+++ b/content/shell/common/shell_messages.h
@@ -105,8 +105,7 @@ IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseRemainingWindows)
IPC_STRUCT_TRAITS_BEGIN(content::LeakDetectionResult)
IPC_STRUCT_TRAITS_MEMBER(leaked)
-IPC_STRUCT_TRAITS_MEMBER(number_of_live_documents)
-IPC_STRUCT_TRAITS_MEMBER(number_of_live_nodes)
+IPC_STRUCT_TRAITS_MEMBER(detail)
IPC_STRUCT_TRAITS_END()
IPC_MESSAGE_ROUTED1(ShellViewHostMsg_LeakDetectionDone,
diff --git a/content/shell/renderer/leak_detector.cc b/content/shell/renderer/leak_detector.cc
index 2af12be..53ecdb2 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;
}