diff options
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 |