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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return histogram; | 275 return histogram; |
276 } | 276 } |
277 | 277 |
278 void AddHistogramSample(void* hist, int sample) { | 278 void AddHistogramSample(void* hist, int sample) { |
279 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 279 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
280 histogram->Add(sample); | 280 histogram->Add(sample); |
281 } | 281 } |
282 | 282 |
283 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmapFunction( | 283 scoped_ptr<cc::SharedBitmap> AllocateSharedBitmapFunction( |
284 const gfx::Size& size) { | 284 const gfx::Size& size) { |
285 return ChildThread::current()->shared_bitmap_manager()->AllocateSharedBitmap( | 285 return ChildThreadImpl::current()->shared_bitmap_manager()-> |
286 size); | 286 AllocateSharedBitmap(size); |
287 } | 287 } |
288 | 288 |
289 void EnableBlinkPlatformLogChannels(const std::string& channels) { | 289 void EnableBlinkPlatformLogChannels(const std::string& channels) { |
290 if (channels.empty()) | 290 if (channels.empty()) |
291 return; | 291 return; |
292 base::StringTokenizer t(channels, ", "); | 292 base::StringTokenizer t(channels, ", "); |
293 while (t.GetNext()) | 293 while (t.GetNext()) |
294 blink::enableLogChannel(t.token().c_str()); | 294 blink::enableLogChannel(t.token().c_str()); |
295 } | 295 } |
296 | 296 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 } | 416 } |
417 } | 417 } |
418 | 418 |
419 RenderThreadImpl* RenderThreadImpl::current() { | 419 RenderThreadImpl* RenderThreadImpl::current() { |
420 return lazy_tls.Pointer()->Get(); | 420 return lazy_tls.Pointer()->Get(); |
421 } | 421 } |
422 | 422 |
423 // When we run plugins in process, we actually run them on the render thread, | 423 // When we run plugins in process, we actually run them on the render thread, |
424 // which means that we need to make the render thread pump UI events. | 424 // which means that we need to make the render thread pump UI events. |
425 RenderThreadImpl::RenderThreadImpl() | 425 RenderThreadImpl::RenderThreadImpl() |
426 : ChildThread(Options(ShouldUseMojoChannel())) { | 426 : ChildThreadImpl(Options(ShouldUseMojoChannel())) { |
427 Init(); | 427 Init(); |
428 } | 428 } |
429 | 429 |
430 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) | 430 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
431 : ChildThread(Options(channel_name, ShouldUseMojoChannel())) { | 431 : ChildThreadImpl(Options(channel_name, ShouldUseMojoChannel())) { |
432 Init(); | 432 Init(); |
433 } | 433 } |
434 | 434 |
435 RenderThreadImpl::RenderThreadImpl( | 435 RenderThreadImpl::RenderThreadImpl( |
436 scoped_ptr<base::MessageLoop> main_message_loop) | 436 scoped_ptr<base::MessageLoop> main_message_loop) |
437 : ChildThread(Options(ShouldUseMojoChannel())), | 437 : ChildThreadImpl(Options(ShouldUseMojoChannel())), |
438 main_message_loop_(main_message_loop.Pass()) { | 438 main_message_loop_(main_message_loop.Pass()) { |
439 Init(); | 439 Init(); |
440 } | 440 } |
441 | 441 |
442 void RenderThreadImpl::Init() { | 442 void RenderThreadImpl::Init() { |
443 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 443 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
444 | 444 |
445 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( | 445 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( |
446 base::PlatformThread::CurrentId(), | 446 base::PlatformThread::CurrentId(), |
447 kTraceEventRendererMainThreadSortIndex); | 447 kTraceEventRendererMainThreadSortIndex); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 #if defined(OS_ANDROID) || defined(OS_LINUX) | 648 #if defined(OS_ANDROID) || defined(OS_LINUX) |
649 if (!command_line.HasSwitch( | 649 if (!command_line.HasSwitch( |
650 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { | 650 switches::kUseNormalPriorityForTileTaskWorkerThreads)) { |
651 cc::TileTaskWorkerPool::SetWorkerThreadPriority( | 651 cc::TileTaskWorkerPool::SetWorkerThreadPriority( |
652 base::kThreadPriority_Background); | 652 base::kThreadPriority_Background); |
653 } | 653 } |
654 #endif | 654 #endif |
655 } | 655 } |
656 | 656 |
657 base::DiscardableMemoryShmemAllocator::SetInstance( | 657 base::DiscardableMemoryShmemAllocator::SetInstance( |
658 ChildThread::discardable_shared_memory_manager()); | 658 ChildThreadImpl::discardable_shared_memory_manager()); |
659 | 659 |
660 service_registry()->AddService<RenderFrameSetup>( | 660 service_registry()->AddService<RenderFrameSetup>( |
661 base::Bind(CreateRenderFrameSetup)); | 661 base::Bind(CreateRenderFrameSetup)); |
662 | 662 |
663 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 663 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
664 } | 664 } |
665 | 665 |
666 RenderThreadImpl::~RenderThreadImpl() { | 666 RenderThreadImpl::~RenderThreadImpl() { |
667 } | 667 } |
668 | 668 |
669 void RenderThreadImpl::Shutdown() { | 669 void RenderThreadImpl::Shutdown() { |
670 FOR_EACH_OBSERVER( | 670 FOR_EACH_OBSERVER( |
671 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 671 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
672 | 672 |
673 ChildThread::Shutdown(); | 673 ChildThreadImpl::Shutdown(); |
674 | 674 |
675 if (memory_observer_) { | 675 if (memory_observer_) { |
676 message_loop()->RemoveTaskObserver(memory_observer_.get()); | 676 message_loop()->RemoveTaskObserver(memory_observer_.get()); |
677 memory_observer_.reset(); | 677 memory_observer_.reset(); |
678 } | 678 } |
679 | 679 |
680 // Wait for all databases to be closed. | 680 // Wait for all databases to be closed. |
681 if (blink_platform_impl_) { | 681 if (blink_platform_impl_) { |
682 // WaitForAllDatabasesToClose might run a nested message loop. To avoid | 682 // WaitForAllDatabasesToClose might run a nested message loop. To avoid |
683 // processing timer events while we're already in the process of shutting | 683 // processing timer events while we're already in the process of shutting |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 RenderViewImpl* render_view = | 804 RenderViewImpl* render_view = |
805 RenderViewImpl::FromRoutingID(msg->routing_id()); | 805 RenderViewImpl::FromRoutingID(msg->routing_id()); |
806 if (render_view) { | 806 if (render_view) { |
807 render_view_id = msg->routing_id(); | 807 render_view_id = msg->routing_id(); |
808 PluginChannelHost::Broadcast( | 808 PluginChannelHost::Broadcast( |
809 new PluginMsg_SignalModalDialogEvent(render_view_id)); | 809 new PluginMsg_SignalModalDialogEvent(render_view_id)); |
810 } | 810 } |
811 #endif | 811 #endif |
812 } | 812 } |
813 | 813 |
814 bool rv = ChildThread::Send(msg); | 814 bool rv = ChildThreadImpl::Send(msg); |
815 | 815 |
816 if (pumping_events) { | 816 if (pumping_events) { |
817 #if defined(ENABLE_PLUGINS) | 817 #if defined(ENABLE_PLUGINS) |
818 if (render_view_id != MSG_ROUTING_NONE) { | 818 if (render_view_id != MSG_ROUTING_NONE) { |
819 PluginChannelHost::Broadcast( | 819 PluginChannelHost::Broadcast( |
820 new PluginMsg_ResetModalDialogEvent(render_view_id)); | 820 new PluginMsg_ResetModalDialogEvent(render_view_id)); |
821 } | 821 } |
822 #endif | 822 #endif |
823 | 823 |
824 if (notify_webkit_of_modal_loop) | 824 if (notify_webkit_of_modal_loop) |
(...skipping 28 matching lines...) Expand all Loading... |
853 IPC::SyncMessageFilter* RenderThreadImpl::GetSyncMessageFilter() { | 853 IPC::SyncMessageFilter* RenderThreadImpl::GetSyncMessageFilter() { |
854 return sync_message_filter(); | 854 return sync_message_filter(); |
855 } | 855 } |
856 | 856 |
857 scoped_refptr<base::MessageLoopProxy> | 857 scoped_refptr<base::MessageLoopProxy> |
858 RenderThreadImpl::GetIOMessageLoopProxy() { | 858 RenderThreadImpl::GetIOMessageLoopProxy() { |
859 return ChildProcess::current()->io_message_loop_proxy(); | 859 return ChildProcess::current()->io_message_loop_proxy(); |
860 } | 860 } |
861 | 861 |
862 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { | 862 void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) { |
863 ChildThread::GetRouter()->AddRoute(routing_id, listener); | 863 ChildThreadImpl::GetRouter()->AddRoute(routing_id, listener); |
864 PendingRenderFrameConnectMap::iterator it = | 864 PendingRenderFrameConnectMap::iterator it = |
865 pending_render_frame_connects_.find(routing_id); | 865 pending_render_frame_connects_.find(routing_id); |
866 if (it == pending_render_frame_connects_.end()) | 866 if (it == pending_render_frame_connects_.end()) |
867 return; | 867 return; |
868 | 868 |
869 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); | 869 RenderFrameImpl* frame = RenderFrameImpl::FromRoutingID(routing_id); |
870 if (!frame) | 870 if (!frame) |
871 return; | 871 return; |
872 | 872 |
873 scoped_refptr<PendingRenderFrameConnect> connection(it->second); | 873 scoped_refptr<PendingRenderFrameConnect> connection(it->second); |
874 mojo::InterfaceRequest<mojo::ServiceProvider> services( | 874 mojo::InterfaceRequest<mojo::ServiceProvider> services( |
875 connection->services.Pass()); | 875 connection->services.Pass()); |
876 mojo::ServiceProviderPtr exposed_services( | 876 mojo::ServiceProviderPtr exposed_services( |
877 connection->exposed_services.Pass()); | 877 connection->exposed_services.Pass()); |
878 pending_render_frame_connects_.erase(it); | 878 pending_render_frame_connects_.erase(it); |
879 | 879 |
880 frame->BindServiceRegistry(services.Pass(), exposed_services.Pass()); | 880 frame->BindServiceRegistry(services.Pass(), exposed_services.Pass()); |
881 } | 881 } |
882 | 882 |
883 void RenderThreadImpl::RemoveRoute(int32 routing_id) { | 883 void RenderThreadImpl::RemoveRoute(int32 routing_id) { |
884 ChildThread::GetRouter()->RemoveRoute(routing_id); | 884 ChildThreadImpl::GetRouter()->RemoveRoute(routing_id); |
885 } | 885 } |
886 | 886 |
887 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, | 887 void RenderThreadImpl::AddEmbeddedWorkerRoute(int32 routing_id, |
888 IPC::Listener* listener) { | 888 IPC::Listener* listener) { |
889 AddRoute(routing_id, listener); | 889 AddRoute(routing_id, listener); |
890 if (devtools_agent_message_filter_.get()) { | 890 if (devtools_agent_message_filter_.get()) { |
891 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( | 891 devtools_agent_message_filter_->AddEmbeddedWorkerRouteOnMainThread( |
892 routing_id); | 892 routing_id); |
893 } | 893 } |
894 } | 894 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { | 1105 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { |
1106 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); | 1106 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); |
1107 } | 1107 } |
1108 | 1108 |
1109 void RenderThreadImpl::RecordComputedAction(const std::string& action) { | 1109 void RenderThreadImpl::RecordComputedAction(const std::string& action) { |
1110 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 1110 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
1111 } | 1111 } |
1112 | 1112 |
1113 scoped_ptr<base::SharedMemory> | 1113 scoped_ptr<base::SharedMemory> |
1114 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 1114 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
1115 return ChildThread::AllocateSharedMemory(size, thread_safe_sender()); | 1115 return ChildThreadImpl::AllocateSharedMemory(size, thread_safe_sender()); |
1116 } | 1116 } |
1117 | 1117 |
1118 cc::SharedBitmapManager* RenderThreadImpl::GetSharedBitmapManager() { | 1118 cc::SharedBitmapManager* RenderThreadImpl::GetSharedBitmapManager() { |
1119 return shared_bitmap_manager(); | 1119 return shared_bitmap_manager(); |
1120 } | 1120 } |
1121 | 1121 |
1122 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { | 1122 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { |
1123 WebScriptController::registerExtension(extension); | 1123 WebScriptController::registerExtension(extension); |
1124 } | 1124 } |
1125 | 1125 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 base::WaitableEvent* RenderThreadImpl::GetShutdownEvent() { | 1319 base::WaitableEvent* RenderThreadImpl::GetShutdownEvent() { |
1320 return ChildProcess::current()->GetShutDownEvent(); | 1320 return ChildProcess::current()->GetShutDownEvent(); |
1321 } | 1321 } |
1322 | 1322 |
1323 #if defined(OS_WIN) | 1323 #if defined(OS_WIN) |
1324 void RenderThreadImpl::PreCacheFontCharacters(const LOGFONT& log_font, | 1324 void RenderThreadImpl::PreCacheFontCharacters(const LOGFONT& log_font, |
1325 const base::string16& str) { | 1325 const base::string16& str) { |
1326 Send(new ViewHostMsg_PreCacheFontCharacters(log_font, str)); | 1326 Send(new ViewHostMsg_PreCacheFontCharacters(log_font, str)); |
1327 } | 1327 } |
1328 | 1328 |
1329 void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) { | |
1330 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | |
1331 } | |
1332 | |
1333 void RenderThreadImpl::ReleaseCachedFonts() { | |
1334 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | |
1335 } | |
1336 | |
1337 #endif // OS_WIN | 1329 #endif // OS_WIN |
1338 | 1330 |
1339 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { | 1331 ServiceRegistry* RenderThreadImpl::GetServiceRegistry() { |
1340 return service_registry(); | 1332 return service_registry(); |
1341 } | 1333 } |
1342 | 1334 |
1343 bool RenderThreadImpl::IsImplSidePaintingEnabled() { | 1335 bool RenderThreadImpl::IsImplSidePaintingEnabled() { |
1344 return is_impl_side_painting_enabled_; | 1336 return is_impl_side_painting_enabled_; |
1345 } | 1337 } |
1346 | 1338 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 1796 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
1805 mojo::ServiceProviderPtr exposed_services) | 1797 mojo::ServiceProviderPtr exposed_services) |
1806 : services(services.Pass()), | 1798 : services(services.Pass()), |
1807 exposed_services(exposed_services.Pass()) { | 1799 exposed_services(exposed_services.Pass()) { |
1808 } | 1800 } |
1809 | 1801 |
1810 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() { | 1802 RenderThreadImpl::PendingRenderFrameConnect::~PendingRenderFrameConnect() { |
1811 } | 1803 } |
1812 | 1804 |
1813 } // namespace content | 1805 } // namespace content |
OLD | NEW |