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

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

Issue 2400313002: Convert miscellaneous RenderThreadImpl messages to mojom (Closed)
Patch Set: rebase Created 4 years, 2 months 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
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 <utility> 10 #include <utility>
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 1729
1730 // Some messages are handled by delegates. 1730 // Some messages are handled by delegates.
1731 if (appcache_dispatcher_->OnMessageReceived(msg) || 1731 if (appcache_dispatcher_->OnMessageReceived(msg) ||
1732 dom_storage_dispatcher_->OnMessageReceived(msg) || 1732 dom_storage_dispatcher_->OnMessageReceived(msg) ||
1733 embedded_worker_dispatcher_->OnMessageReceived(msg)) { 1733 embedded_worker_dispatcher_->OnMessageReceived(msg)) {
1734 return true; 1734 return true;
1735 } 1735 }
1736 1736
1737 bool handled = true; 1737 bool handled = true;
1738 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) 1738 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg)
1739 // TODO(port): removed from render_messages_internal.h;
1740 // is there a new non-windows message I should add here?
1741 IPC_MESSAGE_HANDLER(ViewMsg_NetworkConnectionChanged,
1742 OnNetworkConnectionChanged)
1743 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateNewSharedWorker) 1739 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateNewSharedWorker)
1744 #if defined(OS_ANDROID)
1745 IPC_MESSAGE_HANDLER(ViewMsg_SetWebKitSharedTimersSuspended,
1746 OnSetWebKitSharedTimersSuspended)
1747 #endif
1748 #if defined(OS_MACOSX)
1749 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScrollbarTheme, OnUpdateScrollbarTheme)
1750 IPC_MESSAGE_HANDLER(ViewMsg_SystemColorsChanged, OnSystemColorsChanged)
1751 #endif
1752 #if defined(ENABLE_PLUGINS)
1753 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
1754 #endif
1755 IPC_MESSAGE_UNHANDLED(handled = false) 1740 IPC_MESSAGE_UNHANDLED(handled = false)
1756 IPC_END_MESSAGE_MAP() 1741 IPC_END_MESSAGE_MAP()
1757 return handled; 1742 return handled;
1758 } 1743 }
1759 1744
1760 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { 1745 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) {
1761 ChildThreadImpl::OnProcessBackgrounded(backgrounded); 1746 ChildThreadImpl::OnProcessBackgrounded(backgrounded);
1762 1747
1763 if (backgrounded) { 1748 if (backgrounded) {
1764 renderer_scheduler_->OnRendererBackgrounded(); 1749 renderer_scheduler_->OnRendererBackgrounded();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 } 1978 }
1994 1979
1995 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { 1980 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
1996 if (!gpu_channel_) 1981 if (!gpu_channel_)
1997 return nullptr; 1982 return nullptr;
1998 if (gpu_channel_->IsLost()) 1983 if (gpu_channel_->IsLost())
1999 return nullptr; 1984 return nullptr;
2000 return gpu_channel_.get(); 1985 return gpu_channel_.get();
2001 } 1986 }
2002 1987
2003 #if defined(ENABLE_PLUGINS)
2004 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) {
2005 // The call below will cause a GetPlugins call with refresh=true, but at this
2006 // point we already know that the browser has refreshed its list, so disable
2007 // refresh temporarily to prevent each renderer process causing the list to be
2008 // regenerated.
2009 blink_platform_impl_->set_plugin_refresh_allowed(false);
2010 blink::resetPluginCache(reload_pages);
2011 blink_platform_impl_->set_plugin_refresh_allowed(true);
2012
2013 FOR_EACH_OBSERVER(RenderThreadObserver, observers_, PluginListChanged());
2014 }
2015 #endif
2016
2017 void RenderThreadImpl::OnNetworkConnectionChanged(
2018 net::NetworkChangeNotifier::ConnectionType type,
2019 double max_bandwidth_mbps) {
2020 bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
2021 WebNetworkStateNotifier::setOnLine(online);
2022 FOR_EACH_OBSERVER(
2023 RenderThreadObserver, observers_, NetworkStateChanged(online));
2024 WebNetworkStateNotifier::setWebConnection(
2025 NetConnectionTypeToWebConnectionType(type), max_bandwidth_mbps);
2026 }
2027
2028 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { 1988 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) {
2029 CompositorDependencies* compositor_deps = this; 1989 CompositorDependencies* compositor_deps = this;
2030 // When bringing in render_view, also bring in webkit's glue and jsbindings. 1990 // When bringing in render_view, also bring in webkit's glue and jsbindings.
2031 RenderViewImpl::Create(compositor_deps, *params, false); 1991 RenderViewImpl::Create(compositor_deps, *params, false);
2032 } 1992 }
2033 1993
2034 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { 1994 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) {
2035 // Debug cases of https://crbug.com/626802. 1995 // Debug cases of https://crbug.com/626802.
2036 base::debug::SetCrashKeyValue("newframe_routing_id", 1996 base::debug::SetCrashKeyValue("newframe_routing_id",
2037 base::IntToString(params->routing_id)); 1997 base::IntToString(params->routing_id));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 base::IntToString(render_view_routing_id)); 2031 base::IntToString(render_view_routing_id));
2072 base::debug::SetCrashKeyValue("newproxy_opener_id", 2032 base::debug::SetCrashKeyValue("newproxy_opener_id",
2073 base::IntToString(opener_routing_id)); 2033 base::IntToString(opener_routing_id));
2074 base::debug::SetCrashKeyValue("newproxy_parent_id", 2034 base::debug::SetCrashKeyValue("newproxy_parent_id",
2075 base::IntToString(parent_routing_id)); 2035 base::IntToString(parent_routing_id));
2076 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id, 2036 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id,
2077 opener_routing_id, parent_routing_id, 2037 opener_routing_id, parent_routing_id,
2078 replicated_state); 2038 replicated_state);
2079 } 2039 }
2080 2040
2041 void RenderThreadImpl::OnNetworkConnectionChanged(
2042 net::NetworkChangeNotifier::ConnectionType type,
2043 double max_bandwidth_mbps) {
2044 bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE;
2045 WebNetworkStateNotifier::setOnLine(online);
2046 for (auto& observer : observers_)
2047 observer.NetworkStateChanged(online);
2048 WebNetworkStateNotifier::setWebConnection(
2049 NetConnectionTypeToWebConnectionType(type), max_bandwidth_mbps);
2050 }
2051
2052 void RenderThreadImpl::SetWebKitSharedTimersSuspended(bool suspend) {
2053 #if defined(OS_ANDROID)
2054 if (suspend) {
2055 renderer_scheduler_->SuspendTimerQueue();
2056 } else {
2057 renderer_scheduler_->ResumeTimerQueue();
2058 }
2059 webkit_shared_timer_suspended_ = suspend;
2060 #else
2061 NOTREACHED();
2062 #endif
2063 }
2064
2065 void RenderThreadImpl::UpdateScrollbarTheme(
2066 mojom::UpdateScrollbarThemeParamsPtr params) {
2067 #if defined(OS_MACOSX)
2068 static_cast<WebScrollbarBehaviorImpl*>(
2069 blink_platform_impl_->scrollbarBehavior())
2070 ->set_jump_on_track_click(params->jump_on_track_click);
2071
2072 blink::WebScrollbarTheme::updateScrollbarsWithNSDefaults(
2073 params->initial_button_delay, params->autoscroll_button_delay,
2074 params->preferred_scroller_style, params->redraw,
2075 params->button_placement);
2076 #else
2077 NOTREACHED();
2078 #endif
2079 }
2080
2081 void RenderThreadImpl::OnSystemColorsChanged(
2082 int32_t aqua_color_variant,
2083 const std::string& highlight_text_color,
2084 const std::string& highlight_color) {
2085 #if defined(OS_MACOSX)
2086 SystemColorsDidChange(aqua_color_variant, highlight_text_color,
2087 highlight_color);
2088 #else
2089 NOTREACHED();
2090 #endif
2091 }
2092
2093 void RenderThreadImpl::PurgePluginListCache(bool reload_pages) {
2094 #if defined(ENABLE_PLUGINS)
2095 // The call below will cause a GetPlugins call with refresh=true, but at this
2096 // point we already know that the browser has refreshed its list, so disable
2097 // refresh temporarily to prevent each renderer process causing the list to be
2098 // regenerated.
2099 blink_platform_impl_->set_plugin_refresh_allowed(false);
2100 blink::resetPluginCache(reload_pages);
2101 blink_platform_impl_->set_plugin_refresh_allowed(true);
2102
2103 for (auto& observer : observers_)
2104 observer.PluginListChanged();
2105 #else
2106 NOTREACHED();
2107 #endif
2108 }
2109
2081 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) { 2110 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) {
2082 if (!blink_platform_impl_) 2111 if (!blink_platform_impl_)
2083 return; 2112 return;
2084 if (!zone_id.empty()) { 2113 if (!zone_id.empty()) {
2085 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( 2114 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone(
2086 icu::UnicodeString::fromUTF8(zone_id)); 2115 icu::UnicodeString::fromUTF8(zone_id));
2087 icu::TimeZone::adoptDefault(new_zone); 2116 icu::TimeZone::adoptDefault(new_zone);
2088 VLOG(1) << "ICU default timezone is set to " << zone_id; 2117 VLOG(1) << "ICU default timezone is set to " << zone_id;
2089 } 2118 }
2090 NotifyTimezoneChange(); 2119 NotifyTimezoneChange();
2091 } 2120 }
2092 2121
2093 #if defined(OS_ANDROID)
2094 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) {
2095 if (suspend) {
2096 renderer_scheduler_->SuspendTimerQueue();
2097 } else {
2098 renderer_scheduler_->ResumeTimerQueue();
2099 }
2100 webkit_shared_timer_suspended_ = suspend;
2101 }
2102 #endif
2103
2104 #if defined(OS_MACOSX)
2105 void RenderThreadImpl::OnUpdateScrollbarTheme(
2106 const ViewMsg_UpdateScrollbarTheme_Params& params) {
2107 static_cast<WebScrollbarBehaviorImpl*>(
2108 blink_platform_impl_->scrollbarBehavior())
2109 ->set_jump_on_track_click(params.jump_on_track_click);
2110
2111 blink::WebScrollbarTheme::updateScrollbarsWithNSDefaults(
2112 params.initial_button_delay, params.autoscroll_button_delay,
2113 params.preferred_scroller_style, params.redraw,
2114 params.button_placement);
2115 }
2116
2117 void RenderThreadImpl::OnSystemColorsChanged(
2118 int aqua_color_variant,
2119 const std::string& highlight_text_color,
2120 const std::string& highlight_color) {
2121 SystemColorsDidChange(aqua_color_variant, highlight_text_color,
2122 highlight_color);
2123 }
2124 #endif
2125
2126 void RenderThreadImpl::OnCreateNewSharedWorker( 2122 void RenderThreadImpl::OnCreateNewSharedWorker(
2127 const WorkerProcessMsg_CreateWorker_Params& params) { 2123 const WorkerProcessMsg_CreateWorker_Params& params) {
2128 // EmbeddedSharedWorkerStub will self-destruct. 2124 // EmbeddedSharedWorkerStub will self-destruct.
2129 new EmbeddedSharedWorkerStub( 2125 new EmbeddedSharedWorkerStub(
2130 params.url, params.name, params.content_security_policy, 2126 params.url, params.name, params.content_security_policy,
2131 params.security_policy_type, params.creation_address_space, 2127 params.security_policy_type, params.creation_address_space,
2132 params.pause_on_start, params.route_id); 2128 params.pause_on_start, params.route_id);
2133 } 2129 }
2134 2130
2135 void RenderThreadImpl::OnMemoryPressure( 2131 void RenderThreadImpl::OnMemoryPressure(
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } 2356 }
2361 } 2357 }
2362 2358
2363 void RenderThreadImpl::OnRendererInterfaceRequest( 2359 void RenderThreadImpl::OnRendererInterfaceRequest(
2364 mojom::RendererAssociatedRequest request) { 2360 mojom::RendererAssociatedRequest request) {
2365 DCHECK(!renderer_binding_.is_bound()); 2361 DCHECK(!renderer_binding_.is_bound());
2366 renderer_binding_.Bind(std::move(request)); 2362 renderer_binding_.Bind(std::move(request));
2367 } 2363 }
2368 2364
2369 } // namespace content 2365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698