summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-02 00:46:41 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-02 00:46:41 +0000
commit1f4fc8e8c3423981f1046fa078046b8385b77925 (patch)
treebf593f339b2caada9179eeebba2727dce6ee80f7
parentd7a3e8ec24958958db28dba44542a2c126d94e88 (diff)
downloadchromium_src-1f4fc8e8c3423981f1046fa078046b8385b77925.zip
chromium_src-1f4fc8e8c3423981f1046fa078046b8385b77925.tar.gz
chromium_src-1f4fc8e8c3423981f1046fa078046b8385b77925.tar.bz2
Upload renderer histograms to browser after a page loads
WARNING: We need to watch the perf charts when this lands to be sure that it doesn't cause a regression. Since there is no finalizer for a renderer, and some renderers are just terminated with no warning, the only way to get consistent page data is to send it to the browser after each page loads. That is the bulk of this change. I also fixed up a few nits relating to making this work in single process mode. BUG=16495 r=raman.tenneti Review URL: http://codereview.chromium.org/515072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35431 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/histogram.cc18
-rw-r--r--base/histogram.h4
-rw-r--r--chrome/common/histogram_synchronizer.cc3
-rw-r--r--chrome/common/histogram_synchronizer.h2
-rw-r--r--chrome/renderer/render_view.cc11
-rw-r--r--chrome/renderer/renderer_histogram_snapshots.cc1
6 files changed, 19 insertions, 20 deletions
diff --git a/base/histogram.cc b/base/histogram.cc
index 03478d7..c7a64af 100644
--- a/base/histogram.cc
+++ b/base/histogram.cc
@@ -392,7 +392,7 @@ std::string Histogram::SerializeHistogramInfo(const Histogram& histogram,
pickle.WriteInt(histogram.declared_max());
pickle.WriteSize(histogram.bucket_count());
pickle.WriteInt(histogram.histogram_type());
- pickle.WriteInt(histogram.flags() & ~kIPCSerializationSourceFlag);
+ pickle.WriteInt(histogram.flags());
snapshot.Serialize(&pickle);
return std::string(static_cast<const char*>(pickle.data()), pickle.size());
@@ -425,6 +425,7 @@ bool Histogram::DeserializeHistogramInfo(const std::string& histogram_info) {
LOG(ERROR) << "Pickle error decoding Histogram: " << histogram_name;
return false;
}
+ DCHECK(pickle_flags & kIPCSerializationSourceFlag);
// Since these fields may have come from an untrusted renderer, do additional
// checks above and beyond those in Histogram::Initialize()
if (declared_max <= 0 || declared_min <= 0 || declared_max < declared_min ||
@@ -798,21 +799,6 @@ void StatisticsRecorder::GetHistograms(Histograms* output) {
}
}
-// static
-void StatisticsRecorder::GetHistogramsForRenderer(Histograms* output) {
- if (!histograms_)
- return;
- AutoLock auto_lock(*lock_);
- for (HistogramMap::iterator it = histograms_->begin();
- histograms_->end() != it;
- ++it) {
- scoped_refptr<Histogram> histogram = it->second;
- if (!(histogram->flags() & Histogram::kIPCSerializationSourceFlag))
- histogram->SetFlags(Histogram::kIPCSerializationSourceFlag);
- output->push_back(histogram);
- }
-}
-
bool StatisticsRecorder::FindHistogram(const std::string& name,
scoped_refptr<Histogram>* histogram) {
if (!histograms_)
diff --git a/base/histogram.h b/base/histogram.h
index 6e415a0..f16dde0 100644
--- a/base/histogram.h
+++ b/base/histogram.h
@@ -554,10 +554,6 @@ class StatisticsRecorder {
// Method for extracting histograms which were marked for use by UMA.
static void GetHistograms(Histograms* output);
- // Method for extracting histograms for renderer and the histogram's flag is
- // set to kIPCSerializationSourceFlag.
- static void GetHistogramsForRenderer(Histograms* output);
-
// Find a histogram by name. It matches the exact name. This method is thread
// safe.
static bool FindHistogram(const std::string& query,
diff --git a/chrome/common/histogram_synchronizer.cc b/chrome/common/histogram_synchronizer.cc
index 2a7e09a..9aeff5e 100644
--- a/chrome/common/histogram_synchronizer.cc
+++ b/chrome/common/histogram_synchronizer.cc
@@ -240,6 +240,9 @@ int HistogramSynchronizer::GetNextAvaibleSequenceNumber(
RendererHistogramRequester requester) {
AutoLock auto_lock(lock_);
++next_available_sequence_number_;
+ if (0 > next_available_sequence_number_) // We wrapped around.
+ next_available_sequence_number_ = kReservedSequenceNumber + 1;
+ DCHECK(next_available_sequence_number_ != kReservedSequenceNumber);
if (requester == ASYNC_HISTOGRAMS) {
async_sequence_number_ = next_available_sequence_number_;
async_renderers_pending_ = 0;
diff --git a/chrome/common/histogram_synchronizer.h b/chrome/common/histogram_synchronizer.h
index 35e965e..1190555 100644
--- a/chrome/common/histogram_synchronizer.h
+++ b/chrome/common/histogram_synchronizer.h
@@ -26,6 +26,8 @@ class HistogramSynchronizer : public
SYNCHRONOUS_HISTOGRAMS
};
+ static const int kReservedSequenceNumber = 0;
+
HistogramSynchronizer();
~HistogramSynchronizer();
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 5c52523..418bf4c 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -26,6 +26,7 @@
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/histogram_synchronizer.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/page_zoom.h"
@@ -3755,6 +3756,16 @@ void RenderView::DumpLoadHistograms() const {
}
navigation_state->set_load_histograms_recorded(true);
+
+ // Since there are currently no guarantees that renderer histograms will be
+ // sent to the browser, we initiate a PostTask here to be sure that we send
+ // the histograms we generated. Without this call, pages that don't have an
+ // on-close-handler might generate data that is lost when the renderer is
+ // shutdown abruptly (perchance because the user closed the tab).
+ if (RenderThread::current()) {
+ RenderThread::current()->SendHistograms(
+ HistogramSynchronizer::kReservedSequenceNumber);
+ }
}
void RenderView::LogNavigationState(const NavigationState* state,
diff --git a/chrome/renderer/renderer_histogram_snapshots.cc b/chrome/renderer/renderer_histogram_snapshots.cc
index 025eb73..5b8165a 100644
--- a/chrome/renderer/renderer_histogram_snapshots.cc
+++ b/chrome/renderer/renderer_histogram_snapshots.cc
@@ -37,6 +37,7 @@ void RendererHistogramSnapshots::UploadAllHistrograms(int sequence_number) {
for (StatisticsRecorder::Histograms::iterator it = histograms.begin();
histograms.end() != it;
it++) {
+ (*it)->SetFlags(Histogram::kIPCSerializationSourceFlag);
UploadHistrogram(**it, &pickled_histograms);
}
// Send the sequence number and list of pickled histograms over synchronous