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

Side by Side Diff: content/shell/renderer/layout_test/leak_detector.cc

Issue 1227293002: Add support for V8PerContextData to the leak detector (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: haraken's review Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/layout_test/leak_detector.h" 5 #include "content/shell/renderer/layout_test/leak_detector.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/shell/renderer/layout_test/blink_test_runner.h" 10 #include "content/shell/renderer/layout_test/blink_test_runner.h"
(...skipping 10 matching lines...) Expand all
21 // objects like RefCounted whose initial state is diffcult to estimate, we stop 21 // objects like RefCounted whose initial state is diffcult to estimate, we stop
22 // using hard-coded values. Instead, we need to load about:blank ahead of the 22 // using hard-coded values. Instead, we need to load about:blank ahead of the
23 // layout tests actually and initialize LeakDetector by the got values. 23 // layout tests actually and initialize LeakDetector by the got values.
24 const int kInitialNumberOfLiveAudioNodes = 0; 24 const int kInitialNumberOfLiveAudioNodes = 0;
25 const int kInitialNumberOfLiveDocuments = 1; 25 const int kInitialNumberOfLiveDocuments = 1;
26 const int kInitialNumberOfLiveNodes = 4; 26 const int kInitialNumberOfLiveNodes = 4;
27 const int kInitialNumberOfLiveRenderObjects = 3; 27 const int kInitialNumberOfLiveRenderObjects = 3;
28 const int kInitialNumberOfLiveResources = 0; 28 const int kInitialNumberOfLiveResources = 0;
29 const int kInitialNumberOfScriptPromises = 0; 29 const int kInitialNumberOfScriptPromises = 0;
30 const int kInitialNumberOfLiveFrames = 1; 30 const int kInitialNumberOfLiveFrames = 1;
31 const int kInitialNumberOfV8PerContextData = 1;
31 32
32 // In the initial state, there are two ActiveDOMObjects (FontFaceSet created by 33 // In the initial state, there are two ActiveDOMObjects (FontFaceSet created by
33 // HTMLDocument and SuspendableTimer created by DocumentLoader). 34 // HTMLDocument and SuspendableTimer created by DocumentLoader).
34 const int kInitialNumberOfLiveActiveDOMObject = 2; 35 const int kInitialNumberOfLiveActiveDOMObject = 2;
35 36
36 LeakDetector::LeakDetector(BlinkTestRunner* test_runner) 37 LeakDetector::LeakDetector(BlinkTestRunner* test_runner)
37 : test_runner_(test_runner), 38 : test_runner_(test_runner),
38 web_leak_detector_(blink::WebLeakDetector::create(this)) { 39 web_leak_detector_(blink::WebLeakDetector::create(this)) {
39 previous_result_.numberOfLiveAudioNodes = kInitialNumberOfLiveAudioNodes; 40 previous_result_.numberOfLiveAudioNodes = kInitialNumberOfLiveAudioNodes;
40 previous_result_.numberOfLiveDocuments = kInitialNumberOfLiveDocuments; 41 previous_result_.numberOfLiveDocuments = kInitialNumberOfLiveDocuments;
41 previous_result_.numberOfLiveNodes = kInitialNumberOfLiveNodes; 42 previous_result_.numberOfLiveNodes = kInitialNumberOfLiveNodes;
42 previous_result_.numberOfLiveRenderObjects = 43 previous_result_.numberOfLiveRenderObjects =
43 kInitialNumberOfLiveRenderObjects; 44 kInitialNumberOfLiveRenderObjects;
44 previous_result_.numberOfLiveResources = kInitialNumberOfLiveResources; 45 previous_result_.numberOfLiveResources = kInitialNumberOfLiveResources;
45 previous_result_.numberOfLiveActiveDOMObjects = 46 previous_result_.numberOfLiveActiveDOMObjects =
46 kInitialNumberOfLiveActiveDOMObject; 47 kInitialNumberOfLiveActiveDOMObject;
47 previous_result_.numberOfLiveScriptPromises = kInitialNumberOfScriptPromises; 48 previous_result_.numberOfLiveScriptPromises = kInitialNumberOfScriptPromises;
48 previous_result_.numberOfLiveFrames = kInitialNumberOfLiveFrames; 49 previous_result_.numberOfLiveFrames = kInitialNumberOfLiveFrames;
50 previous_result_.numberOfLiveV8PerContextData =
51 kInitialNumberOfV8PerContextData;
49 } 52 }
50 53
51 LeakDetector::~LeakDetector() { 54 LeakDetector::~LeakDetector() {
52 } 55 }
53 56
54 void LeakDetector::TryLeakDetection(blink::WebLocalFrame* frame) { 57 void LeakDetector::TryLeakDetection(blink::WebLocalFrame* frame) {
55 web_leak_detector_->collectGarbageAndGetDOMCounts(frame); 58 web_leak_detector_->collectGarbageAndGetDOMCounts(frame);
56 } 59 }
57 60
58 void LeakDetector::onLeakDetectionComplete( 61 void LeakDetector::onLeakDetectionComplete(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 list->AppendInteger(previous_result_.numberOfLiveScriptPromises); 108 list->AppendInteger(previous_result_.numberOfLiveScriptPromises);
106 list->AppendInteger(result.numberOfLiveScriptPromises); 109 list->AppendInteger(result.numberOfLiveScriptPromises);
107 detail.Set("numberOfLiveScriptPromises", list); 110 detail.Set("numberOfLiveScriptPromises", list);
108 } 111 }
109 if (previous_result_.numberOfLiveFrames < result.numberOfLiveFrames) { 112 if (previous_result_.numberOfLiveFrames < result.numberOfLiveFrames) {
110 base::ListValue* list = new base::ListValue(); 113 base::ListValue* list = new base::ListValue();
111 list->AppendInteger(previous_result_.numberOfLiveFrames); 114 list->AppendInteger(previous_result_.numberOfLiveFrames);
112 list->AppendInteger(result.numberOfLiveFrames); 115 list->AppendInteger(result.numberOfLiveFrames);
113 detail.Set("numberOfLiveFrames", list); 116 detail.Set("numberOfLiveFrames", list);
114 } 117 }
118 if (previous_result_.numberOfLiveV8PerContextData <
119 result.numberOfLiveV8PerContextData) {
120 base::ListValue* list = new base::ListValue();
121 list->AppendInteger(previous_result_.numberOfLiveV8PerContextData);
122 list->AppendInteger(result.numberOfLiveV8PerContextData);
123 detail.Set("numberOfLiveV8PerContextData", list);
124 }
115 125
116 if (!detail.empty()) { 126 if (!detail.empty()) {
117 std::string detail_str; 127 std::string detail_str;
118 base::JSONWriter::Write(detail, &detail_str); 128 base::JSONWriter::Write(detail, &detail_str);
119 report.detail = detail_str; 129 report.detail = detail_str;
120 report.leaked = true; 130 report.leaked = true;
121 } 131 }
122 132
123 previous_result_ = result; 133 previous_result_ = result;
124 test_runner_->ReportLeakDetectionResult(report); 134 test_runner_->ReportLeakDetectionResult(report);
125 } 135 }
126 136
127 } // namespace content 137 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698