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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/common/shell_messages.h ('k') | 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/leak_detector.h" 5 #include "content/shell/renderer/leak_detector.h"
6 6
7 #include "base/json/json_writer.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h"
8 #include "third_party/WebKit/public/web/WebLeakDetector.h" 10 #include "third_party/WebKit/public/web/WebLeakDetector.h"
9 11
10 using blink::WebLeakDetector; 12 using blink::WebLeakDetector;
11 13
12 namespace content { 14 namespace content {
13 15
14 LeakDetector::LeakDetector() 16 LeakDetector::LeakDetector()
15 : previous_number_of_live_documents_(0), 17 : previous_number_of_live_documents_(0),
16 previous_number_of_live_nodes_(0) { 18 previous_number_of_live_nodes_(0) {
17 } 19 }
18 20
19 LeakDetectionResult LeakDetector::TryLeakDetection(blink::WebFrame* frame) { 21 LeakDetectionResult LeakDetector::TryLeakDetection(blink::WebFrame* frame) {
20 LeakDetectionResult result; 22 LeakDetectionResult result;
21 result.number_of_live_documents = 0; 23 unsigned number_of_live_documents = 0;
22 result.number_of_live_nodes = 0; 24 unsigned number_of_live_nodes = 0;
23 25
24 WebLeakDetector::collectGarbargeAndGetDOMCounts( 26 WebLeakDetector::collectGarbargeAndGetDOMCounts(
25 frame, &result.number_of_live_documents, &result.number_of_live_nodes); 27 frame, &number_of_live_documents, &number_of_live_nodes);
26 28
27 result.leaked = 29 result.leaked =
28 previous_number_of_live_documents_ > 0 && 30 previous_number_of_live_documents_ > 0 &&
29 previous_number_of_live_nodes_ > 0 && 31 previous_number_of_live_nodes_ > 0 &&
30 (previous_number_of_live_documents_ < result.number_of_live_documents || 32 (previous_number_of_live_documents_ < number_of_live_documents ||
31 previous_number_of_live_nodes_ < result.number_of_live_nodes); 33 previous_number_of_live_nodes_ < number_of_live_nodes);
32 34
33 previous_number_of_live_documents_ = result.number_of_live_documents; 35 if (result.leaked) {
34 previous_number_of_live_nodes_ = result.number_of_live_nodes; 36 base::DictionaryValue detail;
37 base::ListValue* list = new base::ListValue();
38 list->AppendInteger(previous_number_of_live_documents_);
39 list->AppendInteger(number_of_live_documents);
40 detail.Set("numberOfLiveDocuments", list);
41
42 list = new base::ListValue();
43 list->AppendInteger(previous_number_of_live_nodes_);
44 list->AppendInteger(number_of_live_nodes);
45 detail.Set("numberOfLiveNodes", list);
46
47 std::string detail_str;
48 base::JSONWriter::Write(&detail, &detail_str);
49 result.detail = detail_str;
50 }
51
52 previous_number_of_live_documents_ = number_of_live_documents;
53 previous_number_of_live_nodes_ = number_of_live_nodes;
35 54
36 return result; 55 return result;
37 } 56 }
38 57
39 } // namespace content 58 } // namespace content
OLDNEW
« 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