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

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

Issue 12389073: Collect tab timing information for use in telementry-based startup tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix telemetry tests with reference builds. Created 7 years, 6 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
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"
(...skipping 13 matching lines...) Expand all
24 automation_id_(MSG_ROUTING_NONE) { 24 automation_id_(MSG_ROUTING_NONE) {
25 BindCallback("send", base::Bind(&DomAutomationController::Send, 25 BindCallback("send", base::Bind(&DomAutomationController::Send,
26 base::Unretained(this))); 26 base::Unretained(this)));
27 BindCallback("setAutomationId", 27 BindCallback("setAutomationId",
28 base::Bind(&DomAutomationController::SetAutomationId, 28 base::Bind(&DomAutomationController::SetAutomationId,
29 base::Unretained(this))); 29 base::Unretained(this)));
30 BindCallback("sendJSON", base::Bind(&DomAutomationController::SendJSON, 30 BindCallback("sendJSON", base::Bind(&DomAutomationController::SendJSON,
31 base::Unretained(this))); 31 base::Unretained(this)));
32 BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId, 32 BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId,
33 base::Unretained(this))); 33 base::Unretained(this)));
34 BindCallback("getHistogram",
35 base::Bind(&DomAutomationController::GetHistogram,
36 base::Unretained(this)));
37 BindCallback("getBrowserHistogram",
38 base::Bind(&DomAutomationController::GetBrowserHistogram,
39 base::Unretained(this)));
40 } 34 }
41 35
42 void DomAutomationController::Send(const CppArgumentList& args, 36 void DomAutomationController::Send(const CppArgumentList& args,
43 CppVariant* result) { 37 CppVariant* result) {
44 if (args.size() != 1) { 38 if (args.size() != 1) {
45 result->SetNull(); 39 result->SetNull();
46 return; 40 return;
47 } 41 }
48 42
49 if (automation_id_ == MSG_ROUTING_NONE) { 43 if (automation_id_ == MSG_ROUTING_NONE) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // KJS::JSType only defines a NumberType (no Int32) 164 // KJS::JSType only defines a NumberType (no Int32)
171 if (!args[0].isNumber()) { 165 if (!args[0].isNumber()) {
172 result->SetNull(); 166 result->SetNull();
173 return; 167 return;
174 } 168 }
175 169
176 automation_id_ = args[0].ToInt32(); 170 automation_id_ = args[0].ToInt32();
177 result->Set(true); 171 result->Set(true);
178 } 172 }
179 173
180 void DomAutomationController::GetHistogram(const CppArgumentList& args,
181 CppVariant* result) {
182 if (args.size() != 1) {
183 result->SetNull();
184 return;
185 }
186 base::HistogramBase* histogram =
187 base::StatisticsRecorder::FindHistogram(args[0].ToString());
188 std::string output;
189 if (!histogram) {
190 output = "{}";
191 } else {
192 histogram->WriteJSON(&output);
193 }
194 result->Set(output);
195 }
196
197 void DomAutomationController::GetBrowserHistogram(const CppArgumentList& args,
198 CppVariant* result) {
199 if (args.size() != 1) {
200 result->SetNull();
201 return;
202 }
203
204 if (!sender_) {
205 NOTREACHED();
206 result->SetNull();
207 return;
208 }
209
210 std::string histogram_json;
211 sender_->Send(new ChildProcessHostMsg_GetBrowserHistogram(
212 args[0].ToString(), &histogram_json));
213 result->Set(histogram_json);
214 }
215
216 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698