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

Side by Side Diff: content/renderer/dom_automation_controller.cc

Issue 11975048: Native memory histograms for the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios build fix Created 7 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/renderer/dom_automation_controller.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/dom_automation_controller.h" 5 #include "content/renderer/dom_automation_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "content/common/child_process_messages.h"
13 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
14 15
15 using webkit_glue::CppArgumentList; 16 using webkit_glue::CppArgumentList;
16 using webkit_glue::CppVariant; 17 using webkit_glue::CppVariant;
17 18
18 namespace content { 19 namespace content {
19 20
20 DomAutomationController::DomAutomationController() 21 DomAutomationController::DomAutomationController()
21 : sender_(NULL), 22 : sender_(NULL),
22 routing_id_(MSG_ROUTING_NONE), 23 routing_id_(MSG_ROUTING_NONE),
23 automation_id_(MSG_ROUTING_NONE) { 24 automation_id_(MSG_ROUTING_NONE) {
24 BindCallback("send", base::Bind(&DomAutomationController::Send, 25 BindCallback("send", base::Bind(&DomAutomationController::Send,
25 base::Unretained(this))); 26 base::Unretained(this)));
26 BindCallback("setAutomationId", 27 BindCallback("setAutomationId",
27 base::Bind(&DomAutomationController::SetAutomationId, 28 base::Bind(&DomAutomationController::SetAutomationId,
28 base::Unretained(this))); 29 base::Unretained(this)));
29 BindCallback("sendJSON", base::Bind(&DomAutomationController::SendJSON, 30 BindCallback("sendJSON", base::Bind(&DomAutomationController::SendJSON,
30 base::Unretained(this))); 31 base::Unretained(this)));
31 BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId, 32 BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId,
32 base::Unretained(this))); 33 base::Unretained(this)));
33 BindCallback("getHistogram", 34 BindCallback("getHistogram",
34 base::Bind(&DomAutomationController::GetHistogram, 35 base::Bind(&DomAutomationController::GetHistogram,
35 base::Unretained(this))); 36 base::Unretained(this)));
37 BindCallback("getBrowserHistogram",
38 base::Bind(&DomAutomationController::GetBrowserHistogram,
39 base::Unretained(this)));
36 } 40 }
37 41
38 void DomAutomationController::Send(const CppArgumentList& args, 42 void DomAutomationController::Send(const CppArgumentList& args,
39 CppVariant* result) { 43 CppVariant* result) {
40 if (args.size() != 1) { 44 if (args.size() != 1) {
41 result->SetNull(); 45 result->SetNull();
42 return; 46 return;
43 } 47 }
44 48
45 if (automation_id_ == MSG_ROUTING_NONE) { 49 if (automation_id_ == MSG_ROUTING_NONE) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 base::StatisticsRecorder::FindHistogram(args[0].ToString()); 188 base::StatisticsRecorder::FindHistogram(args[0].ToString());
185 std::string output; 189 std::string output;
186 if (!histogram) { 190 if (!histogram) {
187 output = "{}"; 191 output = "{}";
188 } else { 192 } else {
189 histogram->WriteJSON(&output); 193 histogram->WriteJSON(&output);
190 } 194 }
191 result->Set(output); 195 result->Set(output);
192 } 196 }
193 197
198 void DomAutomationController::GetBrowserHistogram(const CppArgumentList& args,
199 CppVariant* result) {
200 if (args.size() != 1) {
201 result->SetNull();
202 return;
203 }
204
205 if (!sender_) {
206 NOTREACHED();
207 result->SetNull();
208 return;
209 }
210
211 std::string histogram_json;
212 sender_->Send(new ChildProcessHostMsg_GetBrowserHistogram(
213 args[0].ToString(), &histogram_json));
214 result->Set(histogram_json);
215 }
216
194 } // namespace content 217 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_automation_controller.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698