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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 media::InitializeMediaLibrary(media_path); | 403 media::InitializeMediaLibrary(media_path); |
404 | 404 |
405 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 405 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
406 } | 406 } |
407 | 407 |
408 RenderThreadImpl::~RenderThreadImpl() { | 408 RenderThreadImpl::~RenderThreadImpl() { |
409 FOR_EACH_OBSERVER( | 409 FOR_EACH_OBSERVER( |
410 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 410 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
411 | 411 |
412 // Wait for all databases to be closed. | 412 // Wait for all databases to be closed. |
413 if (web_database_observer_impl_.get()) | 413 if (web_database_observer_impl_) |
414 web_database_observer_impl_->WaitForAllDatabasesToClose(); | 414 web_database_observer_impl_->WaitForAllDatabasesToClose(); |
415 | 415 |
416 // Shutdown in reverse of the initialization order. | 416 // Shutdown in reverse of the initialization order. |
417 if (devtools_agent_message_filter_.get()) { | 417 if (devtools_agent_message_filter_) { |
418 RemoveFilter(devtools_agent_message_filter_.get()); | 418 RemoveFilter(devtools_agent_message_filter_.get()); |
419 devtools_agent_message_filter_ = NULL; | 419 devtools_agent_message_filter_ = NULL; |
420 } | 420 } |
421 | 421 |
422 RemoveFilter(audio_input_message_filter_.get()); | 422 RemoveFilter(audio_input_message_filter_.get()); |
423 audio_input_message_filter_ = NULL; | 423 audio_input_message_filter_ = NULL; |
424 | 424 |
425 RemoveFilter(audio_message_filter_.get()); | 425 RemoveFilter(audio_message_filter_.get()); |
426 audio_message_filter_ = NULL; | 426 audio_message_filter_ = NULL; |
427 | 427 |
428 RemoveFilter(vc_manager_->video_capture_message_filter()); | 428 RemoveFilter(vc_manager_->video_capture_message_filter()); |
429 | 429 |
430 RemoveFilter(db_message_filter_.get()); | 430 RemoveFilter(db_message_filter_.get()); |
431 db_message_filter_ = NULL; | 431 db_message_filter_ = NULL; |
432 | 432 |
433 // Shutdown the file thread if it's running. | 433 // Shutdown the file thread if it's running. |
434 if (file_thread_.get()) | 434 if (file_thread_) |
435 file_thread_->Stop(); | 435 file_thread_->Stop(); |
436 | 436 |
437 if (compositor_output_surface_filter_.get()) { | 437 if (compositor_output_surface_filter_) { |
438 RemoveFilter(compositor_output_surface_filter_.get()); | 438 RemoveFilter(compositor_output_surface_filter_.get()); |
439 compositor_output_surface_filter_ = NULL; | 439 compositor_output_surface_filter_ = NULL; |
440 } | 440 } |
441 | 441 |
442 compositor_thread_.reset(); | 442 compositor_thread_.reset(); |
443 if (input_handler_manager_.get()) { | 443 if (input_handler_manager_) { |
444 RemoveFilter(input_handler_manager_->GetMessageFilter()); | 444 RemoveFilter(input_handler_manager_->GetMessageFilter()); |
445 input_handler_manager_.reset(); | 445 input_handler_manager_.reset(); |
446 } | 446 } |
447 | 447 |
448 if (webkit_platform_support_.get()) | 448 if (webkit_platform_support_) |
449 WebKit::shutdown(); | 449 WebKit::shutdown(); |
450 | 450 |
451 lazy_tls.Pointer()->Set(NULL); | 451 lazy_tls.Pointer()->Set(NULL); |
452 | 452 |
453 // TODO(port) | 453 // TODO(port) |
454 #if defined(OS_WIN) | 454 #if defined(OS_WIN) |
455 // Clean up plugin channels before this thread goes away. | 455 // Clean up plugin channels before this thread goes away. |
456 NPChannelBase::CleanupChannels(); | 456 NPChannelBase::CleanupChannels(); |
457 #endif | 457 #endif |
458 | 458 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 DCHECK_GT(hidden_widget_count_, 0); | 614 DCHECK_GT(hidden_widget_count_, 0); |
615 hidden_widget_count_--; | 615 hidden_widget_count_--; |
616 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 616 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
617 return; | 617 return; |
618 } | 618 } |
619 | 619 |
620 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 620 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
621 } | 621 } |
622 | 622 |
623 void RenderThreadImpl::EnsureWebKitInitialized() { | 623 void RenderThreadImpl::EnsureWebKitInitialized() { |
624 if (webkit_platform_support_.get()) | 624 if (webkit_platform_support_) |
625 return; | 625 return; |
626 | 626 |
627 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); | 627 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); |
628 WebKit::initialize(webkit_platform_support_.get()); | 628 WebKit::initialize(webkit_platform_support_.get()); |
629 WebKit::setSharedWorkerRepository( | 629 WebKit::setSharedWorkerRepository( |
630 webkit_platform_support_.get()->sharedWorkerRepository()); | 630 webkit_platform_support_.get()->sharedWorkerRepository()); |
631 WebKit::setIDBFactory( | 631 WebKit::setIDBFactory( |
632 webkit_platform_support_.get()->idbFactory()); | 632 webkit_platform_support_.get()->idbFactory()); |
633 | 633 |
634 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 634 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 } | 917 } |
918 | 918 |
919 void RenderThreadImpl::PostponeIdleNotification() { | 919 void RenderThreadImpl::PostponeIdleNotification() { |
920 idle_notifications_to_skip_ = 2; | 920 idle_notifications_to_skip_ = 2; |
921 } | 921 } |
922 | 922 |
923 /* static */ | 923 /* static */ |
924 void RenderThreadImpl::OnGpuVDAContextLoss() { | 924 void RenderThreadImpl::OnGpuVDAContextLoss() { |
925 RenderThreadImpl* self = RenderThreadImpl::current(); | 925 RenderThreadImpl* self = RenderThreadImpl::current(); |
926 DCHECK(self); | 926 DCHECK(self); |
927 if (!self->gpu_vda_context3d_.get()) | 927 if (!self->gpu_vda_context3d_) |
928 return; | 928 return; |
929 if (self->compositor_message_loop_proxy()) { | 929 if (self->compositor_message_loop_proxy()) { |
930 self->compositor_message_loop_proxy()->DeleteSoon( | 930 self->compositor_message_loop_proxy()->DeleteSoon( |
931 FROM_HERE, self->gpu_vda_context3d_.release()); | 931 FROM_HERE, self->gpu_vda_context3d_.release()); |
932 } else { | 932 } else { |
933 self->gpu_vda_context3d_.reset(); | 933 self->gpu_vda_context3d_.reset(); |
934 } | 934 } |
935 } | 935 } |
936 | 936 |
937 WebGraphicsContext3DCommandBufferImpl* | 937 WebGraphicsContext3DCommandBufferImpl* |
938 RenderThreadImpl::GetGpuVDAContext3D() { | 938 RenderThreadImpl::GetGpuVDAContext3D() { |
939 if (!gpu_vda_context3d_.get()) { | 939 if (!gpu_vda_context3d_) { |
940 gpu_vda_context3d_.reset( | 940 gpu_vda_context3d_.reset( |
941 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 941 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
942 this, WebKit::WebGraphicsContext3D::Attributes(), | 942 this, WebKit::WebGraphicsContext3D::Attributes(), |
943 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); | 943 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D"))); |
944 if (gpu_vda_context3d_.get()) | 944 if (gpu_vda_context3d_) |
945 gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get()); | 945 gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get()); |
946 } | 946 } |
947 return gpu_vda_context3d_.get(); | 947 return gpu_vda_context3d_.get(); |
948 } | 948 } |
949 | 949 |
950 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 950 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
951 RenderThreadImpl::CreateOffscreenContext3d() { | 951 RenderThreadImpl::CreateOffscreenContext3d() { |
952 WebKit::WebGraphicsContext3D::Attributes attributes; | 952 WebKit::WebGraphicsContext3D::Attributes attributes; |
953 attributes.shareResources = true; | 953 attributes.shareResources = true; |
954 attributes.depth = false; | 954 attributes.depth = false; |
(...skipping 29 matching lines...) Expand all Loading... |
984 | 984 |
985 if (!shared_contexts_compositor_thread_ || | 985 if (!shared_contexts_compositor_thread_ || |
986 shared_contexts_compositor_thread_->DestroyedOnMainThread()) { | 986 shared_contexts_compositor_thread_->DestroyedOnMainThread()) { |
987 shared_contexts_compositor_thread_ = | 987 shared_contexts_compositor_thread_ = |
988 RendererContextProviderCommandBuffer::Create(); | 988 RendererContextProviderCommandBuffer::Create(); |
989 } | 989 } |
990 return shared_contexts_compositor_thread_; | 990 return shared_contexts_compositor_thread_; |
991 } | 991 } |
992 | 992 |
993 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { | 993 AudioRendererMixerManager* RenderThreadImpl::GetAudioRendererMixerManager() { |
994 if (!audio_renderer_mixer_manager_.get()) { | 994 if (!audio_renderer_mixer_manager_) { |
995 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( | 995 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager( |
996 GetAudioHardwareConfig())); | 996 GetAudioHardwareConfig())); |
997 } | 997 } |
998 | 998 |
999 return audio_renderer_mixer_manager_.get(); | 999 return audio_renderer_mixer_manager_.get(); |
1000 } | 1000 } |
1001 | 1001 |
1002 media::AudioHardwareConfig* RenderThreadImpl::GetAudioHardwareConfig() { | 1002 media::AudioHardwareConfig* RenderThreadImpl::GetAudioHardwareConfig() { |
1003 if (!audio_hardware_config_) { | 1003 if (!audio_hardware_config_) { |
1004 media::AudioParameters input_params; | 1004 media::AudioParameters input_params; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 params.next_page_id, | 1163 params.next_page_id, |
1164 params.screen_info, | 1164 params.screen_info, |
1165 params.accessibility_mode, | 1165 params.accessibility_mode, |
1166 params.allow_partial_swap); | 1166 params.allow_partial_swap); |
1167 } | 1167 } |
1168 | 1168 |
1169 GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync( | 1169 GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync( |
1170 CauseForGpuLaunch cause_for_gpu_launch) { | 1170 CauseForGpuLaunch cause_for_gpu_launch) { |
1171 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); | 1171 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); |
1172 | 1172 |
1173 if (gpu_channel_.get()) { | 1173 if (gpu_channel_) { |
1174 // Do nothing if we already have a GPU channel or are already | 1174 // Do nothing if we already have a GPU channel or are already |
1175 // establishing one. | 1175 // establishing one. |
1176 if (gpu_channel_->state() == GpuChannelHost::kUnconnected || | 1176 if (gpu_channel_->state() == GpuChannelHost::kUnconnected || |
1177 gpu_channel_->state() == GpuChannelHost::kConnected) | 1177 gpu_channel_->state() == GpuChannelHost::kConnected) |
1178 return GetGpuChannel(); | 1178 return GetGpuChannel(); |
1179 | 1179 |
1180 // Recreate the channel if it has been lost. | 1180 // Recreate the channel if it has been lost. |
1181 gpu_channel_ = NULL; | 1181 gpu_channel_ = NULL; |
1182 } | 1182 } |
1183 | 1183 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 client, GetMediaStreamDependencyFactory()); | 1225 client, GetMediaStreamDependencyFactory()); |
1226 } | 1226 } |
1227 } | 1227 } |
1228 #endif | 1228 #endif |
1229 return media_stream_center_; | 1229 return media_stream_center_; |
1230 } | 1230 } |
1231 | 1231 |
1232 MediaStreamDependencyFactory* | 1232 MediaStreamDependencyFactory* |
1233 RenderThreadImpl::GetMediaStreamDependencyFactory() { | 1233 RenderThreadImpl::GetMediaStreamDependencyFactory() { |
1234 #if defined(ENABLE_WEBRTC) | 1234 #if defined(ENABLE_WEBRTC) |
1235 if (!media_stream_factory_.get()) { | 1235 if (!media_stream_factory_) { |
1236 media_stream_factory_.reset(new MediaStreamDependencyFactory( | 1236 media_stream_factory_.reset(new MediaStreamDependencyFactory( |
1237 vc_manager_, p2p_socket_dispatcher_)); | 1237 vc_manager_, p2p_socket_dispatcher_)); |
1238 } | 1238 } |
1239 #endif | 1239 #endif |
1240 return media_stream_factory_.get(); | 1240 return media_stream_factory_.get(); |
1241 } | 1241 } |
1242 | 1242 |
1243 GpuChannelHost* RenderThreadImpl::GetGpuChannel() { | 1243 GpuChannelHost* RenderThreadImpl::GetGpuChannel() { |
1244 if (!gpu_channel_.get()) | 1244 if (!gpu_channel_) |
1245 return NULL; | 1245 return NULL; |
1246 | 1246 |
1247 if (gpu_channel_->state() != GpuChannelHost::kConnected) | 1247 if (gpu_channel_->state() != GpuChannelHost::kConnected) |
1248 return NULL; | 1248 return NULL; |
1249 | 1249 |
1250 return gpu_channel_.get(); | 1250 return gpu_channel_.get(); |
1251 } | 1251 } |
1252 | 1252 |
1253 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { | 1253 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { |
1254 EnsureWebKitInitialized(); | 1254 EnsureWebKitInitialized(); |
(...skipping 18 matching lines...) Expand all Loading... |
1273 CHECK(false); | 1273 CHECK(false); |
1274 } | 1274 } |
1275 | 1275 |
1276 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | 1276 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { |
1277 ToggleWebKitSharedTimer(suspend); | 1277 ToggleWebKitSharedTimer(suspend); |
1278 } | 1278 } |
1279 | 1279 |
1280 scoped_refptr<base::MessageLoopProxy> | 1280 scoped_refptr<base::MessageLoopProxy> |
1281 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1281 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1282 DCHECK(message_loop() == MessageLoop::current()); | 1282 DCHECK(message_loop() == MessageLoop::current()); |
1283 if (!file_thread_.get()) { | 1283 if (!file_thread_) { |
1284 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1284 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1285 file_thread_->Start(); | 1285 file_thread_->Start(); |
1286 } | 1286 } |
1287 return file_thread_->message_loop_proxy(); | 1287 return file_thread_->message_loop_proxy(); |
1288 } | 1288 } |
1289 | 1289 |
1290 void RenderThreadImpl::SetFlingCurveParameters( | 1290 void RenderThreadImpl::SetFlingCurveParameters( |
1291 const std::vector<float>& new_touchpad, | 1291 const std::vector<float>& new_touchpad, |
1292 const std::vector<float>& new_touchscreen) { | 1292 const std::vector<float>& new_touchscreen) { |
1293 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1293 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1294 new_touchscreen); | 1294 new_touchscreen); |
1295 | 1295 |
1296 } | 1296 } |
1297 | 1297 |
1298 } // namespace content | 1298 } // namespace content |
OLD | NEW |