| 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..11709edfea5ce8f9f7d3f7838f48184c3c0b5499 100644
|
| --- a/content/renderer/render_thread_impl.cc
|
| +++ b/content/renderer/render_thread_impl.cc
|
| @@ -159,22 +159,35 @@ class RenderViewZoomer : public content::RenderViewVisitor {
|
| DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
|
| };
|
|
|
| -} // namespace
|
| +std::string HostToCustomHistogramSuffix(const std::string& host) {
|
| + 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;
|
| + std::string histogram_name = RenderThreadImpl::current()->
|
| + histogram_customizer()->ConvertToCustomHistogramName(name);
|
| base::Histogram* histogram = base::Histogram::FactoryGet(
|
| - name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag);
|
| + histogram_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:
|
| @@ -186,6 +199,58 @@ class RenderThreadImpl::GpuVDAContextLostCallback
|
| }
|
| };
|
|
|
| +RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() {
|
| + 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");
|
| +}
|
| +
|
| +RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {}
|
| +
|
| +void RenderThreadImpl::HistogramCustomizer::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
|
| + // 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::HistogramCustomizer::ConvertToCustomHistogramName(
|
| + const char* histogram_name) const {
|
| + std::string name(histogram_name);
|
| + if (!common_host_histogram_suffix_.empty() &&
|
| + custom_histograms_.find(name) != custom_histograms_.end())
|
| + name += common_host_histogram_suffix_;
|
| + return name;
|
| +}
|
| +
|
| +void RenderThreadImpl::HistogramCustomizer::SetCommonHost(
|
| + const std::string& host) {
|
| + if (host != common_host_) {
|
| + common_host_ = host;
|
| + common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host);
|
| + v8::V8::SetCreateHistogramFunction(CreateHistogram);
|
| + }
|
| +}
|
| +
|
| RenderThreadImpl* RenderThreadImpl::current() {
|
| return lazy_tls.Pointer()->Get();
|
| }
|
|
|