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

Unified Diff: content/common/child_histogram_message_filter.cc

Issue 10454086: Histograms - Support histograms for Plugins, GPU (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « content/common/child_histogram_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/child_histogram_message_filter.cc
===================================================================
--- content/common/child_histogram_message_filter.cc (revision 0)
+++ content/common/child_histogram_message_filter.cc (working copy)
@@ -0,0 +1,98 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/child_histogram_message_filter.h"
+
+#include <ctype.h>
+
+#include "base/bind.h"
+#include "base/message_loop.h"
+#include "content/common/child_process.h"
+#include "content/common/child_process_messages.h"
+#include "content/common/child_thread.h"
+
+namespace content {
+
+ChildHistogramMessageFilter::ChildHistogramMessageFilter()
+ : channel_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(histogram_snapshot_manager_(this)) {
+}
+
+ChildHistogramMessageFilter::~ChildHistogramMessageFilter() {
+}
+
+void ChildHistogramMessageFilter::OnFilterAdded(IPC::Channel* channel) {
+ channel_ = channel;
+}
+
+void ChildHistogramMessageFilter::OnFilterRemoved() {
+}
+
+bool ChildHistogramMessageFilter::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ChildHistogramMessageFilter, message)
+ IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildHistogramData,
+ OnGetChildHistogramData)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void ChildHistogramMessageFilter::SendHistograms(int sequence_number) {
+ ChildProcess::current()->io_message_loop_proxy()->PostTask(
+ FROM_HERE, base::Bind(&ChildHistogramMessageFilter::UploadAllHistrograms,
+ this, sequence_number));
+}
+
+void ChildHistogramMessageFilter::OnGetChildHistogramData(int sequence_number) {
+ UploadAllHistrograms(sequence_number);
+}
+
+void ChildHistogramMessageFilter::UploadAllHistrograms(int sequence_number) {
+ DCHECK_EQ(0u, pickled_histograms_.size());
+
+ base::StatisticsRecorder::CollectHistogramStats("ChildProcess");
+
+ // Push snapshots into our pickled_histograms_ vector.
+ histogram_snapshot_manager_.PrepareDeltas(
+ base::Histogram::kIPCSerializationSourceFlag, false);
+
+ channel_->Send(new ChildProcessHostMsg_ChildHistogramData(
+ sequence_number, pickled_histograms_));
+
+ pickled_histograms_.clear();
+ static int count = 0;
+ count++;
+ DHISTOGRAM_COUNTS("Histogram.ChildProcessHistogramSentCount", count);
+}
+
+void ChildHistogramMessageFilter::RecordDelta(
+ const base::Histogram& histogram,
+ const base::Histogram::SampleSet& snapshot) {
+ DCHECK_NE(0, snapshot.TotalCount());
+ snapshot.CheckSize(histogram);
+
+ std::string histogram_info =
+ base::Histogram::SerializeHistogramInfo(histogram, snapshot);
+
+ pickled_histograms_.push_back(histogram_info);
+}
+
+void ChildHistogramMessageFilter::InconsistencyDetected(int problem) {
+ UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess",
+ problem, base::Histogram::NEVER_EXCEEDED_VALUE);
+}
+
+void ChildHistogramMessageFilter::UniqueInconsistencyDetected(int problem) {
+ UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique",
+ problem, base::Histogram::NEVER_EXCEEDED_VALUE);
+}
+
+void ChildHistogramMessageFilter::SnapshotProblemResolved(int amount) {
+ UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotChildProcess",
+ std::abs(amount));
+}
+
+} // namespace content
« no previous file with comments | « content/common/child_histogram_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698