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

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

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 #include <cpu-features.h> 130 #include <cpu-features.h>
131 #include "content/renderer/android/synchronous_compositor_factory.h" 131 #include "content/renderer/android/synchronous_compositor_factory.h"
132 #include "content/renderer/media/android/renderer_demuxer_android.h" 132 #include "content/renderer/media/android/renderer_demuxer_android.h"
133 #endif 133 #endif
134 134
135 #if defined(ENABLE_PLUGINS) 135 #if defined(ENABLE_PLUGINS)
136 #include "content/renderer/npapi/plugin_channel_host.h" 136 #include "content/renderer/npapi/plugin_channel_host.h"
137 #endif 137 #endif
138 138
139 using base::ThreadRestrictions; 139 using base::ThreadRestrictions;
140 using WebKit::WebDocument; 140 using blink::WebDocument;
141 using WebKit::WebFrame; 141 using blink::WebFrame;
142 using WebKit::WebNetworkStateNotifier; 142 using blink::WebNetworkStateNotifier;
143 using WebKit::WebRuntimeFeatures; 143 using blink::WebRuntimeFeatures;
144 using WebKit::WebScriptController; 144 using blink::WebScriptController;
145 using WebKit::WebSecurityPolicy; 145 using blink::WebSecurityPolicy;
146 using WebKit::WebString; 146 using blink::WebString;
147 using WebKit::WebView; 147 using blink::WebView;
148 148
149 namespace content { 149 namespace content {
150 150
151 namespace { 151 namespace {
152 152
153 const int64 kInitialIdleHandlerDelayMs = 1000; 153 const int64 kInitialIdleHandlerDelayMs = 1000;
154 const int64 kShortIdleHandlerDelayMs = 1000; 154 const int64 kShortIdleHandlerDelayMs = 1000;
155 const int64 kLongIdleHandlerDelayMs = 30*1000; 155 const int64 kLongIdleHandlerDelayMs = 30*1000;
156 const int kIdleCPUUsageThresholdInPercents = 3; 156 const int kIdleCPUUsageThresholdInPercents = 3;
157 157
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 scoped_ptr<base::SharedMemory> AllocateSharedMemoryFunction(size_t size) { 230 scoped_ptr<base::SharedMemory> AllocateSharedMemoryFunction(size_t size) {
231 return RenderThreadImpl::Get()->HostAllocateSharedMemoryBuffer(size); 231 return RenderThreadImpl::Get()->HostAllocateSharedMemoryBuffer(size);
232 } 232 }
233 233
234 void EnableWebCoreLogChannels(const std::string& channels) { 234 void EnableWebCoreLogChannels(const std::string& channels) {
235 if (channels.empty()) 235 if (channels.empty())
236 return; 236 return;
237 base::StringTokenizer t(channels, ", "); 237 base::StringTokenizer t(channels, ", ");
238 while (t.GetNext()) 238 while (t.GetNext())
239 WebKit::enableLogChannel(t.token().c_str()); 239 blink::enableLogChannel(t.token().c_str());
240 } 240 }
241 241
242 } // namespace 242 } // namespace
243 243
244 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { 244 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() {
245 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); 245 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal");
246 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); 246 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted");
247 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); 247 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed");
248 } 248 }
249 249
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( 305 base::debug::TraceLog::GetInstance()->SetThreadSortIndex(
306 base::PlatformThread::CurrentId(), 306 base::PlatformThread::CurrentId(),
307 kTraceEventRendererMainThreadSortIndex); 307 kTraceEventRendererMainThreadSortIndex);
308 308
309 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); 309 v8::V8::SetCounterFunction(base::StatsTable::FindLocation);
310 v8::V8::SetCreateHistogramFunction(CreateHistogram); 310 v8::V8::SetCreateHistogramFunction(CreateHistogram);
311 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); 311 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample);
312 312
313 #if defined(OS_MACOSX) || defined(OS_ANDROID) 313 #if defined(OS_MACOSX) || defined(OS_ANDROID)
314 // On Mac and Android, the select popups are rendered by the browser. 314 // On Mac and Android, the select popups are rendered by the browser.
315 WebKit::WebView::setUseExternalPopupMenus(true); 315 blink::WebView::setUseExternalPopupMenus(true);
316 #endif 316 #endif
317 317
318 lazy_tls.Pointer()->Set(this); 318 lazy_tls.Pointer()->Set(this);
319 319
320 #if defined(OS_WIN) 320 #if defined(OS_WIN)
321 // If you are running plugins in this thread you need COM active but in 321 // If you are running plugins in this thread you need COM active but in
322 // the normal case you don't. 322 // the normal case you don't.
323 if (RenderProcessImpl::InProcessPlugins()) 323 if (RenderProcessImpl::InProcessPlugins())
324 initialize_com_.reset(new base::win::ScopedCOMInitializer()); 324 initialize_com_.reset(new base::win::ScopedCOMInitializer());
325 #endif 325 #endif
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 445
446 compositor_thread_.reset(); 446 compositor_thread_.reset();
447 input_handler_manager_.reset(); 447 input_handler_manager_.reset();
448 if (input_event_filter_.get()) { 448 if (input_event_filter_.get()) {
449 RemoveFilter(input_event_filter_.get()); 449 RemoveFilter(input_event_filter_.get());
450 input_event_filter_ = NULL; 450 input_event_filter_ = NULL;
451 } 451 }
452 452
453 if (webkit_platform_support_) 453 if (webkit_platform_support_)
454 WebKit::shutdown(); 454 blink::shutdown();
455 455
456 lazy_tls.Pointer()->Set(NULL); 456 lazy_tls.Pointer()->Set(NULL);
457 457
458 // TODO(port) 458 // TODO(port)
459 #if defined(OS_WIN) 459 #if defined(OS_WIN)
460 // Clean up plugin channels before this thread goes away. 460 // Clean up plugin channels before this thread goes away.
461 NPChannelBase::CleanupChannels(); 461 NPChannelBase::CleanupChannels();
462 #endif 462 #endif
463 463
464 // Leak shared contexts on other threads, as we can not get to the correct 464 // Leak shared contexts on other threads, as we can not get to the correct
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 629 }
630 630
631 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 631 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
632 } 632 }
633 633
634 void RenderThreadImpl::EnsureWebKitInitialized() { 634 void RenderThreadImpl::EnsureWebKitInitialized() {
635 if (webkit_platform_support_) 635 if (webkit_platform_support_)
636 return; 636 return;
637 637
638 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); 638 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl);
639 WebKit::initialize(webkit_platform_support_.get()); 639 blink::initialize(webkit_platform_support_.get());
640 640
641 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 641 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
642 642
643 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); 643 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing);
644 if (enable) { 644 if (enable) {
645 #if defined(OS_ANDROID) 645 #if defined(OS_ANDROID)
646 if (SynchronousCompositorFactory* factory = 646 if (SynchronousCompositorFactory* factory =
647 SynchronousCompositorFactory::GetInstance()) 647 SynchronousCompositorFactory::GetInstance())
648 compositor_message_loop_proxy_ = 648 compositor_message_loop_proxy_ =
649 factory->GetCompositorMessageLoop(); 649 factory->GetCompositorMessageLoop();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 692
693 WebScriptController::enableV8SingleThreadMode(); 693 WebScriptController::enableV8SingleThreadMode();
694 694
695 RenderThreadImpl::RegisterSchemes(); 695 RenderThreadImpl::RegisterSchemes();
696 696
697 EnableWebCoreLogChannels( 697 EnableWebCoreLogChannels(
698 command_line.GetSwitchValueASCII(switches::kWebCoreLogChannels)); 698 command_line.GetSwitchValueASCII(switches::kWebCoreLogChannels));
699 699
700 web_database_observer_impl_.reset( 700 web_database_observer_impl_.reset(
701 new WebDatabaseObserverImpl(sync_message_filter())); 701 new WebDatabaseObserverImpl(sync_message_filter()));
702 WebKit::WebDatabase::setObserver(web_database_observer_impl_.get()); 702 blink::WebDatabase::setObserver(web_database_observer_impl_.get());
703 703
704 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); 704 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
705 705
706 if (!media::IsMediaLibraryInitialized()) { 706 if (!media::IsMediaLibraryInitialized()) {
707 WebRuntimeFeatures::enableMediaPlayer(false); 707 WebRuntimeFeatures::enableMediaPlayer(false);
708 WebRuntimeFeatures::enableWebAudio(false); 708 WebRuntimeFeatures::enableWebAudio(false);
709 } 709 }
710 710
711 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); 711 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized());
712 712
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 if (!gpu_va_context_provider_ || 875 if (!gpu_va_context_provider_ ||
876 gpu_va_context_provider_->DestroyedOnMainThread()) { 876 gpu_va_context_provider_->DestroyedOnMainThread()) {
877 if (!gpu_channel_host) { 877 if (!gpu_channel_host) {
878 gpu_channel_host = EstablishGpuChannelSync( 878 gpu_channel_host = EstablishGpuChannelSync(
879 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ E); 879 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZ E);
880 } 880 }
881 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create( 881 gpu_va_context_provider_ = ContextProviderCommandBuffer::Create(
882 make_scoped_ptr( 882 make_scoped_ptr(
883 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 883 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
884 gpu_channel_host.get(), 884 gpu_channel_host.get(),
885 WebKit::WebGraphicsContext3D::Attributes(), 885 blink::WebGraphicsContext3D::Attributes(),
886 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))), 886 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))),
887 "GPU-VideoAccelerator-Offscreen"); 887 "GPU-VideoAccelerator-Offscreen");
888 } 888 }
889 } 889 }
890 if (gpu_channel_host) { 890 if (gpu_channel_host) {
891 gpu_factories = new RendererGpuVideoAcceleratorFactories( 891 gpu_factories = new RendererGpuVideoAcceleratorFactories(
892 gpu_channel_host.get(), gpu_va_context_provider_); 892 gpu_channel_host.get(), gpu_va_context_provider_);
893 } 893 }
894 return gpu_factories; 894 return gpu_factories;
895 } 895 }
896 896
897 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 897 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
898 RenderThreadImpl::CreateOffscreenContext3d() { 898 RenderThreadImpl::CreateOffscreenContext3d() {
899 WebKit::WebGraphicsContext3D::Attributes attributes; 899 blink::WebGraphicsContext3D::Attributes attributes;
900 attributes.shareResources = true; 900 attributes.shareResources = true;
901 attributes.depth = false; 901 attributes.depth = false;
902 attributes.stencil = false; 902 attributes.stencil = false;
903 attributes.antialias = false; 903 attributes.antialias = false;
904 attributes.noAutomaticFlushes = true; 904 attributes.noAutomaticFlushes = true;
905 905
906 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( 906 scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
907 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); 907 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
908 return make_scoped_ptr( 908 return make_scoped_ptr(
909 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( 909 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 // Cache some variables that are needed on the compositor thread for our 1201 // Cache some variables that are needed on the compositor thread for our
1202 // implementation of GpuChannelHostFactory. 1202 // implementation of GpuChannelHostFactory.
1203 io_message_loop_proxy_ = ChildProcess::current()->io_message_loop_proxy(); 1203 io_message_loop_proxy_ = ChildProcess::current()->io_message_loop_proxy();
1204 shutdown_event_ = ChildProcess::current()->GetShutDownEvent(); 1204 shutdown_event_ = ChildProcess::current()->GetShutDownEvent();
1205 1205
1206 gpu_channel_ = GpuChannelHost::Create( 1206 gpu_channel_ = GpuChannelHost::Create(
1207 this, 0, client_id, gpu_info, channel_handle); 1207 this, 0, client_id, gpu_info, channel_handle);
1208 return gpu_channel_.get(); 1208 return gpu_channel_.get();
1209 } 1209 }
1210 1210
1211 WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( 1211 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter(
1212 WebKit::WebMediaStreamCenterClient* client) { 1212 blink::WebMediaStreamCenterClient* client) {
1213 #if defined(OS_ANDROID) 1213 #if defined(OS_ANDROID)
1214 if (CommandLine::ForCurrentProcess()->HasSwitch( 1214 if (CommandLine::ForCurrentProcess()->HasSwitch(
1215 switches::kDisableWebRTC)) 1215 switches::kDisableWebRTC))
1216 return NULL; 1216 return NULL;
1217 #endif 1217 #endif
1218 1218
1219 #if defined(ENABLE_WEBRTC) 1219 #if defined(ENABLE_WEBRTC)
1220 if (!media_stream_center_) { 1220 if (!media_stream_center_) {
1221 media_stream_center_ = GetContentClient()->renderer() 1221 media_stream_center_ = GetContentClient()->renderer()
1222 ->OverrideCreateWebMediaStreamCenter(client); 1222 ->OverrideCreateWebMediaStreamCenter(client);
(...skipping 29 matching lines...) Expand all
1252 return gpu_channel_.get(); 1252 return gpu_channel_.get();
1253 } 1253 }
1254 1254
1255 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { 1255 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) {
1256 EnsureWebKitInitialized(); 1256 EnsureWebKitInitialized();
1257 // The call below will cause a GetPlugins call with refresh=true, but at this 1257 // The call below will cause a GetPlugins call with refresh=true, but at this
1258 // point we already know that the browser has refreshed its list, so disable 1258 // point we already know that the browser has refreshed its list, so disable
1259 // refresh temporarily to prevent each renderer process causing the list to be 1259 // refresh temporarily to prevent each renderer process causing the list to be
1260 // regenerated. 1260 // regenerated.
1261 webkit_platform_support_->set_plugin_refresh_allowed(false); 1261 webkit_platform_support_->set_plugin_refresh_allowed(false);
1262 WebKit::resetPluginCache(reload_pages); 1262 blink::resetPluginCache(reload_pages);
1263 webkit_platform_support_->set_plugin_refresh_allowed(true); 1263 webkit_platform_support_->set_plugin_refresh_allowed(true);
1264 1264
1265 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, PluginListChanged()); 1265 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, PluginListChanged());
1266 } 1266 }
1267 1267
1268 void RenderThreadImpl::OnNetworkStateChanged(bool online) { 1268 void RenderThreadImpl::OnNetworkStateChanged(bool online) {
1269 EnsureWebKitInitialized(); 1269 EnsureWebKitInitialized();
1270 WebNetworkStateNotifier::setOnLine(online); 1270 WebNetworkStateNotifier::setOnLine(online);
1271 } 1271 }
1272 1272
(...skipping 12 matching lines...) Expand all
1285 1285
1286 void RenderThreadImpl::OnMemoryPressure( 1286 void RenderThreadImpl::OnMemoryPressure(
1287 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { 1287 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
1288 base::allocator::ReleaseFreeMemory(); 1288 base::allocator::ReleaseFreeMemory();
1289 1289
1290 if (memory_pressure_level == 1290 if (memory_pressure_level ==
1291 base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL) { 1291 base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL) {
1292 // Trigger full v8 garbage collection on critical memory notification. 1292 // Trigger full v8 garbage collection on critical memory notification.
1293 v8::V8::LowMemoryNotification(); 1293 v8::V8::LowMemoryNotification();
1294 // Clear the image cache. 1294 // Clear the image cache.
1295 WebKit::WebImageCache::clear(); 1295 blink::WebImageCache::clear();
1296 // Purge Skia font cache, by setting it to 0 and then again to the previous 1296 // Purge Skia font cache, by setting it to 0 and then again to the previous
1297 // limit. 1297 // limit.
1298 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0); 1298 size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0);
1299 SkGraphics::SetFontCacheLimit(font_cache_limit); 1299 SkGraphics::SetFontCacheLimit(font_cache_limit);
1300 } else { 1300 } else {
1301 // Otherwise trigger a couple of v8 GCs using IdleNotification. 1301 // Otherwise trigger a couple of v8 GCs using IdleNotification.
1302 if (!v8::V8::IdleNotification()) 1302 if (!v8::V8::IdleNotification())
1303 v8::V8::IdleNotification(); 1303 v8::V8::IdleNotification();
1304 } 1304 }
1305 } 1305 }
(...skipping 24 matching lines...) Expand all
1330 } 1330 }
1331 1331
1332 void RenderThreadImpl::SetFlingCurveParameters( 1332 void RenderThreadImpl::SetFlingCurveParameters(
1333 const std::vector<float>& new_touchpad, 1333 const std::vector<float>& new_touchpad,
1334 const std::vector<float>& new_touchscreen) { 1334 const std::vector<float>& new_touchscreen) {
1335 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, 1335 webkit_platform_support_->SetFlingCurveParameters(new_touchpad,
1336 new_touchscreen); 1336 new_touchscreen);
1337 1337
1338 } 1338 }
1339 1339
1340 void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) { 1340 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) {
1341 if (!gamepad_shared_memory_reader_) 1341 if (!gamepad_shared_memory_reader_)
1342 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); 1342 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader);
1343 gamepad_shared_memory_reader_->SampleGamepads(*data); 1343 gamepad_shared_memory_reader_->SampleGamepads(*data);
1344 } 1344 }
1345 1345
1346 base::ProcessId RenderThreadImpl::renderer_process_id() const { 1346 base::ProcessId RenderThreadImpl::renderer_process_id() const {
1347 return renderer_process_id_; 1347 return renderer_process_id_;
1348 } 1348 }
1349 1349
1350 } // namespace content 1350 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698