diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 00:51:10 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 00:51:10 +0000 |
commit | 4ea7e031cd7b6cc68f509c45bcbd3f7a52d53897 (patch) | |
tree | ae6ae1a66c0e28071a9a2206c682c3931514d78d | |
parent | 010ea08a647dfdc4c75aaab2fca65128f50f2379 (diff) | |
download | chromium_src-4ea7e031cd7b6cc68f509c45bcbd3f7a52d53897.zip chromium_src-4ea7e031cd7b6cc68f509c45bcbd3f7a52d53897.tar.gz chromium_src-4ea7e031cd7b6cc68f509c45bcbd3f7a52d53897.tar.bz2 |
Gather histogram data from render into browser before renderer shutdown
We're currently losing histogram data gathered in the renderer when
we shut down the renderer. We were only gathering it for UMA about every
20 minutes, and also getting an update when the user visits about:histograms.
This change causes the render to push a final update to the browser
when the renderer is about to terminate.
This is almost exactly CL 160153
http://codereview.chromium.org/160153/show
being landed for Raman Tenneti.
Per discussion with Darin, I ended up moving the renderer call to send the
histograms to the next function, which allows it to be called later (often
after the running of the on-unload handler, potentially gathering a bit
more data).
bug=16495
r=ramanTenneti
Review URL: http://codereview.chromium.org/258017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28692 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/histogram_synchronizer.cc | 2 | ||||
-rw-r--r-- | chrome/common/histogram_synchronizer.h | 9 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 6 |
3 files changed, 17 insertions, 0 deletions
diff --git a/chrome/common/histogram_synchronizer.cc b/chrome/common/histogram_synchronizer.cc index 54ff230..aaf23e8 100644 --- a/chrome/common/histogram_synchronizer.cc +++ b/chrome/common/histogram_synchronizer.cc @@ -241,6 +241,8 @@ int HistogramSynchronizer::GetNextAvaibleSequenceNumber( RendererHistogramRequester requester) { AutoLock auto_lock(lock_); ++next_available_sequence_number_; + if (next_available_sequence_number_ < STARTING_SEQUENCE_NUMBER) + next_available_sequence_number_ = STARTING_SEQUENCE_NUMBER; 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 ed866fc..29c34e2 100644 --- a/chrome/common/histogram_synchronizer.h +++ b/chrome/common/histogram_synchronizer.h @@ -32,6 +32,15 @@ class HistogramSynchronizer : public SYNCHRONOUS_HISTOGRAMS }; + // We reserve 0 through 9 sequence numbers for special purposes. For example, + // sequence number 0 is used by renderer to send its histograms before it + // closing renderer. We wanted to reserve the rest of sequence numbers for + // future purposes. + enum SequenceNumbers { + RENDERER_CLOSING_SEQUENCE_NUMBER = 0, + STARTING_SEQUENCE_NUMBER = 10 + }; + HistogramSynchronizer(); ~HistogramSynchronizer(); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 09fbe86..1ec124d 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/jstemplate_builder.h" #include "chrome/common/page_zoom.h" #include "chrome/common/plugin_messages.h" @@ -3161,6 +3162,11 @@ void RenderView::OnClosePage(const ViewMsg_ClosePage_Params& params) { } webview()->dispatchUnloadEvent(); + // Send histogram data before renderer closes. + if (RenderThread::current()) + RenderThread::current()->SendHistograms( + HistogramSynchronizer::RENDERER_CLOSING_SEQUENCE_NUMBER); + // Just echo back the params in the ACK. Send(new ViewHostMsg_ClosePage_ACK(routing_id_, params)); } |