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

Unified Diff: content/browser/histogram_message_filter.cc

Issue 11975048: Native memory histograms for the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/histogram_message_filter.cc
diff --git a/content/browser/histogram_message_filter.cc b/content/browser/histogram_message_filter.cc
index 040ca95ae56da57cced2f092c548444dd131d3fd..7a798bc754fb120bebf5079036d49cd33dd109b6 100644
--- a/content/browser/histogram_message_filter.cc
+++ b/content/browser/histogram_message_filter.cc
@@ -4,10 +4,14 @@
#include "content/browser/histogram_message_filter.h"
+#include "base/command_line.h"
+#include "base/metrics/histogram.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/process_util.h"
#include "content/browser/histogram_controller.h"
#include "content/browser/tcmalloc_internals_request_job.h"
#include "content/common/child_process_messages.h"
+#include "content/public/common/content_switches.h"
namespace content {
@@ -23,6 +27,8 @@ bool HistogramMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_BEGIN_MESSAGE_MAP_EX(HistogramMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildHistogramData,
OnChildHistogramData)
+ IPC_MESSAGE_HANDLER(ChildProcessHostMsg_GetBrowserHistogram,
+ OnGetBrowserHistogram)
jochen (gone - plz use gerrit) 2013/01/18 14:03:11 you need to make sure that this is on the IO threa
marja 2013/01/18 15:00:08 Added a dcheck in the handler func; it's run in th
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
@@ -36,4 +42,19 @@ void HistogramMessageFilter::OnChildHistogramData(
HistogramController::GetInstance()->OnHistogramDataCollected(
sequence_number, pickled_histograms);
}
+
+void HistogramMessageFilter::OnGetBrowserHistogram(
+ const std::string& name,
+ std::string* histogram_json) {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kMemoryMetrics))
+ return;
+ base::Histogram* histogram =
+ base::StatisticsRecorder::FindHistogram(name);
jochen (gone - plz use gerrit) 2013/01/18 14:03:11 maybe even add a whitelist?
marja 2013/01/18 15:00:08 Done.
+ if (!histogram) {
+ *histogram_json = "{}";
+ } else {
+ histogram->WriteJSON(histogram_json);
+ }
+}
+
}
jochen (gone - plz use gerrit) 2013/01/18 14:03:11 // namespace content
marja 2013/01/18 15:00:08 Done.

Powered by Google App Engine
This is Rietveld 408576698