Index: content/renderer/render_thread_impl.cc |
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
index db5696ef5821bc8bd93f23e49ce82fc5ce00b008..957bc42e2009d9e55d14f1aa99b1b871a793a8fc 100644 |
--- a/content/renderer/render_thread_impl.cc |
+++ b/content/renderer/render_thread_impl.cc |
@@ -159,22 +159,33 @@ class RenderViewZoomer : public content::RenderViewVisitor { |
DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
}; |
-} // namespace |
+std::string HostToCustomPage(const std::string& host) { |
Charlie Reis
2012/08/22 23:09:59
HostToCustomHistogramSuffix?
marja
2012/08/23 14:15:00
Done.
|
+ if (host == "mail.google.com") |
+ return ".gmail"; |
+ if (host == "docs.google.com" || host == "drive.google.com") |
+ return ".docs"; |
+ if (host == "plus.google.com") |
+ return ".plus"; |
+ return ""; |
+} |
-static void* CreateHistogram( |
+void* CreateHistogram( |
const char *name, int min, int max, size_t buckets) { |
if (min <= 0) |
min = 1; |
base::Histogram* histogram = base::Histogram::FactoryGet( |
- name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); |
+ RenderThreadImpl::current()->ConvertToCustomHistogramName(name), |
+ min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); |
return histogram; |
} |
-static void AddHistogramSample(void* hist, int sample) { |
+void AddHistogramSample(void* hist, int sample) { |
base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
histogram->Add(sample); |
} |
+} // namespace |
+ |
class RenderThreadImpl::GpuVDAContextLostCallback |
: public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
public: |
@@ -284,6 +295,8 @@ void RenderThreadImpl::Init() { |
if (!media_path.empty()) |
media::InitializeMediaLibrary(media_path); |
+ InitializeCustomHistograms(); |
+ |
TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
} |
@@ -812,6 +825,28 @@ RenderThreadImpl::GetAudioRendererMixerManager() { |
return audio_renderer_mixer_manager_.get(); |
} |
+void RenderThreadImpl::RenderViewNavigatedToHost(const std::string& host, |
+ size_t view_count) { |
+ // Check if all RenderViews are displaying a page from the same host. If there |
+ // is only one RenderView, the common host is this view's host. If there are |
+ // many, check if this one shares the common host of the other |
+ // RenderViews. It's ok to not detect some cases where the RenderViews share a |
Charlie Reis
2012/08/22 23:09:59
I'm glad you have this disclaimer. One case that
marja
2012/08/23 14:15:00
Ack. Yes, we don't need to catch all the possible
|
+ // common host. This information is only used for producing custom histograms. |
+ if (view_count == 1) |
+ SetCommonHost(host); |
+ else if (host != common_host_) |
+ SetCommonHost(std::string()); |
+} |
+ |
+std::string RenderThreadImpl::ConvertToCustomHistogramName( |
+ const char* histogram_name) { |
+ std::string name(histogram_name); |
+ if (!custom_page_.empty() && |
+ custom_histograms_.find(name) != custom_histograms_.end()) |
Charlie Reis
2012/08/22 23:09:59
nit: Condition doesn't fit on one line, so needs b
marja
2012/08/23 14:15:00
counter-nit: Doesn't it only needs braces if the *
Charlie Reis
2012/08/23 16:30:39
Ah, ambiguous style guides! :) Looks like there
|
+ name += custom_page_; |
+ return name; |
+} |
+ |
#if defined(OS_WIN) |
void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
@@ -1080,3 +1115,30 @@ RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
} |
return file_thread_->message_loop_proxy(); |
} |
+ |
+void RenderThreadImpl::SetCommonHost(const std::string& host) { |
+ if (host != common_host_) { |
+ common_host_ = host; |
+ custom_page_ = HostToCustomPage(host); |
+ v8::V8::SetCreateHistogramFunction(CreateHistogram); |
+ } |
+} |
+ |
+void RenderThreadImpl::InitializeCustomHistograms() { |
+ custom_histograms_.insert("V8.GCCompactor"); |
+ custom_histograms_.insert("V8.GCScavenger"); |
+ custom_histograms_.insert("V8.GCContext"); |
+ custom_histograms_.insert("V8.Parse"); |
+ custom_histograms_.insert("V8.ParseLazy"); |
+ custom_histograms_.insert("V8.PreParse"); |
+ custom_histograms_.insert("V8.Compile"); |
+ custom_histograms_.insert("V8.CompileEval"); |
+ custom_histograms_.insert("V8.CompileLazy"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationOldPointerSpace"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationOldDataSpace"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationCodeSpace"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationMapSpace"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationCellSpace"); |
+ custom_histograms_.insert("V8.MemoryExternalFragmentationLoSpace"); |
+} |