Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 std::string host_; | 156 std::string host_; |
| 157 double zoom_level_; | 157 double zoom_level_; |
| 158 | 158 |
| 159 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 159 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 } // namespace | 162 std::string HostToCustomPage(const std::string& host) { |
|
Charlie Reis
2012/08/22 23:09:59
HostToCustomHistogramSuffix?
marja
2012/08/23 14:15:00
Done.
| |
| 163 if (host == "mail.google.com") | |
| 164 return ".gmail"; | |
| 165 if (host == "docs.google.com" || host == "drive.google.com") | |
| 166 return ".docs"; | |
| 167 if (host == "plus.google.com") | |
| 168 return ".plus"; | |
| 169 return ""; | |
| 170 } | |
| 163 | 171 |
| 164 static void* CreateHistogram( | 172 void* CreateHistogram( |
| 165 const char *name, int min, int max, size_t buckets) { | 173 const char *name, int min, int max, size_t buckets) { |
| 166 if (min <= 0) | 174 if (min <= 0) |
| 167 min = 1; | 175 min = 1; |
| 168 base::Histogram* histogram = base::Histogram::FactoryGet( | 176 base::Histogram* histogram = base::Histogram::FactoryGet( |
| 169 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); | 177 RenderThreadImpl::current()->ConvertToCustomHistogramName(name), |
| 178 min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); | |
| 170 return histogram; | 179 return histogram; |
| 171 } | 180 } |
| 172 | 181 |
| 173 static void AddHistogramSample(void* hist, int sample) { | 182 void AddHistogramSample(void* hist, int sample) { |
| 174 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 183 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
| 175 histogram->Add(sample); | 184 histogram->Add(sample); |
| 176 } | 185 } |
| 177 | 186 |
| 187 } // namespace | |
| 188 | |
| 178 class RenderThreadImpl::GpuVDAContextLostCallback | 189 class RenderThreadImpl::GpuVDAContextLostCallback |
| 179 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 190 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| 180 public: | 191 public: |
| 181 GpuVDAContextLostCallback() {} | 192 GpuVDAContextLostCallback() {} |
| 182 virtual ~GpuVDAContextLostCallback() {} | 193 virtual ~GpuVDAContextLostCallback() {} |
| 183 virtual void onContextLost() { | 194 virtual void onContextLost() { |
| 184 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind( | 195 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind( |
| 185 &RenderThreadImpl::OnGpuVDAContextLoss)); | 196 &RenderThreadImpl::OnGpuVDAContextLoss)); |
| 186 } | 197 } |
| 187 }; | 198 }; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 | 288 |
| 278 context_lost_cb_.reset(new GpuVDAContextLostCallback()); | 289 context_lost_cb_.reset(new GpuVDAContextLostCallback()); |
| 279 | 290 |
| 280 // Note that under Linux, the media library will normally already have | 291 // Note that under Linux, the media library will normally already have |
| 281 // been initialized by the Zygote before this instance became a Renderer. | 292 // been initialized by the Zygote before this instance became a Renderer. |
| 282 FilePath media_path; | 293 FilePath media_path; |
| 283 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); | 294 PathService::Get(content::DIR_MEDIA_LIBS, &media_path); |
| 284 if (!media_path.empty()) | 295 if (!media_path.empty()) |
| 285 media::InitializeMediaLibrary(media_path); | 296 media::InitializeMediaLibrary(media_path); |
| 286 | 297 |
| 298 InitializeCustomHistograms(); | |
| 299 | |
| 287 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 300 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
| 288 } | 301 } |
| 289 | 302 |
| 290 RenderThreadImpl::~RenderThreadImpl() { | 303 RenderThreadImpl::~RenderThreadImpl() { |
| 291 FOR_EACH_OBSERVER( | 304 FOR_EACH_OBSERVER( |
| 292 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 305 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
| 293 | 306 |
| 294 // Wait for all databases to be closed. | 307 // Wait for all databases to be closed. |
| 295 if (web_database_observer_impl_.get()) | 308 if (web_database_observer_impl_.get()) |
| 296 web_database_observer_impl_->WaitForAllDatabasesToClose(); | 309 web_database_observer_impl_->WaitForAllDatabasesToClose(); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 805 RenderThreadImpl::GetAudioRendererMixerManager() { | 818 RenderThreadImpl::GetAudioRendererMixerManager() { |
| 806 if (!audio_renderer_mixer_manager_.get()) { | 819 if (!audio_renderer_mixer_manager_.get()) { |
| 807 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 820 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
| 808 audio_hardware::GetOutputSampleRate(), | 821 audio_hardware::GetOutputSampleRate(), |
| 809 audio_hardware::GetOutputBufferSize())); | 822 audio_hardware::GetOutputBufferSize())); |
| 810 } | 823 } |
| 811 | 824 |
| 812 return audio_renderer_mixer_manager_.get(); | 825 return audio_renderer_mixer_manager_.get(); |
| 813 } | 826 } |
| 814 | 827 |
| 828 void RenderThreadImpl::RenderViewNavigatedToHost(const std::string& host, | |
| 829 size_t view_count) { | |
| 830 // Check if all RenderViews are displaying a page from the same host. If there | |
| 831 // is only one RenderView, the common host is this view's host. If there are | |
| 832 // many, check if this one shares the common host of the other | |
| 833 // 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
| |
| 834 // common host. This information is only used for producing custom histograms. | |
| 835 if (view_count == 1) | |
| 836 SetCommonHost(host); | |
| 837 else if (host != common_host_) | |
| 838 SetCommonHost(std::string()); | |
| 839 } | |
| 840 | |
| 841 std::string RenderThreadImpl::ConvertToCustomHistogramName( | |
| 842 const char* histogram_name) { | |
| 843 std::string name(histogram_name); | |
| 844 if (!custom_page_.empty() && | |
| 845 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
| |
| 846 name += custom_page_; | |
| 847 return name; | |
| 848 } | |
| 849 | |
| 815 #if defined(OS_WIN) | 850 #if defined(OS_WIN) |
| 816 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 851 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
| 817 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 852 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
| 818 } | 853 } |
| 819 | 854 |
| 820 void RenderThreadImpl::ReleaseCachedFonts() { | 855 void RenderThreadImpl::ReleaseCachedFonts() { |
| 821 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 856 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
| 822 } | 857 } |
| 823 | 858 |
| 824 #endif // OS_WIN | 859 #endif // OS_WIN |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 | 1108 |
| 1074 scoped_refptr<base::MessageLoopProxy> | 1109 scoped_refptr<base::MessageLoopProxy> |
| 1075 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1110 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
| 1076 DCHECK(message_loop() == MessageLoop::current()); | 1111 DCHECK(message_loop() == MessageLoop::current()); |
| 1077 if (!file_thread_.get()) { | 1112 if (!file_thread_.get()) { |
| 1078 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1113 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 1079 file_thread_->Start(); | 1114 file_thread_->Start(); |
| 1080 } | 1115 } |
| 1081 return file_thread_->message_loop_proxy(); | 1116 return file_thread_->message_loop_proxy(); |
| 1082 } | 1117 } |
| 1118 | |
| 1119 void RenderThreadImpl::SetCommonHost(const std::string& host) { | |
| 1120 if (host != common_host_) { | |
| 1121 common_host_ = host; | |
| 1122 custom_page_ = HostToCustomPage(host); | |
| 1123 v8::V8::SetCreateHistogramFunction(CreateHistogram); | |
| 1124 } | |
| 1125 } | |
| 1126 | |
| 1127 void RenderThreadImpl::InitializeCustomHistograms() { | |
| 1128 custom_histograms_.insert("V8.GCCompactor"); | |
| 1129 custom_histograms_.insert("V8.GCScavenger"); | |
| 1130 custom_histograms_.insert("V8.GCContext"); | |
| 1131 custom_histograms_.insert("V8.Parse"); | |
| 1132 custom_histograms_.insert("V8.ParseLazy"); | |
| 1133 custom_histograms_.insert("V8.PreParse"); | |
| 1134 custom_histograms_.insert("V8.Compile"); | |
| 1135 custom_histograms_.insert("V8.CompileEval"); | |
| 1136 custom_histograms_.insert("V8.CompileLazy"); | |
| 1137 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); | |
| 1138 custom_histograms_.insert("V8.MemoryExternalFragmentationOldPointerSpace"); | |
| 1139 custom_histograms_.insert("V8.MemoryExternalFragmentationOldDataSpace"); | |
| 1140 custom_histograms_.insert("V8.MemoryExternalFragmentationCodeSpace"); | |
| 1141 custom_histograms_.insert("V8.MemoryExternalFragmentationMapSpace"); | |
| 1142 custom_histograms_.insert("V8.MemoryExternalFragmentationCellSpace"); | |
| 1143 custom_histograms_.insert("V8.MemoryExternalFragmentationLoSpace"); | |
| 1144 } | |
| OLD | NEW |