Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 10828342: Per-host V8 histograms. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return true; 150 return true;
151 } 151 }
152 152
153 private: 153 private:
154 std::string host_; 154 std::string host_;
155 double zoom_level_; 155 double zoom_level_;
156 156
157 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); 157 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
158 }; 158 };
159 159
160 } // namespace 160 std::string HostToCustomPage(const std::string& host) {
161 if (host == "mail.google.com")
162 return ".gmail";
163 if (host == "docs.google.com" || host == "drive.google.com")
164 return ".docs";
165 if (host == "plus.google.com")
166 return ".plus";
167 return "";
168 }
161 169
162 static void* CreateHistogram( 170 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
171 std::string custom_page;
172 base::LazyInstance<std::set<std::string> > custom_histograms =
173 LAZY_INSTANCE_INITIALIZER;
174
175 void InitializeCustomHistograms() {
176 std::set<std::string>* histograms = custom_histograms.Pointer();
177 if (!histograms->empty())
178 return;
179 histograms->insert("V8.GCCompactor");
180 histograms->insert("V8.GCScavenger");
181 histograms->insert("V8.GCContext");
182 histograms->insert("V8.Parse");
183 histograms->insert("V8.ParseLazy");
184 histograms->insert("V8.PreParse");
185 histograms->insert("V8.Compile");
186 histograms->insert("V8.CompileEval");
187 histograms->insert("V8.CompileLazy");
188 histograms->insert("V8.MemoryExternalFragmentationTotal");
189 histograms->insert("V8.MemoryExternalFragmentationOldPointerSpace");
190 histograms->insert("V8.MemoryExternalFragmentationOldDataSpace");
191 histograms->insert("V8.MemoryExternalFragmentationCodeSpace");
192 histograms->insert("V8.MemoryExternalFragmentationMapSpace");
193 histograms->insert("V8.MemoryExternalFragmentationCellSpace");
194 histograms->insert("V8.MemoryExternalFragmentationLoSpace");
195 }
196
197 void* CreateHistogram(
163 const char *name, int min, int max, size_t buckets) { 198 const char *name, int min, int max, size_t buckets) {
164 if (min <= 0) 199 if (min <= 0)
165 min = 1; 200 min = 1;
201 InitializeCustomHistograms();
202 std::string histogram_name(name);
203 if (custom_histograms.Get().find(histogram_name) !=
204 custom_histograms.Get().end())
205 histogram_name += custom_page;
166 base::Histogram* histogram = base::Histogram::FactoryGet( 206 base::Histogram* histogram = base::Histogram::FactoryGet(
167 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); 207 histogram_name, min, max, buckets,
208 base::Histogram::kUmaTargetedHistogramFlag);
168 return histogram; 209 return histogram;
169 } 210 }
170 211
171 static void AddHistogramSample(void* hist, int sample) { 212 void AddHistogramSample(void* hist, int sample) {
172 base::Histogram* histogram = static_cast<base::Histogram*>(hist); 213 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
173 histogram->Add(sample); 214 histogram->Add(sample);
174 } 215 }
175 216
217 } // namespace
218
176 RenderThreadImpl* RenderThreadImpl::current() { 219 RenderThreadImpl* RenderThreadImpl::current() {
177 return lazy_tls.Pointer()->Get(); 220 return lazy_tls.Pointer()->Get();
178 } 221 }
179 222
180 // When we run plugins in process, we actually run them on the render thread, 223 // When we run plugins in process, we actually run them on the render thread,
181 // which means that we need to make the render thread pump UI events. 224 // which means that we need to make the render thread pump UI events.
182 RenderThreadImpl::RenderThreadImpl() { 225 RenderThreadImpl::RenderThreadImpl() {
183 Init(); 226 Init();
184 } 227 }
185 228
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 RenderThreadImpl::GetAudioRendererMixerManager() { 815 RenderThreadImpl::GetAudioRendererMixerManager() {
773 if (!audio_renderer_mixer_manager_.get()) { 816 if (!audio_renderer_mixer_manager_.get()) {
774 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( 817 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager(
775 audio_hardware::GetOutputSampleRate(), 818 audio_hardware::GetOutputSampleRate(),
776 audio_hardware::GetOutputBufferSize())); 819 audio_hardware::GetOutputBufferSize()));
777 } 820 }
778 821
779 return audio_renderer_mixer_manager_.get(); 822 return audio_renderer_mixer_manager_.get();
780 } 823 }
781 824
825 // static
826 std::string RenderThreadImpl::CommonHost() {
827 return common_host;
828 }
829
830 // static
831 void RenderThreadImpl::SetCommonHost(const std::string& host) {
832 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.
833 common_host = host;
834 custom_page = HostToCustomPage(host);
835 v8::V8::SetCreateHistogramFunction(CreateHistogram);
836 }
837 }
838
782 #if defined(OS_WIN) 839 #if defined(OS_WIN)
783 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { 840 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) {
784 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); 841 Send(new ChildProcessHostMsg_PreCacheFont(log_font));
785 } 842 }
786 843
787 void RenderThreadImpl::ReleaseCachedFonts() { 844 void RenderThreadImpl::ReleaseCachedFonts() {
788 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); 845 Send(new ChildProcessHostMsg_ReleaseCachedFonts());
789 } 846 }
790 847
791 #endif // OS_WIN 848 #endif // OS_WIN
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1097
1041 scoped_refptr<base::MessageLoopProxy> 1098 scoped_refptr<base::MessageLoopProxy>
1042 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 1099 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1043 DCHECK(message_loop() == MessageLoop::current()); 1100 DCHECK(message_loop() == MessageLoop::current());
1044 if (!file_thread_.get()) { 1101 if (!file_thread_.get()) {
1045 file_thread_.reset(new base::Thread("Renderer::FILE")); 1102 file_thread_.reset(new base::Thread("Renderer::FILE"));
1046 file_thread_->Start(); 1103 file_thread_->Start();
1047 } 1104 }
1048 return file_thread_->message_loop_proxy(); 1105 return file_thread_->message_loop_proxy();
1049 } 1106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698