OLD | NEW |
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 <utility> |
| 8 |
7 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
9 #include "base/values.h" | 12 #include "base/values.h" |
10 #include "content/shell/renderer/layout_test/blink_test_runner.h" | 13 #include "content/shell/renderer/layout_test/blink_test_runner.h" |
11 #include "third_party/WebKit/public/web/WebLeakDetector.h" | 14 #include "third_party/WebKit/public/web/WebLeakDetector.h" |
12 | 15 |
13 using blink::WebLeakDetector; | 16 using blink::WebLeakDetector; |
14 | 17 |
15 namespace content { | 18 namespace content { |
16 | 19 |
17 // The initial states of the DOM objects at about:blank. The four nodes are a | 20 // The initial states of the DOM objects at about:blank. The four nodes are a |
18 // Document, a HTML, a HEAD and a BODY. | 21 // Document, a HTML, a HEAD and a BODY. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 72 } |
70 | 73 |
71 void LeakDetector::OnLeakDetectionComplete( | 74 void LeakDetector::OnLeakDetectionComplete( |
72 const WebLeakDetectorClient::Result& result) { | 75 const WebLeakDetectorClient::Result& result) { |
73 LeakDetectionResult report; | 76 LeakDetectionResult report; |
74 report.leaked = false; | 77 report.leaked = false; |
75 base::DictionaryValue detail; | 78 base::DictionaryValue detail; |
76 | 79 |
77 if (previous_result_.number_of_live_audio_nodes < | 80 if (previous_result_.number_of_live_audio_nodes < |
78 result.number_of_live_audio_nodes) { | 81 result.number_of_live_audio_nodes) { |
79 base::ListValue* list = new base::ListValue(); | 82 auto list = base::MakeUnique<base::ListValue>(); |
80 list->AppendInteger(previous_result_.number_of_live_audio_nodes); | 83 list->AppendInteger(previous_result_.number_of_live_audio_nodes); |
81 list->AppendInteger(result.number_of_live_audio_nodes); | 84 list->AppendInteger(result.number_of_live_audio_nodes); |
82 detail.Set("numberOfLiveAudioNodes", list); | 85 detail.Set("numberOfLiveAudioNodes", std::move(list)); |
83 } | 86 } |
84 if (previous_result_.number_of_live_documents < | 87 if (previous_result_.number_of_live_documents < |
85 result.number_of_live_documents) { | 88 result.number_of_live_documents) { |
86 base::ListValue* list = new base::ListValue(); | 89 auto list = base::MakeUnique<base::ListValue>(); |
87 list->AppendInteger(previous_result_.number_of_live_documents); | 90 list->AppendInteger(previous_result_.number_of_live_documents); |
88 list->AppendInteger(result.number_of_live_documents); | 91 list->AppendInteger(result.number_of_live_documents); |
89 detail.Set("numberOfLiveDocuments", list); | 92 detail.Set("numberOfLiveDocuments", std::move(list)); |
90 } | 93 } |
91 if (previous_result_.number_of_live_nodes < result.number_of_live_nodes) { | 94 if (previous_result_.number_of_live_nodes < result.number_of_live_nodes) { |
92 base::ListValue* list = new base::ListValue(); | 95 auto list = base::MakeUnique<base::ListValue>(); |
93 list->AppendInteger(previous_result_.number_of_live_nodes); | 96 list->AppendInteger(previous_result_.number_of_live_nodes); |
94 list->AppendInteger(result.number_of_live_nodes); | 97 list->AppendInteger(result.number_of_live_nodes); |
95 detail.Set("numberOfLiveNodes", list); | 98 detail.Set("numberOfLiveNodes", std::move(list)); |
96 } | 99 } |
97 if (previous_result_.number_of_live_layout_objects < | 100 if (previous_result_.number_of_live_layout_objects < |
98 result.number_of_live_layout_objects) { | 101 result.number_of_live_layout_objects) { |
99 base::ListValue* list = new base::ListValue(); | 102 auto list = base::MakeUnique<base::ListValue>(); |
100 list->AppendInteger(previous_result_.number_of_live_layout_objects); | 103 list->AppendInteger(previous_result_.number_of_live_layout_objects); |
101 list->AppendInteger(result.number_of_live_layout_objects); | 104 list->AppendInteger(result.number_of_live_layout_objects); |
102 detail.Set("numberOfLiveLayoutObjects", list); | 105 detail.Set("numberOfLiveLayoutObjects", std::move(list)); |
103 } | 106 } |
104 if (previous_result_.number_of_live_resources < | 107 if (previous_result_.number_of_live_resources < |
105 result.number_of_live_resources) { | 108 result.number_of_live_resources) { |
106 base::ListValue* list = new base::ListValue(); | 109 auto list = base::MakeUnique<base::ListValue>(); |
107 list->AppendInteger(previous_result_.number_of_live_resources); | 110 list->AppendInteger(previous_result_.number_of_live_resources); |
108 list->AppendInteger(result.number_of_live_resources); | 111 list->AppendInteger(result.number_of_live_resources); |
109 detail.Set("numberOfLiveResources", list); | 112 detail.Set("numberOfLiveResources", std::move(list)); |
110 } | 113 } |
111 if (previous_result_.number_of_live_suspendable_objects < | 114 if (previous_result_.number_of_live_suspendable_objects < |
112 result.number_of_live_suspendable_objects) { | 115 result.number_of_live_suspendable_objects) { |
113 base::ListValue* list = new base::ListValue(); | 116 auto list = base::MakeUnique<base::ListValue>(); |
114 list->AppendInteger(previous_result_.number_of_live_suspendable_objects); | 117 list->AppendInteger(previous_result_.number_of_live_suspendable_objects); |
115 list->AppendInteger(result.number_of_live_suspendable_objects); | 118 list->AppendInteger(result.number_of_live_suspendable_objects); |
116 detail.Set("numberOfLiveSuspendableObjects", list); | 119 detail.Set("numberOfLiveSuspendableObjects", std::move(list)); |
117 } | 120 } |
118 if (previous_result_.number_of_live_script_promises < | 121 if (previous_result_.number_of_live_script_promises < |
119 result.number_of_live_script_promises) { | 122 result.number_of_live_script_promises) { |
120 base::ListValue* list = new base::ListValue(); | 123 auto list = base::MakeUnique<base::ListValue>(); |
121 list->AppendInteger(previous_result_.number_of_live_script_promises); | 124 list->AppendInteger(previous_result_.number_of_live_script_promises); |
122 list->AppendInteger(result.number_of_live_script_promises); | 125 list->AppendInteger(result.number_of_live_script_promises); |
123 detail.Set("numberOfLiveScriptPromises", list); | 126 detail.Set("numberOfLiveScriptPromises", std::move(list)); |
124 } | 127 } |
125 if (previous_result_.number_of_live_frames < result.number_of_live_frames) { | 128 if (previous_result_.number_of_live_frames < result.number_of_live_frames) { |
126 base::ListValue* list = new base::ListValue(); | 129 auto list = base::MakeUnique<base::ListValue>(); |
127 list->AppendInteger(previous_result_.number_of_live_frames); | 130 list->AppendInteger(previous_result_.number_of_live_frames); |
128 list->AppendInteger(result.number_of_live_frames); | 131 list->AppendInteger(result.number_of_live_frames); |
129 detail.Set("numberOfLiveFrames", list); | 132 detail.Set("numberOfLiveFrames", std::move(list)); |
130 } | 133 } |
131 if (previous_result_.number_of_live_v8_per_context_data < | 134 if (previous_result_.number_of_live_v8_per_context_data < |
132 result.number_of_live_v8_per_context_data) { | 135 result.number_of_live_v8_per_context_data) { |
133 base::ListValue* list = new base::ListValue(); | 136 auto list = base::MakeUnique<base::ListValue>(); |
134 list->AppendInteger(previous_result_.number_of_live_v8_per_context_data); | 137 list->AppendInteger(previous_result_.number_of_live_v8_per_context_data); |
135 list->AppendInteger(result.number_of_live_v8_per_context_data); | 138 list->AppendInteger(result.number_of_live_v8_per_context_data); |
136 detail.Set("numberOfLiveV8PerContextData", list); | 139 detail.Set("numberOfLiveV8PerContextData", std::move(list)); |
137 } | 140 } |
138 if (previous_result_.number_of_worker_global_scopes < | 141 if (previous_result_.number_of_worker_global_scopes < |
139 result.number_of_worker_global_scopes) { | 142 result.number_of_worker_global_scopes) { |
140 base::ListValue* list = new base::ListValue(); | 143 auto list = base::MakeUnique<base::ListValue>(); |
141 list->AppendInteger(previous_result_.number_of_worker_global_scopes); | 144 list->AppendInteger(previous_result_.number_of_worker_global_scopes); |
142 list->AppendInteger(result.number_of_worker_global_scopes); | 145 list->AppendInteger(result.number_of_worker_global_scopes); |
143 detail.Set("numberOfWorkerGlobalScopes", list); | 146 detail.Set("numberOfWorkerGlobalScopes", std::move(list)); |
144 } | 147 } |
145 | 148 |
146 if (!detail.empty()) { | 149 if (!detail.empty()) { |
147 std::string detail_str; | 150 std::string detail_str; |
148 base::JSONWriter::Write(detail, &detail_str); | 151 base::JSONWriter::Write(detail, &detail_str); |
149 report.detail = detail_str; | 152 report.detail = detail_str; |
150 report.leaked = true; | 153 report.leaked = true; |
151 } | 154 } |
152 | 155 |
153 previous_result_ = result; | 156 previous_result_ = result; |
154 test_runner_->ReportLeakDetectionResult(report); | 157 test_runner_->ReportLeakDetectionResult(report); |
155 } | 158 } |
156 | 159 |
157 } // namespace content | 160 } // namespace content |
OLD | NEW |