diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-02 00:46:41 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-02 00:46:41 +0000 |
commit | 1f4fc8e8c3423981f1046fa078046b8385b77925 (patch) | |
tree | bf593f339b2caada9179eeebba2727dce6ee80f7 /chrome | |
parent | d7a3e8ec24958958db28dba44542a2c126d94e88 (diff) | |
download | chromium_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
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/histogram_synchronizer.cc | 3 | ||||
-rw-r--r-- | chrome/common/histogram_synchronizer.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 11 | ||||
-rw-r--r-- | chrome/renderer/renderer_histogram_snapshots.cc | 1 |
4 files changed, 17 insertions, 0 deletions
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 |