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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 == "gmail.com") | |
| 162 return ".gmail"; | |
|
Charlie Reis
2012/08/16 16:22:56
I don't understand how you're defining host. What
marja
2012/08/21 15:21:15
Here we don't care about http vs. https. It would
| |
| 163 if (host == "docs.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 custom_host; |
| 171 void* CreateHistogram( | |
| 163 const char *name, int min, int max, size_t buckets) { | 172 const char *name, int min, int max, size_t buckets) { |
| 164 if (min <= 0) | 173 if (min <= 0) |
| 165 min = 1; | 174 min = 1; |
| 166 base::Histogram* histogram = base::Histogram::FactoryGet( | 175 base::Histogram* histogram = base::Histogram::FactoryGet( |
| 167 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag); | 176 std::string(name) + custom_host, min, max, buckets, |
| 177 base::Histogram::kUmaTargetedHistogramFlag); | |
| 168 return histogram; | 178 return histogram; |
| 169 } | 179 } |
| 170 | 180 |
| 171 static void AddHistogramSample(void* hist, int sample) { | 181 void AddHistogramSample(void* hist, int sample) { |
| 172 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 182 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
| 173 histogram->Add(sample); | 183 histogram->Add(sample); |
| 174 } | 184 } |
| 175 | 185 |
| 186 } // namespace | |
| 187 | |
| 176 RenderThreadImpl* RenderThreadImpl::current() { | 188 RenderThreadImpl* RenderThreadImpl::current() { |
| 177 return lazy_tls.Pointer()->Get(); | 189 return lazy_tls.Pointer()->Get(); |
| 178 } | 190 } |
| 179 | 191 |
| 180 // When we run plugins in process, we actually run them on the render thread, | 192 // 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. | 193 // which means that we need to make the render thread pump UI events. |
| 182 RenderThreadImpl::RenderThreadImpl() { | 194 RenderThreadImpl::RenderThreadImpl() { |
| 183 Init(); | 195 Init(); |
| 184 } | 196 } |
| 185 | 197 |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 RenderThreadImpl::GetAudioRendererMixerManager() { | 784 RenderThreadImpl::GetAudioRendererMixerManager() { |
| 773 if (!audio_renderer_mixer_manager_.get()) { | 785 if (!audio_renderer_mixer_manager_.get()) { |
| 774 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 786 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
| 775 audio_hardware::GetOutputSampleRate(), | 787 audio_hardware::GetOutputSampleRate(), |
| 776 audio_hardware::GetOutputBufferSize())); | 788 audio_hardware::GetOutputBufferSize())); |
| 777 } | 789 } |
| 778 | 790 |
| 779 return audio_renderer_mixer_manager_.get(); | 791 return audio_renderer_mixer_manager_.get(); |
| 780 } | 792 } |
| 781 | 793 |
| 794 // static | |
| 795 std::string RenderThreadImpl::CommonHost() { | |
| 796 return custom_host; | |
| 797 } | |
| 798 | |
| 799 // static | |
| 800 void RenderThreadImpl::SetCommonHost(const std::string& host) { | |
| 801 std::string new_custom_host = HostToCustomPage(host); | |
| 802 if (new_custom_host != custom_host) { | |
| 803 v8::V8::SetCreateHistogramFunction(CreateHistogram); | |
| 804 custom_host = new_custom_host; | |
| 805 } | |
| 806 } | |
| 807 | |
| 782 #if defined(OS_WIN) | 808 #if defined(OS_WIN) |
| 783 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 809 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
| 784 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 810 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
| 785 } | 811 } |
| 786 | 812 |
| 787 void RenderThreadImpl::ReleaseCachedFonts() { | 813 void RenderThreadImpl::ReleaseCachedFonts() { |
| 788 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 814 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
| 789 } | 815 } |
| 790 | 816 |
| 791 #endif // OS_WIN | 817 #endif // OS_WIN |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1040 | 1066 |
| 1041 scoped_refptr<base::MessageLoopProxy> | 1067 scoped_refptr<base::MessageLoopProxy> |
| 1042 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1068 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
| 1043 DCHECK(message_loop() == MessageLoop::current()); | 1069 DCHECK(message_loop() == MessageLoop::current()); |
| 1044 if (!file_thread_.get()) { | 1070 if (!file_thread_.get()) { |
| 1045 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1071 file_thread_.reset(new base::Thread("Renderer::FILE")); |
| 1046 file_thread_->Start(); | 1072 file_thread_->Start(); |
| 1047 } | 1073 } |
| 1048 return file_thread_->message_loop_proxy(); | 1074 return file_thread_->message_loop_proxy(); |
| 1049 } | 1075 } |
| OLD | NEW |