summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/renderer/dom_automation_controller.cc22
-rw-r--r--content/renderer/dom_automation_controller.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/content/renderer/dom_automation_controller.cc b/content/renderer/dom_automation_controller.cc
index 4c2a717..0ab7035 100644
--- a/content/renderer/dom_automation_controller.cc
+++ b/content/renderer/dom_automation_controller.cc
@@ -7,6 +7,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/json/json_string_value_serializer.h"
+#include "base/metrics/histogram.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/string_util.h"
#include "content/common/view_messages.h"
@@ -26,6 +28,9 @@ DomAutomationController::DomAutomationController()
base::Unretained(this)));
BindCallback("sendWithId", base::Bind(&DomAutomationController::SendWithId,
base::Unretained(this)));
+ BindCallback("getHistogram",
+ base::Bind(&DomAutomationController::GetHistogram,
+ base::Unretained(this)));
}
void DomAutomationController::Send(const CppArgumentList& args,
@@ -166,3 +171,20 @@ void DomAutomationController::SetAutomationId(
automation_id_ = args[0].ToInt32();
result->Set(true);
}
+
+void DomAutomationController::GetHistogram(const CppArgumentList& args,
+ CppVariant* result) {
+ if (args.size() != 1) {
+ result->SetNull();
+ return;
+ }
+ base::Histogram* histogram =
+ base::StatisticsRecorder::FindHistogram(args[0].ToString());
+ std::string output;
+ if (!histogram) {
+ output = "{}";
+ } else {
+ histogram->WriteJSON(&output);
+ }
+ result->Set(output);
+}
diff --git a/content/renderer/dom_automation_controller.h b/content/renderer/dom_automation_controller.h
index 85bb60b..4550864 100644
--- a/content/renderer/dom_automation_controller.h
+++ b/content/renderer/dom_automation_controller.h
@@ -113,6 +113,10 @@ class DomAutomationController : public webkit_glue::CppBoundClass {
sender_ = sender;
}
+ // Retrieves a histogram and returns a JSON representation of it.
+ void GetHistogram(const webkit_glue::CppArgumentList& args,
+ webkit_glue::CppVariant* result);
+
private:
IPC::Sender* sender_;