Chromium Code Reviews| Index: content/renderer/render_thread_impl.cc |
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
| index 93ce9fb58dc8125e3ca5c091fab3de9adb2db186..07def6467ef25028df90c8ed8c102418a246849a 100644 |
| --- a/content/renderer/render_thread_impl.cc |
| +++ b/content/renderer/render_thread_impl.cc |
| @@ -157,22 +157,65 @@ class RenderViewZoomer : public content::RenderViewVisitor { |
| DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
| }; |
| -} // namespace |
| +std::string HostToCustomPage(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( |
| +std::string common_host; |
|
Charlie Reis
2012/08/21 22:46:49
These are globals and should start with g_, right?
marja
2012/08/22 14:59:31
They're inside an unnamed namespace, so only visib
|
| +std::string custom_page; |
| +base::LazyInstance<std::set<std::string> > custom_histograms = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +void InitializeCustomHistograms() { |
| + std::set<std::string>* histograms = custom_histograms.Pointer(); |
| + if (!histograms->empty()) |
| + return; |
| + histograms->insert("V8.GCCompactor"); |
| + histograms->insert("V8.GCScavenger"); |
| + histograms->insert("V8.GCContext"); |
| + histograms->insert("V8.Parse"); |
| + histograms->insert("V8.ParseLazy"); |
| + histograms->insert("V8.PreParse"); |
| + histograms->insert("V8.Compile"); |
| + histograms->insert("V8.CompileEval"); |
| + histograms->insert("V8.CompileLazy"); |
| + histograms->insert("V8.MemoryExternalFragmentationTotal"); |
| + histograms->insert("V8.MemoryExternalFragmentationOldPointerSpace"); |
| + histograms->insert("V8.MemoryExternalFragmentationOldDataSpace"); |
| + histograms->insert("V8.MemoryExternalFragmentationCodeSpace"); |
| + histograms->insert("V8.MemoryExternalFragmentationMapSpace"); |
| + histograms->insert("V8.MemoryExternalFragmentationCellSpace"); |
| + histograms->insert("V8.MemoryExternalFragmentationLoSpace"); |
| +} |
| + |
| +void* CreateHistogram( |
| const char *name, int min, int max, size_t buckets) { |
| if (min <= 0) |
| min = 1; |
| + InitializeCustomHistograms(); |
| + std::string histogram_name(name); |
| + if (custom_histograms.Get().find(histogram_name) != |
| + custom_histograms.Get().end()) |
| + histogram_name += custom_page; |
| 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 |
| + |
| RenderThreadImpl* RenderThreadImpl::current() { |
| return lazy_tls.Pointer()->Get(); |
| } |
| @@ -779,6 +822,20 @@ RenderThreadImpl::GetAudioRendererMixerManager() { |
| return audio_renderer_mixer_manager_.get(); |
| } |
| +// static |
| +std::string RenderThreadImpl::CommonHost() { |
| + return common_host; |
| +} |
| + |
| +// static |
| +void RenderThreadImpl::SetCommonHost(const std::string& host) { |
| + if (host != common_host) { |
|
Charlie Reis
2012/08/21 22:46:49
Can we move some of the logic into here rather tha
marja
2012/08/22 14:59:31
Done: Moved the logic to RenderThreadImpl. RenderV
Charlie Reis
2012/08/22 23:09:59
Yes, much better, thanks.
|
| + common_host = host; |
| + custom_page = HostToCustomPage(host); |
| + v8::V8::SetCreateHistogramFunction(CreateHistogram); |
| + } |
| +} |
| + |
| #if defined(OS_WIN) |
| void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
| Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |