summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authortkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 00:36:40 +0000
committertkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-12 00:37:47 +0000
commit57345d0059dc1ffc135d89d523054038447d2525 (patch)
treea5b61838055783deaea2f8bd55e289e803777e82 /content
parent80e4b813ce2452244ab9b173bcef1a86ed018312 (diff)
downloadchromium_src-57345d0059dc1ffc135d89d523054038447d2525.zip
chromium_src-57345d0059dc1ffc135d89d523054038447d2525.tar.gz
chromium_src-57345d0059dc1ffc135d89d523054038447d2525.tar.bz2
Leak detector: Add support for reporting AudioNode, RenderObject, and Resource object leak.
Also, LeakDetector::onLeakDetectionComplete produces a JSON including only leaked items. e.g. If Document objects are not leaked, resultant JSON doesn't have numberOfLiveDocuments item. This CL will make the leak detector bot red. We need to update third_party/WebKit/LayoutTests/LeakExpectations. BUG=400588 Review URL: https://codereview.chromium.org/457333002 Cr-Commit-Position: refs/heads/master@{#288849} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/shell/renderer/leak_detector.cc42
1 files changed, 35 insertions, 7 deletions
diff --git a/content/shell/renderer/leak_detector.cc b/content/shell/renderer/leak_detector.cc
index 01cbb08..1ee577c 100644
--- a/content/shell/renderer/leak_detector.cc
+++ b/content/shell/renderer/leak_detector.cc
@@ -21,14 +21,21 @@ namespace content {
// RefCoutned objects whose initial state is diffcult to estimate, we stop using
// hard-coded values. Instead, we need to load about:blank ahead of the layout
// tests actually and initialize LeakDetector by the got values.
+const int kInitialNumberOfLiveAudioNodes = 0;
const int kInitialNumberOfLiveDocuments = 1;
const int kInitialNumberOfLiveNodes = 4;
+const int kInitialNumberOfLiveRenderObjects = 3;
+const int kInitialNumberOfLiveResources = 1;
LeakDetector::LeakDetector(WebKitTestRunner* test_runner)
: test_runner_(test_runner),
web_leak_detector_(blink::WebLeakDetector::create(this)) {
+ previous_result_.numberOfLiveAudioNodes = kInitialNumberOfLiveAudioNodes;
previous_result_.numberOfLiveDocuments = kInitialNumberOfLiveDocuments;
previous_result_.numberOfLiveNodes = kInitialNumberOfLiveNodes;
+ previous_result_.numberOfLiveRenderObjects =
+ kInitialNumberOfLiveRenderObjects;
+ previous_result_.numberOfLiveResources = kInitialNumberOfLiveResources;
}
LeakDetector::~LeakDetector() {
@@ -41,25 +48,46 @@ void LeakDetector::TryLeakDetection(blink::WebLocalFrame* frame) {
void LeakDetector::onLeakDetectionComplete(
const WebLeakDetectorClient::Result& result) {
LeakDetectionResult report;
- report.leaked =
- (previous_result_.numberOfLiveDocuments < result.numberOfLiveDocuments ||
- previous_result_.numberOfLiveNodes < result.numberOfLiveNodes);
+ report.leaked = false;
+ base::DictionaryValue detail;
- if (report.leaked) {
- base::DictionaryValue detail;
+ if (previous_result_.numberOfLiveAudioNodes < result.numberOfLiveAudioNodes) {
+ base::ListValue* list = new base::ListValue();
+ list->AppendInteger(previous_result_.numberOfLiveAudioNodes);
+ list->AppendInteger(result.numberOfLiveAudioNodes);
+ detail.Set("numberOfLiveAudioNodes", list);
+ }
+ if (previous_result_.numberOfLiveDocuments < result.numberOfLiveDocuments) {
base::ListValue* list = new base::ListValue();
list->AppendInteger(previous_result_.numberOfLiveDocuments);
list->AppendInteger(result.numberOfLiveDocuments);
detail.Set("numberOfLiveDocuments", list);
-
- list = new base::ListValue();
+ }
+ if (previous_result_.numberOfLiveNodes < result.numberOfLiveNodes) {
+ base::ListValue* list = new base::ListValue();
list->AppendInteger(previous_result_.numberOfLiveNodes);
list->AppendInteger(result.numberOfLiveNodes);
detail.Set("numberOfLiveNodes", list);
+ }
+ if (previous_result_.numberOfLiveRenderObjects <
+ result.numberOfLiveRenderObjects) {
+ base::ListValue* list = new base::ListValue();
+ list->AppendInteger(previous_result_.numberOfLiveRenderObjects);
+ list->AppendInteger(result.numberOfLiveRenderObjects);
+ detail.Set("numberOfLiveRenderObjects", list);
+ }
+ if (previous_result_.numberOfLiveResources < result.numberOfLiveResources) {
+ base::ListValue* list = new base::ListValue();
+ list->AppendInteger(previous_result_.numberOfLiveResources);
+ list->AppendInteger(result.numberOfLiveResources);
+ detail.Set("numberOfLiveResources", list);
+ }
+ if (!detail.empty()) {
std::string detail_str;
base::JSONWriter::Write(&detail, &detail_str);
report.detail = detail_str;
+ report.leaked = true;
}
previous_result_ = result;