summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authormarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 10:36:13 +0000
committermarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 10:36:13 +0000
commitb9c43b153d100f0783dadd673282d1165d1a38b8 (patch)
treec4d6dcf64c6b0d4dbcfb501318b0eb5c424b4aaf /content
parentfbbba4ce2cb1345942797acae2635a5f89d23c3d (diff)
downloadchromium_src-b9c43b153d100f0783dadd673282d1165d1a38b8.zip
chromium_src-b9c43b153d100f0783dadd673282d1165d1a38b8.tar.gz
chromium_src-b9c43b153d100f0783dadd673282d1165d1a38b8.tar.bz2
Page cyclers: output memory histograms (approach: expose JS object)
This CL makes the chrome browser expose a JS object for retrieving histograms if a command line flag is passed. Page cycler then gets the histograms by executing JS via the test automation API. BUG=145352 Review URL: https://chromiumcodereview.appspot.com/10905073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159668 0039d316-1c4b-4281-b951-d872f2087c98
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_;