blob: 81da444761578b7c5d006b8b0db4a44af3608da7 [file] [log] [blame]
[email protected]d3d6325d2012-01-03 21:17:361// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]f1a29a02011-10-06 23:08:445#include "content/renderer/render_thread_impl.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]da00a2882009-03-09 17:51:197#include <algorithm>
[email protected]61a9b2d82010-02-26 00:31:088#include <limits>
[email protected]75e126b932009-09-28 19:38:499#include <map>
[email protected]da00a2882009-03-09 17:51:1910#include <vector>
11
[email protected]237a14852012-04-28 02:56:3812#include "base/allocator/allocator_extension.h"
[email protected]06533c0b2009-03-05 21:39:1113#include "base/command_line.h"
[email protected]58580352010-10-26 04:07:5014#include "base/debug/trace_event.h"
[email protected]94f9a0f682009-06-15 18:30:3015#include "base/lazy_instance.h"
[email protected]bee16aab2009-08-26 15:55:0316#include "base/logging.h"
[email protected]835d7c82010-10-14 04:38:3817#include "base/metrics/field_trial.h"
[email protected]6cf19311f2011-04-14 23:06:0218#include "base/metrics/histogram.h"
[email protected]835d7c82010-10-14 04:38:3819#include "base/metrics/stats_table.h"
[email protected]433df472012-03-07 20:33:3920#include "base/path_service.h"
initial.commit09911bf2008-07-26 23:55:2921#include "base/shared_memory.h"
[email protected]8c380582011-12-02 03:16:1022#include "base/string_number_conversions.h" // Temporary
[email protected]1357c322010-12-30 22:18:5623#include "base/threading/thread_local.h"
[email protected]58436a12012-03-21 17:10:2624#include "base/utf_string_conversions.h"
[email protected]7a4de7a62010-08-17 18:38:2425#include "base/values.h"
[email protected]e93e04e2011-03-14 00:27:1026#include "content/common/appcache/appcache_dispatcher.h"
[email protected]83ab4a282012-07-12 18:19:4527#include "content/common/child_histogram_message_filter.h"
[email protected]bdae9812011-10-15 00:33:0328#include "content/common/child_process_messages.h"
[email protected]37666cf2011-03-13 21:51:4229#include "content/common/database_messages.h"
30#include "content/common/db_message_filter.h"
[email protected]127dd582011-03-16 21:32:1031#include "content/common/dom_storage_messages.h"
[email protected]c26ad882012-02-07 06:41:2032#include "content/common/gpu/client/gpu_channel_host.h"
[email protected]202b54ff2011-04-22 21:36:3833#include "content/common/gpu/gpu_messages.h"
[email protected]988aacf2012-02-12 18:10:0334#include "content/common/indexed_db/indexed_db_dispatcher.h"
35#include "content/common/indexed_db/indexed_db_message_filter.h"
[email protected]d3fd748b2011-09-20 17:39:1736#include "content/common/npobject_util.h"
[email protected]105303e2011-03-14 22:16:1037#include "content/common/plugin_messages.h"
[email protected]359dfa32011-10-12 01:10:1538#include "content/common/resource_dispatcher.h"
[email protected]94dc971d2011-03-05 19:08:3239#include "content/common/resource_messages.h"
[email protected]778574e2011-03-21 22:03:5040#include "content/common/view_messages.h"
[email protected]e93e04e2011-03-14 00:27:1041#include "content/common/web_database_observer_impl.h"
[email protected]b7c4f032012-08-07 16:38:5642#include "content/public/common/compositor_util.h"
[email protected]a458504b2012-07-23 19:57:0643#include "content/public/common/content_constants.h"
[email protected]433df472012-03-07 20:33:3944#include "content/public/common/content_paths.h"
[email protected]c08950d22011-10-13 22:20:2945#include "content/public/common/content_switches.h"
[email protected]daf82f82011-10-31 22:35:3146#include "content/public/common/renderer_preferences.h"
[email protected]58436a12012-03-21 17:10:2647#include "content/public/common/url_constants.h"
[email protected]d344114c2011-10-01 01:24:3448#include "content/public/renderer/content_renderer_client.h"
[email protected]64ffa0442011-10-03 22:08:3649#include "content/public/renderer/render_process_observer.h"
50#include "content/public/renderer/render_view_visitor.h"
[email protected]14cf0f12012-06-18 17:15:5751#include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h"
52#include "content/renderer/browser_plugin/old/browser_plugin_registry.h"
[email protected]82622452011-07-22 09:57:2053#include "content/renderer/devtools_agent_filter.h"
[email protected]1910fe82012-05-10 00:04:1054#include "content/renderer/dom_storage/dom_storage_dispatcher.h"
55#include "content/renderer/dom_storage/webstoragearea_impl.h"
56#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
[email protected]a9fb30aa2011-10-06 06:58:4657#include "content/renderer/gpu/compositor_thread.h"
[email protected]1842fe22012-08-13 23:24:3558#include "content/renderer/gpu/compositor_output_surface.h"
[email protected]e54ab492012-06-12 19:40:0159#include "content/renderer/gpu/gpu_benchmarking_extension.h"
[email protected]3958e972012-07-17 00:25:4160#include "content/renderer/media/audio_hardware.h"
[email protected]f7eb0a392011-07-12 10:19:5161#include "content/renderer/media/audio_input_message_filter.h"
62#include "content/renderer/media/audio_message_filter.h"
[email protected]3958e972012-07-17 00:25:4163#include "content/renderer/media/audio_renderer_mixer_manager.h"
[email protected]d8cd8372012-03-09 10:49:5164#include "content/renderer/media/media_stream_center.h"
[email protected]6ee10bd2012-09-13 09:01:5365#include "content/renderer/media/media_stream_dependency_factory.h"
[email protected]80b161a2011-06-27 17:42:1166#include "content/renderer/media/video_capture_impl_manager.h"
[email protected]ba164c912011-06-14 22:07:3467#include "content/renderer/media/video_capture_message_filter.h"
[email protected]4761cf12012-09-12 10:37:5568#include "content/renderer/p2p/socket_dispatcher.h"
[email protected]6f516082011-03-17 19:15:3569#include "content/renderer/plugin_channel_host.h"
[email protected]8704f89b2011-04-15 00:30:0570#include "content/renderer/render_process_impl.h"
[email protected]310ebd6302011-10-10 19:06:2871#include "content/renderer/render_view_impl.h"
[email protected]8d6cba42011-09-02 10:05:1972#include "content/renderer/renderer_webkitplatformsupport_impl.h"
[email protected]766a7082012-02-03 23:39:1573#include "grit/content_resources.h"
[email protected]46f36a492010-07-28 19:36:4174#include "ipc/ipc_channel_handle.h"
[email protected]1842fe22012-08-13 23:24:3575#include "ipc/ipc_forwarding_message_filter.h"
[email protected]cb6037d2009-11-16 22:55:1776#include "ipc/ipc_platform_file.h"
[email protected]433df472012-03-07 20:33:3977#include "media/base/media.h"
[email protected]620161e2011-03-07 18:05:2678#include "net/base/net_errors.h"
[email protected]9d797f32010-04-23 07:17:5479#include "net/base/net_util.h"
[email protected]cd7ce3be2012-09-10 05:19:4180#include "third_party/WebKit/Source/Platform/chromium/public/Platform.h"
81#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSupport.h"
[email protected]1332623f12012-08-10 03:45:1382#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
[email protected]f8c648b2012-02-28 03:46:4583#include "third_party/WebKit/Source/WebKit/chromium/public/WebColorName.h"
[email protected]8bd0fe62011-01-17 06:44:3784#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
85#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
[email protected]8bd0fe62011-01-17 06:44:3786#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
87#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
[email protected]6eac57a2011-07-12 21:15:0988#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
[email protected]4bd55a32011-07-28 13:28:3889#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
[email protected]8bd0fe62011-01-17 06:44:3790#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
91#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
[email protected]58436a12012-03-21 17:10:2692#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
[email protected]61a796c42012-05-17 21:28:2093#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
[email protected]c49201a2012-05-24 11:04:5794#include "ui/base/layout.h"
[email protected]18ad6772011-09-20 21:51:3295#include "ui/base/ui_base_switches.h"
[email protected]7f3a2cf2011-04-06 00:10:5096#include "v8/include/v8.h"
[email protected]d471190a2011-02-16 14:52:3097#include "webkit/glue/webkit_glue.h"
[email protected]2c62b562009-01-27 19:04:5098
[email protected]da00a2882009-03-09 17:51:1999#if defined(OS_WIN)
100#include <windows.h>
101#include <objbase.h>
[email protected]5f7e4512012-10-01 20:51:37102#include "base/win/scoped_com_initializer.h"
103#else
104// TODO(port)
105#include "base/memory/scoped_handle.h"
106#include "content/common/np_channel_base.h"
[email protected]da00a2882009-03-09 17:51:19107#endif
108
[email protected]6217d392010-03-25 22:08:35109#if defined(OS_POSIX)
110#include "ipc/ipc_channel_posix.h"
111#endif
112
[email protected]b6cb3a842011-06-24 18:28:41113using WebKit::WebDocument;
[email protected]f85f0702010-01-30 09:31:01114using WebKit::WebFrame;
[email protected]6eac57a2011-07-12 21:15:09115using WebKit::WebNetworkStateNotifier;
[email protected]adf00bc2009-11-02 18:35:00116using WebKit::WebRuntimeFeatures;
[email protected]98d7127b2009-10-23 18:26:51117using WebKit::WebScriptController;
[email protected]58436a12012-03-21 17:10:26118using WebKit::WebSecurityPolicy;
[email protected]2c434b32009-03-19 06:27:47119using WebKit::WebString;
[email protected]50ae00ef2009-10-19 05:11:03120using WebKit::WebView;
[email protected]3958e972012-07-17 00:25:41121using content::AudioRendererMixerManager;
[email protected]64ffa0442011-10-03 22:08:36122using content::RenderProcessObserver;
initial.commit09911bf2008-07-26 23:55:29123
[email protected]42f1d7822009-07-23 18:17:55124namespace {
[email protected]da9ccfb2012-01-28 00:34:40125
126const int64 kInitialIdleHandlerDelayMs = 1000;
127const int64 kShortIdleHandlerDelayMs = 1000;
128const int64 kLongIdleHandlerDelayMs = 30*1000;
129const int kIdleCPUUsageThresholdInPercents = 3;
[email protected]bee16aab2009-08-26 15:55:03130
[email protected]f1a29a02011-10-06 23:08:44131// Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
[email protected]f3ede412010-06-21 22:52:16132// incorrectly from the wrong thread.
[email protected]da9ccfb2012-01-28 00:34:40133base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
[email protected]6de0fd1d2011-11-15 13:31:49134 lazy_tls = LAZY_INSTANCE_INITIALIZER;
[email protected]1edc16b82009-04-07 17:45:54135
[email protected]64ffa0442011-10-03 22:08:36136class RenderViewZoomer : public content::RenderViewVisitor {
[email protected]40bd6582009-12-04 23:49:51137 public:
[email protected]4e2a25a2012-01-27 00:42:08138 RenderViewZoomer(const std::string& host, double zoom_level)
139 : host_(host), zoom_level_(zoom_level) {
[email protected]40bd6582009-12-04 23:49:51140 }
141
[email protected]a2ef54c2011-10-10 16:20:31142 virtual bool Visit(content::RenderView* render_view) {
143 WebView* webview = render_view->GetWebView();
[email protected]b6cb3a842011-06-24 18:28:41144 WebDocument document = webview->mainFrame()->document();
[email protected]b75b8292010-10-01 07:28:25145
146 // Don't set zoom level for full-page plugin since they don't use the same
147 // zoom settings.
[email protected]b6cb3a842011-06-24 18:28:41148 if (document.isPluginDocument())
[email protected]b75b8292010-10-01 07:28:25149 return true;
150
[email protected]b6cb3a842011-06-24 18:28:41151 if (net::GetHostOrSpecFromURL(GURL(document.url())) == host_)
[email protected]40bd6582009-12-04 23:49:51152 webview->setZoomLevel(false, zoom_level_);
153 return true;
154 }
155
156 private:
157 std::string host_;
[email protected]b75b8292010-10-01 07:28:25158 double zoom_level_;
[email protected]40bd6582009-12-04 23:49:51159
160 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
161};
[email protected]0478d0162010-08-28 08:29:40162
[email protected]b2d98762012-09-03 17:04:06163std::string HostToCustomHistogramSuffix(const std::string& host) {
164 if (host == "mail.google.com")
165 return ".gmail";
166 if (host == "docs.google.com" || host == "drive.google.com")
167 return ".docs";
168 if (host == "plus.google.com")
169 return ".plus";
170 return "";
171}
[email protected]42f1d7822009-07-23 18:17:55172
[email protected]b2d98762012-09-03 17:04:06173void* CreateHistogram(
[email protected]d1b8fccc2011-08-03 01:20:13174 const char *name, int min, int max, size_t buckets) {
175 if (min <= 0)
176 min = 1;
[email protected]b2d98762012-09-03 17:04:06177 std::string histogram_name;
178 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
179 if (render_thread_impl) { // Can be null in tests.
180 histogram_name = render_thread_impl->
181 histogram_customizer()->ConvertToCustomHistogramName(name);
182 } else {
183 histogram_name = std::string(name);
184 }
[email protected]d1b8fccc2011-08-03 01:20:13185 base::Histogram* histogram = base::Histogram::FactoryGet(
[email protected]b2d98762012-09-03 17:04:06186 histogram_name, min, max, buckets,
187 base::Histogram::kUmaTargetedHistogramFlag);
[email protected]d1b8fccc2011-08-03 01:20:13188 return histogram;
189}
190
[email protected]b2d98762012-09-03 17:04:06191void AddHistogramSample(void* hist, int sample) {
[email protected]d1b8fccc2011-08-03 01:20:13192 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
193 histogram->Add(sample);
194}
195
[email protected]b2d98762012-09-03 17:04:06196} // namespace
197
[email protected]fe476b02012-08-13 21:21:38198class RenderThreadImpl::GpuVDAContextLostCallback
199 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
200 public:
201 GpuVDAContextLostCallback() {}
202 virtual ~GpuVDAContextLostCallback() {}
203 virtual void onContextLost() {
204 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
205 &RenderThreadImpl::OnGpuVDAContextLoss));
206 }
207};
208
[email protected]b2d98762012-09-03 17:04:06209RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() {
210 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal");
211 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted");
212 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed");
213}
214
215RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {}
216
217void RenderThreadImpl::HistogramCustomizer::RenderViewNavigatedToHost(
218 const std::string& host, size_t view_count) {
219 // Check if all RenderViews are displaying a page from the same host. If there
220 // is only one RenderView, the common host is this view's host. If there are
221 // many, check if this one shares the common host of the other
222 // RenderViews. It's ok to not detect some cases where the RenderViews share a
223 // common host. This information is only used for producing custom histograms.
224 if (view_count == 1)
225 SetCommonHost(host);
226 else if (host != common_host_)
227 SetCommonHost(std::string());
228}
229
230std::string RenderThreadImpl::HistogramCustomizer::ConvertToCustomHistogramName(
231 const char* histogram_name) const {
232 std::string name(histogram_name);
233 if (!common_host_histogram_suffix_.empty() &&
234 custom_histograms_.find(name) != custom_histograms_.end())
235 name += common_host_histogram_suffix_;
236 return name;
237}
238
239void RenderThreadImpl::HistogramCustomizer::SetCommonHost(
240 const std::string& host) {
241 if (host != common_host_) {
242 common_host_ = host;
243 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host);
244 v8::V8::SetCreateHistogramFunction(CreateHistogram);
245 }
246}
247
[email protected]f1a29a02011-10-06 23:08:44248RenderThreadImpl* RenderThreadImpl::current() {
[email protected]526476902011-10-06 20:34:06249 return lazy_tls.Pointer()->Get();
250}
251
[email protected]42f1d7822009-07-23 18:17:55252// When we run plugins in process, we actually run them on the render thread,
253// which means that we need to make the render thread pump UI events.
[email protected]f1a29a02011-10-06 23:08:44254RenderThreadImpl::RenderThreadImpl() {
[email protected]42f1d7822009-07-23 18:17:55255 Init();
256}
257
[email protected]f1a29a02011-10-06 23:08:44258RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
[email protected]42f1d7822009-07-23 18:17:55259 : ChildThread(channel_name) {
260 Init();
261}
[email protected]5fa1c542009-05-05 20:36:07262
[email protected]f1a29a02011-10-06 23:08:44263void RenderThreadImpl::Init() {
264 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, "");
[email protected]a872ea1f2010-08-11 04:45:33265
[email protected]c7e948b42012-07-12 09:20:20266 v8::V8::SetCounterFunction(base::StatsTable::FindLocation);
267 v8::V8::SetCreateHistogramFunction(CreateHistogram);
268 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample);
269
[email protected]d3f09092012-02-16 01:52:17270#if defined(OS_MACOSX) || defined(OS_ANDROID)
271 // On Mac and Android, the select popups are rendered by the browser.
[email protected]53c607c2011-03-21 23:19:04272 WebKit::WebView::setUseExternalPopupMenus(true);
273#endif
274
[email protected]94f9a0f682009-06-15 18:30:30275 lazy_tls.Pointer()->Set(this);
[email protected]b3e83de2012-02-07 03:33:28276
[email protected]2c62b562009-01-27 19:04:50277#if defined(OS_WIN)
[email protected]bdef78b52009-04-16 19:31:34278 // If you are running plugins in this thread you need COM active but in
279 // the normal case you don't.
[email protected]00c39612010-03-06 02:53:28280 if (RenderProcessImpl::InProcessPlugins())
[email protected]1a771262011-10-31 09:11:12281 initialize_com_.reset(new base::win::ScopedCOMInitializer());
[email protected]2c62b562009-01-27 19:04:50282#endif
initial.commit09911bf2008-07-26 23:55:29283
[email protected]06c694d2012-02-01 22:26:16284 // Register this object as the main thread.
285 ChildProcess::current()->set_main_thread(this);
286
[email protected]31f87132010-04-21 23:36:21287 // In single process the single process is all there is.
[email protected]80fc08c52010-03-09 07:43:50288 suspend_webkit_shared_timer_ = true;
289 notify_webkit_of_modal_loop_ = true;
[email protected]bee16aab2009-08-26 15:55:03290 widget_count_ = 0;
291 hidden_widget_count_ = 0;
[email protected]6593ae12011-11-14 12:09:44292 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs;
[email protected]1784b2f2011-11-24 10:53:48293 idle_notifications_to_skip_ = 0;
[email protected]2db58cf92011-12-01 21:39:01294 compositor_initialized_ = false;
[email protected]8d86fce2009-02-26 23:37:55295
[email protected]526476902011-10-06 20:34:06296 appcache_dispatcher_.reset(new AppCacheDispatcher(Get()));
[email protected]1910fe82012-05-10 00:04:10297 dom_storage_dispatcher_.reset(new DomStorageDispatcher());
[email protected]a9bbd0ee2012-04-13 02:16:08298 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher());
[email protected]dd9241932010-02-24 19:23:13299
[email protected]cb25aa12012-08-07 19:13:43300 browser_plugin_registry_.reset(new content::old::BrowserPluginRegistry());
[email protected]468e4902012-05-23 01:49:31301 browser_plugin_channel_manager_.reset(
[email protected]cb25aa12012-08-07 19:13:43302 new content::old::BrowserPluginChannelManager());
[email protected]468e4902012-05-23 01:49:31303 AddObserver(browser_plugin_channel_manager_.get());
304
[email protected]d8cd8372012-03-09 10:49:51305 media_stream_center_ = NULL;
306
[email protected]017022b2009-07-27 23:06:34307 db_message_filter_ = new DBMessageFilter();
308 AddFilter(db_message_filter_.get());
[email protected]dd9241932010-02-24 19:23:13309
[email protected]4761cf12012-09-12 10:37:55310#if defined(ENABLE_WEBRTC)
311 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(
312 GetIOMessageLoopProxy());
313 AddFilter(p2p_socket_dispatcher_);
314#endif // defined(ENABLE_WEBRTC)
[email protected]80b161a2011-06-27 17:42:11315 vc_manager_ = new VideoCaptureImplManager();
316 AddFilter(vc_manager_->video_capture_message_filter());
[email protected]e25f4d72011-06-08 20:58:46317
[email protected]f7eb0a392011-07-12 10:19:51318 audio_input_message_filter_ = new AudioInputMessageFilter();
319 AddFilter(audio_input_message_filter_.get());
320
321 audio_message_filter_ = new AudioMessageFilter();
322 AddFilter(audio_message_filter_.get());
323
[email protected]31bfae72011-12-16 02:04:38324 AddFilter(new IndexedDBMessageFilter);
325
[email protected]8d97ade2011-04-14 18:17:08326 content::GetContentClient()->renderer()->RenderThreadStarted();
[email protected]6779aa12011-03-29 17:32:24327
[email protected]302fe422012-06-11 14:49:11328 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
[email protected]e54ab492012-06-12 19:40:01329 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking))
330 RegisterExtension(content::GpuBenchmarkingExtension::Get());
331
[email protected]fe476b02012-08-13 21:21:38332 context_lost_cb_.reset(new GpuVDAContextLostCallback());
333
[email protected]433df472012-03-07 20:33:39334 // Note that under Linux, the media library will normally already have
335 // been initialized by the Zygote before this instance became a Renderer.
336 FilePath media_path;
337 PathService::Get(content::DIR_MEDIA_LIBS, &media_path);
338 if (!media_path.empty())
339 media::InitializeMediaLibrary(media_path);
340
[email protected]f1a29a02011-10-06 23:08:44341 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
initial.commit09911bf2008-07-26 23:55:29342}
343
[email protected]f1a29a02011-10-06 23:08:44344RenderThreadImpl::~RenderThreadImpl() {
[email protected]1223d6ef2011-03-28 16:47:50345 FOR_EACH_OBSERVER(
346 RenderProcessObserver, observers_, OnRenderProcessShutdown());
347
[email protected]12cbfda32010-01-30 01:04:25348 // Wait for all databases to be closed.
[email protected]2b437e232010-04-02 01:30:08349 if (web_database_observer_impl_.get())
350 web_database_observer_impl_->WaitForAllDatabasesToClose();
[email protected]12cbfda32010-01-30 01:04:25351
[email protected]8d86fce2009-02-26 23:37:55352 // Shutdown in reverse of the initialization order.
[email protected]b146d6d2012-09-11 10:20:05353 if (devtools_agent_message_filter_.get()) {
354 RemoveFilter(devtools_agent_message_filter_.get());
355 devtools_agent_message_filter_ = NULL;
356 }
[email protected]82622452011-07-22 09:57:20357
[email protected]f7eb0a392011-07-12 10:19:51358 RemoveFilter(audio_input_message_filter_.get());
359 audio_input_message_filter_ = NULL;
360
361 RemoveFilter(audio_message_filter_.get());
362 audio_message_filter_ = NULL;
363
[email protected]80b161a2011-06-27 17:42:11364 RemoveFilter(vc_manager_->video_capture_message_filter());
365
[email protected]017022b2009-07-27 23:06:34366 RemoveFilter(db_message_filter_.get());
367 db_message_filter_ = NULL;
[email protected]12cbfda32010-01-30 01:04:25368
[email protected]c6a7b862010-08-20 22:19:38369 // Shutdown the file thread if it's running.
370 if (file_thread_.get())
371 file_thread_->Stop();
372
[email protected]23d2b7e2012-08-14 00:34:09373 if (compositor_output_surface_filter_.get()) {
374 RemoveFilter(compositor_output_surface_filter_.get());
375 compositor_output_surface_filter_ = NULL;
376 }
[email protected]1842fe22012-08-13 23:24:35377
[email protected]2db58cf92011-12-01 21:39:01378 if (compositor_initialized_) {
[email protected]cd7ce3be2012-09-10 05:19:41379 WebKit::Platform::current()->compositorSupport()->shutdown();
[email protected]2db58cf92011-12-01 21:39:01380 compositor_initialized_ = false;
381 }
[email protected]a9fb30aa2011-10-06 06:58:46382 if (compositor_thread_.get()) {
383 RemoveFilter(compositor_thread_->GetMessageFilter());
384 compositor_thread_.reset();
385 }
386
[email protected]8d6cba42011-09-02 10:05:19387 if (webkit_platform_support_.get())
[email protected]9291ed12009-07-23 17:33:22388 WebKit::shutdown();
[email protected]9291ed12009-07-23 17:33:22389
[email protected]94f9a0f682009-06-15 18:30:30390 lazy_tls.Pointer()->Set(NULL);
[email protected]8fd8de92008-08-12 23:50:30391
[email protected]8d86fce2009-02-26 23:37:55392 // TODO(port)
[email protected]2c62b562009-01-27 19:04:50393#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29394 // Clean up plugin channels before this thread goes away.
[email protected]099587b72011-09-20 00:40:50395 NPChannelBase::CleanupChannels();
[email protected]2c62b562009-01-27 19:04:50396#endif
initial.commit09911bf2008-07-26 23:55:29397}
398
[email protected]f1a29a02011-10-06 23:08:44399bool RenderThreadImpl::Send(IPC::Message* msg) {
[email protected]f23d4da92010-11-24 21:36:14400 // Certain synchronous messages cannot always be processed synchronously by
401 // the browser, e.g., Chrome frame communicating with the embedding browser.
[email protected]80fc08c52010-03-09 07:43:50402 // This could cause a complete hang of Chrome if a windowed plug-in is trying
403 // to communicate with the renderer thread since the browser's UI thread
404 // could be stuck (within a Windows API call) trying to synchronously
405 // communicate with the plug-in. The remedy is to pump messages on this
[email protected]f23d4da92010-11-24 21:36:14406 // thread while the browser is processing this request. This creates an
407 // opportunity for re-entrancy into WebKit, so we need to take care to disable
408 // callbacks, timers, and pending network loads that could trigger such
409 // callbacks.
[email protected]38b592902011-04-16 02:08:42410 bool pumping_events = false;
[email protected]80fc08c52010-03-09 07:43:50411 if (msg->is_sync()) {
412 if (msg->is_caller_pumping_messages()) {
413 pumping_events = true;
414 } else {
[email protected]38b592902011-04-16 02:08:42415 if ((msg->type() == ViewHostMsg_GetCookies::ID ||
416 msg->type() == ViewHostMsg_GetRawCookies::ID ||
417 msg->type() == ViewHostMsg_CookiesEnabled::ID) &&
418 content::GetContentClient()->renderer()->
419 ShouldPumpEventsDuringCookieMessage()) {
420 pumping_events = true;
[email protected]80fc08c52010-03-09 07:43:50421 }
422 }
[email protected]c1f50aa2010-02-18 03:46:57423 }
424
[email protected]80fc08c52010-03-09 07:43:50425 bool suspend_webkit_shared_timer = true; // default value
426 std::swap(suspend_webkit_shared_timer, suspend_webkit_shared_timer_);
[email protected]c1f50aa2010-02-18 03:46:57427
[email protected]80fc08c52010-03-09 07:43:50428 bool notify_webkit_of_modal_loop = true; // default value
429 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_);
430
431 gfx::NativeViewId host_window = 0;
[email protected]c1f50aa2010-02-18 03:46:57432
433 if (pumping_events) {
[email protected]80fc08c52010-03-09 07:43:50434 if (suspend_webkit_shared_timer)
[email protected]8d6cba42011-09-02 10:05:19435 webkit_platform_support_->SuspendSharedTimer();
[email protected]c1f50aa2010-02-18 03:46:57436
[email protected]39065d012010-07-09 11:22:46437 if (notify_webkit_of_modal_loop)
[email protected]c1f50aa2010-02-18 03:46:57438 WebView::willEnterModalLoop();
[email protected]c1f50aa2010-02-18 03:46:57439
[email protected]80fc08c52010-03-09 07:43:50440 RenderWidget* widget =
441 static_cast<RenderWidget*>(ResolveRoute(msg->routing_id()));
442 if (widget) {
443 host_window = widget->host_window();
[email protected]c1f50aa2010-02-18 03:46:57444 PluginChannelHost::Broadcast(
445 new PluginMsg_SignalModalDialogEvent(host_window));
446 }
447 }
448
449 bool rv = ChildThread::Send(msg);
450
451 if (pumping_events) {
452 if (host_window) {
453 PluginChannelHost::Broadcast(
454 new PluginMsg_ResetModalDialogEvent(host_window));
455 }
456
[email protected]39065d012010-07-09 11:22:46457 if (notify_webkit_of_modal_loop)
[email protected]c1f50aa2010-02-18 03:46:57458 WebView::didExitModalLoop();
[email protected]c1f50aa2010-02-18 03:46:57459
[email protected]80fc08c52010-03-09 07:43:50460 if (suspend_webkit_shared_timer)
[email protected]8d6cba42011-09-02 10:05:19461 webkit_platform_support_->ResumeSharedTimer();
[email protected]c1f50aa2010-02-18 03:46:57462 }
463
464 return rv;
465}
466
[email protected]f1a29a02011-10-06 23:08:44467MessageLoop* RenderThreadImpl::GetMessageLoop() {
[email protected]526476902011-10-06 20:34:06468 return message_loop();
469}
470
[email protected]f1a29a02011-10-06 23:08:44471IPC::SyncChannel* RenderThreadImpl::GetChannel() {
[email protected]526476902011-10-06 20:34:06472 return channel();
473}
474
[email protected]f1a29a02011-10-06 23:08:44475std::string RenderThreadImpl::GetLocale() {
[email protected]526476902011-10-06 20:34:06476 // The browser process should have passed the locale to the renderer via the
477 // --lang command line flag. In single process mode, this will return the
478 // wrong value. TODO(tc): Fix this for single process mode.
479 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
480 const std::string& lang =
481 parsed_command_line.GetSwitchValueASCII(switches::kLang);
482 DCHECK(!lang.empty() ||
483 (!parsed_command_line.HasSwitch(switches::kRendererProcess) &&
484 !parsed_command_line.HasSwitch(switches::kPluginProcess)));
485 return lang;
486}
487
[email protected]07bb6332012-01-21 01:07:57488IPC::SyncMessageFilter* RenderThreadImpl::GetSyncMessageFilter() {
489 return sync_message_filter();
490}
491
[email protected]96191d52012-05-17 01:37:11492scoped_refptr<base::MessageLoopProxy>
493 RenderThreadImpl::GetIOMessageLoopProxy() {
494 return ChildProcess::current()->io_message_loop_proxy();
495}
496
[email protected]c47317e2012-06-20 22:35:31497void RenderThreadImpl::AddRoute(int32 routing_id, IPC::Listener* listener) {
[email protected]c1f50aa2010-02-18 03:46:57498 widget_count_++;
499 return ChildThread::AddRoute(routing_id, listener);
500}
501
[email protected]f1a29a02011-10-06 23:08:44502void RenderThreadImpl::RemoveRoute(int32 routing_id) {
[email protected]c1f50aa2010-02-18 03:46:57503 widget_count_--;
504 return ChildThread::RemoveRoute(routing_id);
505}
506
[email protected]77fc9b92011-10-15 16:20:37507int RenderThreadImpl::GenerateRoutingID() {
508 int routing_id = MSG_ROUTING_NONE;
509 Send(new ViewHostMsg_GenerateRoutingID(&routing_id));
510 return routing_id;
511}
512
[email protected]f1a29a02011-10-06 23:08:44513void RenderThreadImpl::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
[email protected]42f1d7822009-07-23 18:17:55514 channel()->AddFilter(filter);
515}
516
[email protected]f1a29a02011-10-06 23:08:44517void RenderThreadImpl::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
[email protected]42f1d7822009-07-23 18:17:55518 channel()->RemoveFilter(filter);
519}
520
[email protected]f1a29a02011-10-06 23:08:44521void RenderThreadImpl::SetOutgoingMessageFilter(
[email protected]526476902011-10-06 20:34:06522 IPC::ChannelProxy::OutgoingMessageFilter* filter) {
523}
524
[email protected]f1a29a02011-10-06 23:08:44525void RenderThreadImpl::AddObserver(content::RenderProcessObserver* observer) {
[email protected]526476902011-10-06 20:34:06526 observers_.AddObserver(observer);
527}
528
[email protected]f1a29a02011-10-06 23:08:44529void RenderThreadImpl::RemoveObserver(
530 content::RenderProcessObserver* observer) {
[email protected]526476902011-10-06 20:34:06531 observers_.RemoveObserver(observer);
532}
533
[email protected]359dfa32011-10-12 01:10:15534void RenderThreadImpl::SetResourceDispatcherDelegate(
535 content::ResourceDispatcherDelegate* delegate) {
536 resource_dispatcher()->set_delegate(delegate);
537}
538
[email protected]f1a29a02011-10-06 23:08:44539void RenderThreadImpl::WidgetHidden() {
[email protected]bee16aab2009-08-26 15:55:03540 DCHECK(hidden_widget_count_ < widget_count_);
[email protected]4a3dab22009-11-11 17:36:50541 hidden_widget_count_++;
[email protected]6779aa12011-03-29 17:32:24542
543 if (!content::GetContentClient()->renderer()->
544 RunIdleHandlerWhenWidgetsHidden()) {
545 return;
546 }
547
548 if (widget_count_ && hidden_widget_count_ == widget_count_)
[email protected]6593ae12011-11-14 12:09:44549 ScheduleIdleHandler(kInitialIdleHandlerDelayMs);
[email protected]bee16aab2009-08-26 15:55:03550}
551
[email protected]f1a29a02011-10-06 23:08:44552void RenderThreadImpl::WidgetRestored() {
[email protected]61a9b2d82010-02-26 00:31:08553 DCHECK_GT(hidden_widget_count_, 0);
[email protected]bee16aab2009-08-26 15:55:03554 hidden_widget_count_--;
[email protected]6779aa12011-03-29 17:32:24555 if (!content::GetContentClient()->renderer()->
556 RunIdleHandlerWhenWidgetsHidden()) {
557 return;
558 }
[email protected]bee16aab2009-08-26 15:55:03559
[email protected]1784b2f2011-11-24 10:53:48560 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
[email protected]e4be2dd2010-12-14 00:44:39561}
562
[email protected]f1a29a02011-10-06 23:08:44563void RenderThreadImpl::EnsureWebKitInitialized() {
[email protected]8d6cba42011-09-02 10:05:19564 if (webkit_platform_support_.get())
[email protected]d1b8fccc2011-08-03 01:20:13565 return;
566
[email protected]8d6cba42011-09-02 10:05:19567 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl);
568 WebKit::initialize(webkit_platform_support_.get());
[email protected]d1b8fccc2011-08-03 01:20:13569
[email protected]cd7ce3be2012-09-10 05:19:41570 WebKit::WebCompositorSupport* compositor_support =
571 WebKit::Platform::current()->compositorSupport();
572 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
573 compositor_support->setAcceleratedAnimationEnabled(
574 !command_line.HasSwitch(switches::kDisableThreadedAnimation));
575 compositor_support->setPerTilePaintingEnabled(
576 command_line.HasSwitch(switches::kEnablePerTilePainting));
577 compositor_support->setPartialSwapEnabled(
578 command_line.HasSwitch(switches::kEnablePartialSwap));
[email protected]1c0c9bc2012-10-08 22:41:48579 compositor_support->setPageScalePinchZoomEnabled(
580 command_line.HasSwitch(switches::kEnablePinchInCompositor));
[email protected]cd7ce3be2012-09-10 05:19:41581
[email protected]3e407b42012-06-25 20:43:26582 // TODO(fsamuel): Guests don't currently support threaded compositing.
583 // This should go away with the new design of the browser plugin.
584 // The new design can be tracked at: http://crbug.com/134492.
585 bool is_guest = CommandLine::ForCurrentProcess()->HasSwitch(
586 switches::kGuestRenderer);
[email protected]b7c4f032012-08-07 16:38:56587 bool enable = content::IsThreadedCompositingEnabled() && !is_guest;
[email protected]72787e392012-03-23 05:55:43588 if (enable) {
[email protected]f3150172011-10-22 02:28:45589 compositor_thread_.reset(new CompositorThread(this));
590 AddFilter(compositor_thread_->GetMessageFilter());
[email protected]cd7ce3be2012-09-10 05:19:41591 compositor_support->initialize(compositor_thread_->GetWebThread());
[email protected]a458504b2012-07-23 19:57:06592 } else {
[email protected]cd7ce3be2012-09-10 05:19:41593 compositor_support->initialize(NULL);
[email protected]a458504b2012-07-23 19:57:06594 }
[email protected]2db58cf92011-12-01 21:39:01595 compositor_initialized_ = true;
[email protected]a9fb30aa2011-10-06 06:58:46596
[email protected]1842fe22012-08-13 23:24:35597 MessageLoop* output_surface_loop = enable ?
598 compositor_thread_->message_loop() :
599 MessageLoop::current();
600
601 compositor_output_surface_filter_ = CompositorOutputSurface::CreateFilter(
602 output_surface_loop->message_loop_proxy());
603 AddFilter(compositor_output_surface_filter_.get());
604
[email protected]d1b8fccc2011-08-03 01:20:13605 WebScriptController::enableV8SingleThreadMode();
606
[email protected]58436a12012-03-21 17:10:26607 RenderThreadImpl::RegisterSchemes();
608
[email protected]d1b8fccc2011-08-03 01:20:13609 webkit_glue::EnableWebCoreLogChannels(
610 command_line.GetSwitchValueASCII(switches::kWebCoreLogChannels));
611
[email protected]766a7082012-02-03 23:39:15612 if (CommandLine::ForCurrentProcess()->HasSwitch(
613 switches::kDomAutomationController)) {
614 base::StringPiece extension = content::GetContentClient()->GetDataResource(
[email protected]c49201a2012-05-24 11:04:57615 IDR_DOM_AUTOMATION_JS, ui::SCALE_FACTOR_NONE);
[email protected]766a7082012-02-03 23:39:15616 RegisterExtension(new v8::Extension(
617 "dom_automation.js", extension.data(), 0, NULL, extension.size()));
618 }
619
[email protected]fa1c17e42012-03-06 22:29:54620 web_database_observer_impl_.reset(
621 new WebDatabaseObserverImpl(sync_message_filter()));
[email protected]d1b8fccc2011-08-03 01:20:13622 WebKit::WebDatabase::setObserver(web_database_observer_impl_.get());
623
624 WebRuntimeFeatures::enableSockets(
625 !command_line.HasSwitch(switches::kDisableWebSockets));
626
627 WebRuntimeFeatures::enableDatabase(
628 !command_line.HasSwitch(switches::kDisableDatabases));
629
630 WebRuntimeFeatures::enableDataTransferItems(
631 !command_line.HasSwitch(switches::kDisableDataTransferItems));
632
633 WebRuntimeFeatures::enableApplicationCache(
634 !command_line.HasSwitch(switches::kDisableApplicationCache));
635
636 WebRuntimeFeatures::enableNotifications(
637 !command_line.HasSwitch(switches::kDisableDesktopNotifications));
638
639 WebRuntimeFeatures::enableLocalStorage(
640 !command_line.HasSwitch(switches::kDisableLocalStorage));
641 WebRuntimeFeatures::enableSessionStorage(
642 !command_line.HasSwitch(switches::kDisableSessionStorage));
643
[email protected]b3796c82012-01-19 08:34:33644 WebRuntimeFeatures::enableIndexedDatabase(true);
[email protected]d1b8fccc2011-08-03 01:20:13645
646 WebRuntimeFeatures::enableGeolocation(
647 !command_line.HasSwitch(switches::kDisableGeolocation));
648
[email protected]6aa03b32011-10-27 21:44:44649 WebKit::WebRuntimeFeatures::enableMediaSource(
[email protected]da43c082012-09-07 18:56:11650 !command_line.HasSwitch(switches::kDisableMediaSource));
[email protected]6aa03b32011-10-27 21:44:44651
[email protected]433df472012-03-07 20:33:39652 WebRuntimeFeatures::enableMediaPlayer(
653 media::IsMediaLibraryInitialized());
654
[email protected]7082fb942012-05-16 23:44:59655 WebKit::WebRuntimeFeatures::enableMediaStream(true);
[email protected]cdb609e72012-08-30 10:49:58656 WebKit::WebRuntimeFeatures::enablePeerConnection(true);
[email protected]78847572012-10-16 11:03:54657 WebKit::WebRuntimeFeatures::enableDeprecatedPeerConnection(
658 command_line.HasSwitch(switches::kEnableDeprecatedPeerConnection));
[email protected]8ea05a12012-05-02 09:17:47659
[email protected]efdc0282011-08-26 00:36:12660 WebKit::WebRuntimeFeatures::enableFullScreenAPI(
[email protected]5e5671a2011-09-08 02:12:21661 !command_line.HasSwitch(switches::kDisableFullScreen));
[email protected]efdc0282011-08-26 00:36:12662
[email protected]0ef60d02012-09-18 18:03:51663 WebKit::WebRuntimeFeatures::enablePointerLock(true);
[email protected]e4e68dbb2011-11-18 01:50:22664
[email protected]9f5b7822012-04-18 23:39:03665 WebKit::WebRuntimeFeatures::enableEncryptedMedia(
666 command_line.HasSwitch(switches::kEnableEncryptedMedia));
667
[email protected]634a3bd2012-07-26 04:49:01668#if defined(OS_ANDROID)
669 WebRuntimeFeatures::enableWebAudio(
670 command_line.HasSwitch(switches::kEnableWebAudio) &&
671 media::IsMediaLibraryInitialized());
672#else
[email protected]d1b8fccc2011-08-03 01:20:13673 WebRuntimeFeatures::enableWebAudio(
[email protected]6a1f9cf2012-05-24 21:23:45674 !command_line.HasSwitch(switches::kDisableWebAudio) &&
675 media::IsMediaLibraryInitialized());
[email protected]634a3bd2012-07-26 04:49:01676#endif
[email protected]d1b8fccc2011-08-03 01:20:13677
[email protected]223a31e42012-10-04 01:12:18678#if defined(OS_CHROMEOS)
679 WebRuntimeFeatures::enableTouch(true);
680#else
[email protected]18e9781a2012-02-28 05:27:53681 WebRuntimeFeatures::enableTouch(
682 command_line.HasSwitch(switches::kEnableTouchEvents));
[email protected]223a31e42012-10-04 01:12:18683#endif
[email protected]d1b8fccc2011-08-03 01:20:13684
685 WebRuntimeFeatures::enableDeviceMotion(
686 command_line.HasSwitch(switches::kEnableDeviceMotion));
687
688 WebRuntimeFeatures::enableDeviceOrientation(
689 !command_line.HasSwitch(switches::kDisableDeviceOrientation));
690
691 WebRuntimeFeatures::enableSpeechInput(
692 !command_line.HasSwitch(switches::kDisableSpeechInput));
693
[email protected]9b7b57d2012-03-21 13:17:48694 WebRuntimeFeatures::enableScriptedSpeech(
695 command_line.HasSwitch(switches::kEnableScriptedSpeech));
696
[email protected]d1b8fccc2011-08-03 01:20:13697 WebRuntimeFeatures::enableFileSystem(
698 !command_line.HasSwitch(switches::kDisableFileSystem));
699
700 WebRuntimeFeatures::enableJavaScriptI18NAPI(
701 !command_line.HasSwitch(switches::kDisableJavaScriptI18NAPI));
702
[email protected]d7a35b72012-05-17 15:59:57703 WebRuntimeFeatures::enableGamepad(true);
[email protected]0205fbf2011-11-30 21:51:36704
[email protected]d1b8fccc2011-08-03 01:20:13705 WebRuntimeFeatures::enableQuota(true);
706
[email protected]739d08d32012-10-12 07:38:14707 WebRuntimeFeatures::enableShadowDOM(true);
[email protected]d2edc6702012-01-30 09:13:16708
[email protected]4961218f2012-02-23 10:11:07709 WebRuntimeFeatures::enableStyleScoped(
[email protected]ff7b6dd2012-09-15 20:20:03710 command_line.HasSwitch(switches::kEnableExperimentalWebKitFeatures));
[email protected]4961218f2012-02-23 10:11:07711
[email protected]c76f58ba2012-08-11 01:11:57712 WebRuntimeFeatures::enableCSSExclusions(
[email protected]ff7b6dd2012-09-15 20:20:03713 command_line.HasSwitch(switches::kEnableExperimentalWebKitFeatures));
[email protected]c76f58ba2012-08-11 01:11:57714
[email protected]d1b8fccc2011-08-03 01:20:13715 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized());
[email protected]1784b2f2011-11-24 10:53:48716
[email protected]b146d6d2012-09-11 10:20:05717 devtools_agent_message_filter_ = new DevToolsAgentFilter();
718 AddFilter(devtools_agent_message_filter_.get());
719
[email protected]1784b2f2011-11-24 10:53:48720 if (content::GetContentClient()->renderer()->
721 RunIdleHandlerWhenWidgetsHidden()) {
722 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
723 }
[email protected]d1b8fccc2011-08-03 01:20:13724}
725
[email protected]58436a12012-03-21 17:10:26726void RenderThreadImpl::RegisterSchemes() {
727 // swappedout: pages should not be accessible, and should also
728 // be treated as empty documents that can commit synchronously.
729 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme));
730 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme);
731 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme);
732}
733
[email protected]f1a29a02011-10-06 23:08:44734void RenderThreadImpl::RecordUserMetrics(const std::string& action) {
[email protected]526476902011-10-06 20:34:06735 Send(new ViewHostMsg_UserMetricsRecordAction(action));
736}
737
[email protected]00614a82011-10-07 22:39:31738base::SharedMemoryHandle RenderThreadImpl::HostAllocateSharedMemoryBuffer(
[email protected]bdae9812011-10-15 00:33:03739 uint32 buffer_size) {
[email protected]cb62dc12012-10-13 00:26:44740 base::SharedMemoryHandle mem_handle = base::SharedMemoryHandle();
[email protected]bdae9812011-10-15 00:33:03741 Send(new ChildProcessHostMsg_SyncAllocateSharedMemory(
742 buffer_size, &mem_handle));
[email protected]00614a82011-10-07 22:39:31743 return mem_handle;
744}
745
[email protected]f1a29a02011-10-06 23:08:44746void RenderThreadImpl::RegisterExtension(v8::Extension* extension) {
[email protected]526476902011-10-06 20:34:06747 WebScriptController::registerExtension(extension);
[email protected]526476902011-10-06 20:34:06748}
749
[email protected]6593ae12011-11-14 12:09:44750void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) {
751 idle_notification_delay_in_ms_ = initial_delay_ms;
[email protected]526476902011-10-06 20:34:06752 idle_timer_.Stop();
753 idle_timer_.Start(FROM_HERE,
[email protected]6593ae12011-11-14 12:09:44754 base::TimeDelta::FromMilliseconds(initial_delay_ms),
[email protected]f1a29a02011-10-06 23:08:44755 this, &RenderThreadImpl::IdleHandler);
[email protected]526476902011-10-06 20:34:06756}
757
[email protected]f1a29a02011-10-06 23:08:44758void RenderThreadImpl::IdleHandler() {
[email protected]1784b2f2011-11-24 10:53:48759 bool run_in_foreground_tab = (widget_count_ > hidden_widget_count_) &&
760 content::GetContentClient()->renderer()->
761 RunIdleHandlerWhenWidgetsHidden();
762 if (run_in_foreground_tab) {
763 IdleHandlerInForegroundTab();
764 return;
765 }
[email protected]237a14852012-04-28 02:56:38766
767 base::allocator::ReleaseFreeMemory();
[email protected]526476902011-10-06 20:34:06768
769 v8::V8::IdleNotification();
770
771 // Schedule next invocation.
[email protected]6593ae12011-11-14 12:09:44772 // Dampen the delay using the algorithm (if delay is in seconds):
[email protected]526476902011-10-06 20:34:06773 // delay = delay + 1 / (delay + 2)
774 // Using floor(delay) has a dampening effect such as:
775 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
[email protected]6593ae12011-11-14 12:09:44776 // If the delay is in milliseconds, the above formula is equivalent to:
777 // delay_ms / 1000 = delay_ms / 1000 + 1 / (delay_ms / 1000 + 2)
778 // which is equivalent to
779 // delay_ms = delay_ms + 1000*1000 / (delay_ms + 2000).
780 // Note that idle_notification_delay_in_ms_ would be reset to
781 // kInitialIdleHandlerDelayMs in RenderThreadImpl::WidgetHidden.
782 ScheduleIdleHandler(idle_notification_delay_in_ms_ +
783 1000000 / (idle_notification_delay_in_ms_ + 2000));
[email protected]526476902011-10-06 20:34:06784
785 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification());
786}
787
[email protected]1784b2f2011-11-24 10:53:48788void RenderThreadImpl::IdleHandlerInForegroundTab() {
789 // Increase the delay in the same way as in IdleHandler,
790 // but make it periodic by reseting it once it is too big.
791 int64 new_delay_ms = idle_notification_delay_in_ms_ +
792 1000000 / (idle_notification_delay_in_ms_ + 2000);
793 if (new_delay_ms >= kLongIdleHandlerDelayMs)
794 new_delay_ms = kShortIdleHandlerDelayMs;
795
[email protected]1784b2f2011-11-24 10:53:48796 if (idle_notifications_to_skip_ > 0) {
797 idle_notifications_to_skip_--;
[email protected]7e967f82011-12-01 09:35:14798 } else {
[email protected]a47105c832011-12-07 17:24:30799 int cpu_usage = 0;
[email protected]7e967f82011-12-01 09:35:14800 Send(new ViewHostMsg_GetCPUUsage(&cpu_usage));
[email protected]1393c4a2012-02-07 10:12:58801 // Idle notification hint roughly specifies the expected duration of the
802 // idle pause. We set it proportional to the idle timer delay.
803 int idle_hint = static_cast<int>(new_delay_ms / 10);
[email protected]d7e59252012-03-06 22:26:02804 if (cpu_usage < kIdleCPUUsageThresholdInPercents) {
[email protected]237a14852012-04-28 02:56:38805 base::allocator::ReleaseFreeMemory();
[email protected]d7e59252012-03-06 22:26:02806 if (v8::V8::IdleNotification(idle_hint)) {
807 // V8 finished collecting garbage.
808 new_delay_ms = kLongIdleHandlerDelayMs;
809 }
[email protected]1784b2f2011-11-24 10:53:48810 }
811 }
[email protected]1784b2f2011-11-24 10:53:48812 ScheduleIdleHandler(new_delay_ms);
813}
814
[email protected]6593ae12011-11-14 12:09:44815int64 RenderThreadImpl::GetIdleNotificationDelayInMs() const {
816 return idle_notification_delay_in_ms_;
[email protected]526476902011-10-06 20:34:06817}
818
[email protected]6593ae12011-11-14 12:09:44819void RenderThreadImpl::SetIdleNotificationDelayInMs(
820 int64 idle_notification_delay_in_ms) {
821 idle_notification_delay_in_ms_ = idle_notification_delay_in_ms;
[email protected]4a7d6392011-09-19 20:55:08822}
823
[email protected]a1a7ff32012-07-19 14:03:51824void RenderThreadImpl::ToggleWebKitSharedTimer(bool suspend) {
825 if (suspend_webkit_shared_timer_) {
826 EnsureWebKitInitialized();
827 if (suspend) {
828 webkit_platform_support_->SuspendSharedTimer();
829 } else {
830 webkit_platform_support_->ResumeSharedTimer();
831 }
832 }
833}
834
835void RenderThreadImpl::UpdateHistograms(int sequence_number) {
836 child_histogram_message_filter()->SendHistograms(sequence_number);
837}
838
[email protected]1784b2f2011-11-24 10:53:48839void RenderThreadImpl::PostponeIdleNotification() {
840 idle_notifications_to_skip_ = 2;
841}
842
[email protected]fe476b02012-08-13 21:21:38843/* static */
844void RenderThreadImpl::OnGpuVDAContextLoss() {
845 RenderThreadImpl* self = RenderThreadImpl::current();
846 DCHECK(self);
847 if (!self->gpu_vda_context3d_.get())
848 return;
849 if (self->compositor_thread()) {
850 self->compositor_thread()->GetWebThread()->message_loop()->DeleteSoon(
851 FROM_HERE, self->gpu_vda_context3d_.release());
852 } else {
853 self->gpu_vda_context3d_.reset();
[email protected]3b2afc32012-06-18 21:31:16854 }
[email protected]fe476b02012-08-13 21:21:38855}
856
857WebGraphicsContext3DCommandBufferImpl*
858RenderThreadImpl::GetGpuVDAContext3D() {
[email protected]3b2afc32012-06-18 21:31:16859 if (!gpu_vda_context3d_.get()) {
860 gpu_vda_context3d_.reset(
861 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
[email protected]d1a9e062012-07-13 00:45:14862 this, WebKit::WebGraphicsContext3D::Attributes(),
863 GURL("chrome://gpu/RenderThreadImpl::GetGpuVDAContext3D")));
[email protected]fde3e2f2012-08-14 06:51:37864 if (gpu_vda_context3d_.get())
865 gpu_vda_context3d_->setContextLostCallback(context_lost_cb_.get());
[email protected]3b2afc32012-06-18 21:31:16866 }
[email protected]fe476b02012-08-13 21:21:38867 return gpu_vda_context3d_.get();
[email protected]3b2afc32012-06-18 21:31:16868}
869
[email protected]3958e972012-07-17 00:25:41870content::AudioRendererMixerManager*
871RenderThreadImpl::GetAudioRendererMixerManager() {
872 if (!audio_renderer_mixer_manager_.get()) {
873 audio_renderer_mixer_manager_.reset(new AudioRendererMixerManager(
874 audio_hardware::GetOutputSampleRate(),
875 audio_hardware::GetOutputBufferSize()));
876 }
877
878 return audio_renderer_mixer_manager_.get();
879}
880
[email protected]4a7d6392011-09-19 20:55:08881#if defined(OS_WIN)
[email protected]f1a29a02011-10-06 23:08:44882void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) {
[email protected]526476902011-10-06 20:34:06883 Send(new ChildProcessHostMsg_PreCacheFont(log_font));
[email protected]79fff822011-09-20 03:33:21884}
885
[email protected]f1a29a02011-10-06 23:08:44886void RenderThreadImpl::ReleaseCachedFonts() {
[email protected]526476902011-10-06 20:34:06887 Send(new ChildProcessHostMsg_ReleaseCachedFonts());
[email protected]4a7d6392011-09-19 20:55:08888}
[email protected]526476902011-10-06 20:34:06889
[email protected]4a7d6392011-09-19 20:55:08890#endif // OS_WIN
891
[email protected]988aacf2012-02-12 18:10:03892bool RenderThreadImpl::IsWebFrameValid(WebKit::WebFrame* web_frame) {
893 if (!web_frame)
[email protected]4761cf12012-09-12 10:37:55894 return false; // We must be shutting down.
[email protected]988aacf2012-02-12 18:10:03895
896 RenderViewImpl* render_view = RenderViewImpl::FromWebView(web_frame->view());
897 if (!render_view)
[email protected]4761cf12012-09-12 10:37:55898 return false; // We must be shutting down.
[email protected]988aacf2012-02-12 18:10:03899
900 return true;
901}
902
[email protected]b3e83de2012-02-07 03:33:28903bool RenderThreadImpl::IsMainThread() {
904 return !!current();
905}
906
907bool RenderThreadImpl::IsIOThread() {
908 return MessageLoop::current() == ChildProcess::current()->io_message_loop();
909}
910
911MessageLoop* RenderThreadImpl::GetMainLoop() {
912 return message_loop();
913}
[email protected]5b040e592012-02-10 02:56:10914
915scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() {
[email protected]b3e83de2012-02-07 03:33:28916 return ChildProcess::current()->io_message_loop_proxy();
917}
918
919base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() {
920 return ChildProcess::current()->GetShutDownEvent();
921}
922
923scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory(
924 uint32 size) {
[email protected]b3e83de2012-02-07 03:33:28925 base::SharedMemoryHandle handle;
[email protected]8b10b332012-02-29 21:02:14926 bool success;
927 IPC::Message* message =
928 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle);
929
930 // Allow calling this from the compositor thread.
931 if (MessageLoop::current() == message_loop())
932 success = ChildThread::Send(message);
933 else
934 success = sync_message_filter()->Send(message);
935
936 if (!success)
[email protected]b3e83de2012-02-07 03:33:28937 return scoped_ptr<base::SharedMemory>();
[email protected]8b10b332012-02-29 21:02:14938
[email protected]b3e83de2012-02-07 03:33:28939 if (!base::SharedMemory::IsHandleValid(handle))
940 return scoped_ptr<base::SharedMemory>();
941 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false));
942}
943
944int32 RenderThreadImpl::CreateViewCommandBuffer(
945 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) {
[email protected]d13f35d2012-05-18 02:28:15946 TRACE_EVENT1("gpu",
947 "RenderThreadImpl::CreateViewCommandBuffer",
948 "surface_id",
949 surface_id);
950
[email protected]b3e83de2012-02-07 03:33:28951 int32 route_id = MSG_ROUTING_NONE;
[email protected]8b10b332012-02-29 21:02:14952 IPC::Message* message = new GpuHostMsg_CreateViewCommandBuffer(
[email protected]b3e83de2012-02-07 03:33:28953 surface_id,
954 init_params,
[email protected]8b10b332012-02-29 21:02:14955 &route_id);
956
957 // Allow calling this from the compositor thread.
958 if (MessageLoop::current() == message_loop())
959 ChildThread::Send(message);
960 else
961 sync_message_filter()->Send(message);
962
[email protected]b3e83de2012-02-07 03:33:28963 return route_id;
964}
965
[email protected]f1a29a02011-10-06 23:08:44966void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
[email protected]526476902011-10-06 20:34:06967 suspend_webkit_shared_timer_ = false;
968}
969
[email protected]f1a29a02011-10-06 23:08:44970void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
[email protected]526476902011-10-06 20:34:06971 notify_webkit_of_modal_loop_ = false;
972}
973
[email protected]4e2a25a2012-01-27 00:42:08974void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& host,
[email protected]f1a29a02011-10-06 23:08:44975 double zoom_level) {
[email protected]4e2a25a2012-01-27 00:42:08976 RenderViewZoomer zoomer(host, zoom_level);
[email protected]310ebd6302011-10-10 19:06:28977 content::RenderView::ForEach(&zoomer);
[email protected]526476902011-10-06 20:34:06978}
979
[email protected]f1a29a02011-10-06 23:08:44980bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
[email protected]1223d6ef2011-03-28 16:47:50981 ObserverListBase<RenderProcessObserver>::Iterator it(observers_);
982 RenderProcessObserver* observer;
983 while ((observer = it.GetNext()) != NULL) {
984 if (observer->OnControlMessageReceived(msg))
985 return true;
986 }
987
[email protected]70c19a932010-05-14 12:59:11988 // Some messages are handled by delegates.
[email protected]1910fe82012-05-10 00:04:10989 if (appcache_dispatcher_->OnMessageReceived(msg) ||
990 dom_storage_dispatcher_->OnMessageReceived(msg)) {
[email protected]a95986a82010-12-24 06:19:28991 return true;
[email protected]1910fe82012-05-10 00:04:10992 }
[email protected]1edc16b82009-04-07 17:45:54993
[email protected]a95986a82010-12-24 06:19:28994 bool handled = true;
[email protected]f1a29a02011-10-06 23:08:44995 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg)
[email protected]9d797f32010-04-23 07:17:54996 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL,
997 OnSetZoomLevelForCurrentURL)
[email protected]b9ab10c2009-08-07 18:09:55998 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors)
[email protected]8930d472009-02-21 08:05:28999 // TODO(port): removed from render_messages_internal.h;
1000 // is there a new non-windows message I should add here?
1001 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
[email protected]3e267192011-03-25 01:55:451002 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
[email protected]6eac57a2011-07-12 21:15:091003 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged)
[email protected]b69934e2011-10-29 02:51:521004 IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData)
[email protected]a95986a82010-12-24 06:19:281005 IPC_MESSAGE_UNHANDLED(handled = false)
[email protected]8930d472009-02-21 08:05:281006 IPC_END_MESSAGE_MAP()
[email protected]a95986a82010-12-24 06:19:281007 return handled;
initial.commit09911bf2008-07-26 23:55:291008}
1009
[email protected]b9ab10c2009-08-07 18:09:551010// Called when to register CSS Color name->system color mappings.
1011// We update the colors one by one and then tell WebKit to refresh all render
1012// views.
[email protected]f1a29a02011-10-06 23:08:441013void RenderThreadImpl::OnSetCSSColors(
[email protected]b9ab10c2009-08-07 18:09:551014 const std::vector<CSSColors::CSSColorMapping>& colors) {
[email protected]f5e4b9bf2009-10-08 00:59:591015 EnsureWebKitInitialized();
[email protected]b9ab10c2009-08-07 18:09:551016 size_t num_colors = colors.size();
1017 scoped_array<WebKit::WebColorName> color_names(
1018 new WebKit::WebColorName[num_colors]);
1019 scoped_array<WebKit::WebColor> web_colors(new WebKit::WebColor[num_colors]);
1020 size_t i = 0;
1021 for (std::vector<CSSColors::CSSColorMapping>::const_iterator it =
1022 colors.begin();
1023 it != colors.end();
1024 ++it, ++i) {
1025 color_names[i] = it->first;
1026 web_colors[i] = it->second;
1027 }
1028 WebKit::setNamedColors(color_names.get(), web_colors.get(), num_colors);
1029}
1030
[email protected]f1a29a02011-10-06 23:08:441031void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) {
[email protected]90a3fbb12009-02-28 01:13:471032 EnsureWebKitInitialized();
[email protected]be645db2009-02-06 20:36:331033 // When bringing in render_view, also bring in webkit's glue and jsbindings.
[email protected]468e4902012-05-23 01:49:311034 if (!params.embedder_channel_name.empty()) {
1035 browser_plugin_channel_manager()->CreateRenderView(params);
1036 } else {
1037 RenderViewImpl::Create(
1038 params.parent_window,
1039 params.opener_route_id,
1040 params.renderer_preferences,
1041 params.web_preferences,
1042 new SharedRenderViewCounter(0),
1043 params.view_id,
1044 params.surface_id,
1045 params.session_storage_namespace_id,
1046 params.frame_name,
1047 false,
1048 params.swapped_out,
1049 params.next_page_id,
[email protected]842f10652012-06-06 01:54:041050 params.screen_info,
[email protected]468e4902012-05-23 01:49:311051 NULL,
1052 params.accessibility_mode);
1053 }
[email protected]7f874dec2009-02-06 01:48:271054}
[email protected]4274e582009-01-27 22:09:561055
[email protected]f1a29a02011-10-06 23:08:441056GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync(
[email protected]7f3a2cf2011-04-06 00:10:501057 content::CauseForGpuLaunch cause_for_gpu_launch) {
[email protected]d13f35d2012-05-18 02:28:151058 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync");
1059
[email protected]6217d392010-03-25 22:08:351060 if (gpu_channel_.get()) {
[email protected]1082b1d2010-03-30 00:31:221061 // Do nothing if we already have a GPU channel or are already
1062 // establishing one.
[email protected]e09cee42010-11-09 01:50:081063 if (gpu_channel_->state() == GpuChannelHost::kUnconnected ||
1064 gpu_channel_->state() == GpuChannelHost::kConnected)
[email protected]b42a9f62011-06-08 20:36:041065 return GetGpuChannel();
[email protected]6217d392010-03-25 22:08:351066
1067 // Recreate the channel if it has been lost.
[email protected]894e8fc2012-02-24 13:29:501068 gpu_channel_ = NULL;
[email protected]6217d392010-03-25 22:08:351069 }
1070
[email protected]6217d392010-03-25 22:08:351071 // Ask the browser for the channel name.
[email protected]894e8fc2012-02-24 13:29:501072 int client_id = 0;
[email protected]b42a9f62011-06-08 20:36:041073 IPC::ChannelHandle channel_handle;
[email protected]a80f5ece2011-10-20 23:56:551074 content::GPUInfo gpu_info;
[email protected]b42a9f62011-06-08 20:36:041075 if (!Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch,
[email protected]894e8fc2012-02-24 13:29:501076 &client_id,
[email protected]b42a9f62011-06-08 20:36:041077 &channel_handle,
[email protected]b42a9f62011-06-08 20:36:041078 &gpu_info)) ||
[email protected]8bc550e2012-02-07 11:05:561079#if defined(OS_POSIX)
1080 channel_handle.socket.fd == -1 ||
1081#endif
[email protected]cd0bd792012-04-14 00:52:161082 channel_handle.name.empty()) {
[email protected]b42a9f62011-06-08 20:36:041083 // Otherwise cancel the connection.
1084 gpu_channel_ = NULL;
1085 return NULL;
1086 }
[email protected]6217d392010-03-25 22:08:351087
[email protected]03dc8882012-03-08 23:46:291088 gpu_channel_ = new GpuChannelHost(this, 0, client_id);
[email protected]b42a9f62011-06-08 20:36:041089 gpu_channel_->set_gpu_info(gpu_info);
1090 content::GetContentClient()->SetGpuInfo(gpu_info);
1091
1092 // Connect to the GPU process if a channel name was received.
[email protected]cd0bd792012-04-14 00:52:161093 gpu_channel_->Connect(channel_handle);
[email protected]b42a9f62011-06-08 20:36:041094
[email protected]f9a2b2fe2010-07-15 21:13:231095 return GetGpuChannel();
[email protected]3bf4d532010-03-27 00:23:341096}
1097
[email protected]d8cd8372012-03-09 10:49:511098WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter(
1099 WebKit::WebMediaStreamCenterClient* client) {
1100#if defined(ENABLE_WEBRTC)
[email protected]d8cd8372012-03-09 10:49:511101 if (!media_stream_center_)
[email protected]6ee10bd2012-09-13 09:01:531102 media_stream_center_ = new content::MediaStreamCenter(
1103 client, GetMediaStreamDependencyFactory());
[email protected]d8cd8372012-03-09 10:49:511104#endif
1105 return media_stream_center_;
1106}
1107
[email protected]6ee10bd2012-09-13 09:01:531108MediaStreamDependencyFactory*
1109RenderThreadImpl::GetMediaStreamDependencyFactory() {
1110#if defined(ENABLE_WEBRTC)
1111 if (!media_stream_factory_.get()) {
1112 media_stream_factory_.reset(new MediaStreamDependencyFactory(
1113 vc_manager_, p2p_socket_dispatcher_));
1114 }
1115#endif
1116 return media_stream_factory_.get();
1117}
1118
[email protected]f1a29a02011-10-06 23:08:441119GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
[email protected]6217d392010-03-25 22:08:351120 if (!gpu_channel_.get())
1121 return NULL;
1122
[email protected]e09cee42010-11-09 01:50:081123 if (gpu_channel_->state() != GpuChannelHost::kConnected)
[email protected]6217d392010-03-25 22:08:351124 return NULL;
1125
1126 return gpu_channel_.get();
1127}
1128
[email protected]f1a29a02011-10-06 23:08:441129void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) {
[email protected]f5e4b9bf2009-10-08 00:59:591130 EnsureWebKitInitialized();
[email protected]b547fd42009-04-23 23:16:271131 // The call below will cause a GetPlugins call with refresh=true, but at this
1132 // point we already know that the browser has refreshed its list, so disable
1133 // refresh temporarily to prevent each renderer process causing the list to be
1134 // regenerated.
[email protected]a70b4352012-07-31 22:34:531135 webkit_platform_support_->set_plugin_refresh_allowed(false);
[email protected]b78e168b2009-09-21 22:05:451136 WebKit::resetPluginCache(reload_pages);
[email protected]a70b4352012-07-31 22:34:531137 webkit_platform_support_->set_plugin_refresh_allowed(true);
[email protected]3b48dbc2012-01-06 16:34:171138
1139 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, PluginListChanged());
[email protected]b547fd42009-04-23 23:16:271140}
[email protected]85c55dc2009-11-06 03:05:461141
[email protected]f1a29a02011-10-06 23:08:441142void RenderThreadImpl::OnNetworkStateChanged(bool online) {
[email protected]6eac57a2011-07-12 21:15:091143 EnsureWebKitInitialized();
1144 WebNetworkStateNotifier::setOnLine(online);
1145}
1146
[email protected]b69934e2011-10-29 02:51:521147void RenderThreadImpl::OnTempCrashWithData(const GURL& data) {
[email protected]74ce1ad2011-12-16 21:51:461148 content::GetContentClient()->SetActiveURL(data);
[email protected]b69934e2011-10-29 02:51:521149 CHECK(false);
1150}
1151
[email protected]c6a7b862010-08-20 22:19:381152scoped_refptr<base::MessageLoopProxy>
[email protected]f1a29a02011-10-06 23:08:441153RenderThreadImpl::GetFileThreadMessageLoopProxy() {
[email protected]c6a7b862010-08-20 22:19:381154 DCHECK(message_loop() == MessageLoop::current());
1155 if (!file_thread_.get()) {
1156 file_thread_.reset(new base::Thread("Renderer::FILE"));
1157 file_thread_->Start();
1158 }
1159 return file_thread_->message_loop_proxy();
1160}