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 29 matching lines...) Expand all Loading... |
40 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
41 #include "content/common/web_database_observer_impl.h" | 41 #include "content/common/web_database_observer_impl.h" |
42 #include "content/public/common/content_paths.h" | 42 #include "content/public/common/content_paths.h" |
43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/renderer_preferences.h" | 44 #include "content/public/common/renderer_preferences.h" |
45 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
46 #include "content/public/renderer/content_renderer_client.h" | 46 #include "content/public/renderer/content_renderer_client.h" |
47 #include "content/public/renderer/render_process_observer.h" | 47 #include "content/public/renderer/render_process_observer.h" |
48 #include "content/public/renderer/render_view_visitor.h" | 48 #include "content/public/renderer/render_view_visitor.h" |
49 #include "content/renderer/devtools_agent_filter.h" | 49 #include "content/renderer/devtools_agent_filter.h" |
| 50 #include "content/renderer/dom_storage/dom_storage_dispatcher.h" |
| 51 #include "content/renderer/dom_storage/webstoragearea_impl.h" |
| 52 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
50 #include "content/renderer/gpu/compositor_thread.h" | 53 #include "content/renderer/gpu/compositor_thread.h" |
51 #include "content/renderer/media/audio_input_message_filter.h" | 54 #include "content/renderer/media/audio_input_message_filter.h" |
52 #include "content/renderer/media/audio_message_filter.h" | 55 #include "content/renderer/media/audio_message_filter.h" |
53 #include "content/renderer/media/media_stream_center.h" | 56 #include "content/renderer/media/media_stream_center.h" |
54 #include "content/renderer/media/video_capture_impl_manager.h" | 57 #include "content/renderer/media/video_capture_impl_manager.h" |
55 #include "content/renderer/media/video_capture_message_filter.h" | 58 #include "content/renderer/media/video_capture_message_filter.h" |
56 #include "content/renderer/plugin_channel_host.h" | 59 #include "content/renderer/plugin_channel_host.h" |
57 #include "content/renderer/render_process_impl.h" | 60 #include "content/renderer/render_process_impl.h" |
58 #include "content/renderer/render_view_impl.h" | 61 #include "content/renderer/render_view_impl.h" |
59 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 62 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
60 #include "content/renderer/renderer_webstoragearea_impl.h" | |
61 #include "content/renderer/renderer_webstoragenamespace_impl.h" | |
62 #include "grit/content_resources.h" | 63 #include "grit/content_resources.h" |
63 #include "ipc/ipc_channel_handle.h" | 64 #include "ipc/ipc_channel_handle.h" |
64 #include "ipc/ipc_platform_file.h" | 65 #include "ipc/ipc_platform_file.h" |
65 #include "media/base/media.h" | 66 #include "media/base/media.h" |
66 #include "net/base/net_errors.h" | 67 #include "net/base/net_errors.h" |
67 #include "net/base/net_util.h" | 68 #include "net/base/net_util.h" |
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h" | 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h" |
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" |
70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" |
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi
er.h" | 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifi
er.h" |
75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" | 78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" |
78 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
79 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" | |
80 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 80 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
82 #include "ui/base/ui_base_switches.h" | 82 #include "ui/base/ui_base_switches.h" |
83 #include "v8/include/v8.h" | 83 #include "v8/include/v8.h" |
84 #include "webkit/glue/webkit_glue.h" | 84 #include "webkit/glue/webkit_glue.h" |
85 | 85 |
86 // TODO(port) | 86 // TODO(port) |
87 #if !defined(OS_WIN) | 87 #if !defined(OS_WIN) |
88 #include "base/memory/scoped_handle.h" | 88 #include "base/memory/scoped_handle.h" |
89 #include "content/common/np_channel_base.h" | 89 #include "content/common/np_channel_base.h" |
90 #endif | 90 #endif |
91 | 91 |
92 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
93 #include <windows.h> | 93 #include <windows.h> |
94 #include <objbase.h> | 94 #include <objbase.h> |
95 #endif | 95 #endif |
96 | 96 |
97 #if defined(OS_POSIX) | 97 #if defined(OS_POSIX) |
98 #include "ipc/ipc_channel_posix.h" | 98 #include "ipc/ipc_channel_posix.h" |
99 #endif | 99 #endif |
100 | 100 |
101 using WebKit::WebDocument; | 101 using WebKit::WebDocument; |
102 using WebKit::WebFrame; | 102 using WebKit::WebFrame; |
103 using WebKit::WebNetworkStateNotifier; | 103 using WebKit::WebNetworkStateNotifier; |
104 using WebKit::WebRuntimeFeatures; | 104 using WebKit::WebRuntimeFeatures; |
105 using WebKit::WebScriptController; | 105 using WebKit::WebScriptController; |
106 using WebKit::WebSecurityPolicy; | 106 using WebKit::WebSecurityPolicy; |
107 using WebKit::WebString; | 107 using WebKit::WebString; |
108 using WebKit::WebStorageEventDispatcher; | |
109 using WebKit::WebView; | 108 using WebKit::WebView; |
110 using content::RenderProcessObserver; | 109 using content::RenderProcessObserver; |
111 | 110 |
112 namespace { | 111 namespace { |
113 | 112 |
114 const int64 kInitialIdleHandlerDelayMs = 1000; | 113 const int64 kInitialIdleHandlerDelayMs = 1000; |
115 const int64 kShortIdleHandlerDelayMs = 1000; | 114 const int64 kShortIdleHandlerDelayMs = 1000; |
116 const int64 kLongIdleHandlerDelayMs = 30*1000; | 115 const int64 kLongIdleHandlerDelayMs = 30*1000; |
117 const int kIdleCPUUsageThresholdInPercents = 3; | 116 const int kIdleCPUUsageThresholdInPercents = 3; |
118 | 117 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 suspend_webkit_shared_timer_ = true; | 202 suspend_webkit_shared_timer_ = true; |
204 notify_webkit_of_modal_loop_ = true; | 203 notify_webkit_of_modal_loop_ = true; |
205 plugin_refresh_allowed_ = true; | 204 plugin_refresh_allowed_ = true; |
206 widget_count_ = 0; | 205 widget_count_ = 0; |
207 hidden_widget_count_ = 0; | 206 hidden_widget_count_ = 0; |
208 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 207 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
209 idle_notifications_to_skip_ = 0; | 208 idle_notifications_to_skip_ = 0; |
210 compositor_initialized_ = false; | 209 compositor_initialized_ = false; |
211 | 210 |
212 appcache_dispatcher_.reset(new AppCacheDispatcher(Get())); | 211 appcache_dispatcher_.reset(new AppCacheDispatcher(Get())); |
| 212 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); |
213 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); | 213 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); |
214 | 214 |
215 media_stream_center_ = NULL; | 215 media_stream_center_ = NULL; |
216 | 216 |
217 db_message_filter_ = new DBMessageFilter(); | 217 db_message_filter_ = new DBMessageFilter(); |
218 AddFilter(db_message_filter_.get()); | 218 AddFilter(db_message_filter_.get()); |
219 | 219 |
220 vc_manager_ = new VideoCaptureImplManager(); | 220 vc_manager_ = new VideoCaptureImplManager(); |
221 AddFilter(vc_manager_->video_capture_message_filter()); | 221 AddFilter(vc_manager_->video_capture_message_filter()); |
222 | 222 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 803 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
804 notify_webkit_of_modal_loop_ = false; | 804 notify_webkit_of_modal_loop_ = false; |
805 } | 805 } |
806 | 806 |
807 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& host, | 807 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& host, |
808 double zoom_level) { | 808 double zoom_level) { |
809 RenderViewZoomer zoomer(host, zoom_level); | 809 RenderViewZoomer zoomer(host, zoom_level); |
810 content::RenderView::ForEach(&zoomer); | 810 content::RenderView::ForEach(&zoomer); |
811 } | 811 } |
812 | 812 |
813 void RenderThreadImpl::OnDOMStorageEvent( | |
814 const DOMStorageMsg_Event_Params& params) { | |
815 EnsureWebKitInitialized(); | |
816 | |
817 bool originated_in_process = params.connection_id != 0; | |
818 RendererWebStorageAreaImpl* originating_area = NULL; | |
819 if (originated_in_process) { | |
820 originating_area = RendererWebStorageAreaImpl::FromConnectionId( | |
821 params.connection_id); | |
822 } | |
823 | |
824 if (params.namespace_id == dom_storage::kLocalStorageNamespaceId) { | |
825 WebStorageEventDispatcher::dispatchLocalStorageEvent( | |
826 params.key, | |
827 params.old_value, | |
828 params.new_value, | |
829 params.origin, | |
830 params.page_url, | |
831 originating_area, | |
832 originated_in_process); | |
833 } else if (originated_in_process) { | |
834 // TODO(michaeln): For now, we only raise session storage events into the | |
835 // process which caused the event to occur. However there are cases where | |
836 // sessions can span process boundaries, so there are correctness issues. | |
837 RendererWebStorageNamespaceImpl | |
838 session_namespace_for_event_dispatch(params.namespace_id); | |
839 WebStorageEventDispatcher::dispatchSessionStorageEvent( | |
840 params.key, | |
841 params.old_value, | |
842 params.new_value, | |
843 params.origin, | |
844 params.page_url, | |
845 session_namespace_for_event_dispatch, | |
846 originating_area, | |
847 originated_in_process); | |
848 } | |
849 } | |
850 | |
851 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 813 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
852 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 814 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
853 RenderProcessObserver* observer; | 815 RenderProcessObserver* observer; |
854 while ((observer = it.GetNext()) != NULL) { | 816 while ((observer = it.GetNext()) != NULL) { |
855 if (observer->OnControlMessageReceived(msg)) | 817 if (observer->OnControlMessageReceived(msg)) |
856 return true; | 818 return true; |
857 } | 819 } |
858 | 820 |
859 // Some messages are handled by delegates. | 821 // Some messages are handled by delegates. |
860 if (appcache_dispatcher_->OnMessageReceived(msg)) | 822 if (appcache_dispatcher_->OnMessageReceived(msg) || |
| 823 dom_storage_dispatcher_->OnMessageReceived(msg)) { |
861 return true; | 824 return true; |
| 825 } |
862 | 826 |
863 bool handled = true; | 827 bool handled = true; |
864 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) | 828 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) |
865 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, | 829 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
866 OnSetZoomLevelForCurrentURL) | 830 OnSetZoomLevelForCurrentURL) |
867 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) | 831 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) |
868 // TODO(port): removed from render_messages_internal.h; | 832 // TODO(port): removed from render_messages_internal.h; |
869 // is there a new non-windows message I should add here? | 833 // is there a new non-windows message I should add here? |
870 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 834 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
871 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 835 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
872 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) | 836 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) |
873 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) | |
874 IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData) | 837 IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData) |
875 IPC_MESSAGE_UNHANDLED(handled = false) | 838 IPC_MESSAGE_UNHANDLED(handled = false) |
876 IPC_END_MESSAGE_MAP() | 839 IPC_END_MESSAGE_MAP() |
877 return handled; | 840 return handled; |
878 } | 841 } |
879 | 842 |
880 // Called when to register CSS Color name->system color mappings. | 843 // Called when to register CSS Color name->system color mappings. |
881 // We update the colors one by one and then tell WebKit to refresh all render | 844 // We update the colors one by one and then tell WebKit to refresh all render |
882 // views. | 845 // views. |
883 void RenderThreadImpl::OnSetCSSColors( | 846 void RenderThreadImpl::OnSetCSSColors( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 970 |
1008 scoped_refptr<base::MessageLoopProxy> | 971 scoped_refptr<base::MessageLoopProxy> |
1009 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 972 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1010 DCHECK(message_loop() == MessageLoop::current()); | 973 DCHECK(message_loop() == MessageLoop::current()); |
1011 if (!file_thread_.get()) { | 974 if (!file_thread_.get()) { |
1012 file_thread_.reset(new base::Thread("Renderer::FILE")); | 975 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1013 file_thread_->Start(); | 976 file_thread_->Start(); |
1014 } | 977 } |
1015 return file_thread_->message_loop_proxy(); | 978 return file_thread_->message_loop_proxy(); |
1016 } | 979 } |
OLD | NEW |