blob: 9aa51acfe38610459676a01a34d1a9e977131cdd [file] [log] [blame]
[email protected]7785b17f2011-03-23 01:20:281// Copyright (c) 2011 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]06533c0b2009-03-05 21:39:1112#include "base/command_line.h"
[email protected]58580352010-10-26 04:07:5013#include "base/debug/trace_event.h"
[email protected]94f9a0f682009-06-15 18:30:3014#include "base/lazy_instance.h"
[email protected]bee16aab2009-08-26 15:55:0315#include "base/logging.h"
[email protected]835d7c82010-10-14 04:38:3816#include "base/metrics/field_trial.h"
[email protected]6cf19311f2011-04-14 23:06:0217#include "base/metrics/histogram.h"
[email protected]835d7c82010-10-14 04:38:3818#include "base/metrics/stats_table.h"
[email protected]d41041092009-10-08 06:56:5719#include "base/process_util.h"
initial.commit09911bf2008-07-26 23:55:2920#include "base/shared_memory.h"
[email protected]46f36a492010-07-28 19:36:4121#include "base/task.h"
[email protected]1357c322010-12-30 22:18:5622#include "base/threading/thread_local.h"
[email protected]7a4de7a62010-08-17 18:38:2423#include "base/values.h"
[email protected]e93e04e2011-03-14 00:27:1024#include "content/common/appcache/appcache_dispatcher.h"
[email protected]38b592902011-04-16 02:08:4225#include "content/common/content_switches.h"
[email protected]37666cf2011-03-13 21:51:4226#include "content/common/database_messages.h"
27#include "content/common/db_message_filter.h"
[email protected]127dd582011-03-16 21:32:1028#include "content/common/dom_storage_messages.h"
[email protected]202b54ff2011-04-22 21:36:3829#include "content/common/gpu/gpu_messages.h"
[email protected]d3fd748b2011-09-20 17:39:1730#include "content/common/npobject_util.h"
[email protected]105303e2011-03-14 22:16:1031#include "content/common/plugin_messages.h"
[email protected]60916042011-03-19 00:43:3632#include "content/common/renderer_preferences.h"
[email protected]359dfa32011-10-12 01:10:1533#include "content/common/resource_dispatcher.h"
[email protected]94dc971d2011-03-05 19:08:3234#include "content/common/resource_messages.h"
[email protected]778574e2011-03-21 22:03:5035#include "content/common/view_messages.h"
[email protected]e93e04e2011-03-14 00:27:1036#include "content/common/web_database_observer_impl.h"
[email protected]d344114c2011-10-01 01:24:3437#include "content/public/renderer/content_renderer_client.h"
[email protected]64ffa0442011-10-03 22:08:3638#include "content/public/renderer/render_process_observer.h"
39#include "content/public/renderer/render_view_visitor.h"
[email protected]82622452011-07-22 09:57:2040#include "content/renderer/devtools_agent_filter.h"
[email protected]a9fb30aa2011-10-06 06:58:4641#include "content/renderer/gpu/compositor_thread.h"
[email protected]a03a2222011-05-25 21:26:4042#include "content/renderer/gpu/gpu_channel_host.h"
[email protected]230b7ef2011-03-16 22:30:1943#include "content/renderer/indexed_db_dispatcher.h"
[email protected]f7eb0a392011-07-12 10:19:5144#include "content/renderer/media/audio_input_message_filter.h"
45#include "content/renderer/media/audio_message_filter.h"
[email protected]80b161a2011-06-27 17:42:1146#include "content/renderer/media/video_capture_impl_manager.h"
[email protected]ba164c912011-06-14 22:07:3447#include "content/renderer/media/video_capture_message_filter.h"
[email protected]6f516082011-03-17 19:15:3548#include "content/renderer/plugin_channel_host.h"
[email protected]8704f89b2011-04-15 00:30:0549#include "content/renderer/render_process_impl.h"
[email protected]310ebd6302011-10-10 19:06:2850#include "content/renderer/render_view_impl.h"
[email protected]acb94722011-03-18 01:33:3451#include "content/renderer/renderer_webidbfactory_impl.h"
[email protected]8d6cba42011-09-02 10:05:1952#include "content/renderer/renderer_webkitplatformsupport_impl.h"
[email protected]46f36a492010-07-28 19:36:4153#include "ipc/ipc_channel_handle.h"
[email protected]cb6037d2009-11-16 22:55:1754#include "ipc/ipc_platform_file.h"
[email protected]620161e2011-03-07 18:05:2655#include "net/base/net_errors.h"
[email protected]9d797f32010-04-23 07:17:5456#include "net/base/net_util.h"
[email protected]1b1f3eb2009-12-01 13:48:0457#include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
[email protected]8bd0fe62011-01-17 06:44:3758#include "third_party/WebKit/Source/WebKit/chromium/public/WebColor.h"
[email protected]8bd0fe62011-01-17 06:44:3759#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h"
60#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
[email protected]8bd0fe62011-01-17 06:44:3761#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
62#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
[email protected]6eac57a2011-07-12 21:15:0963#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h"
[email protected]4bd55a32011-07-28 13:28:3864#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
[email protected]8bd0fe62011-01-17 06:44:3765#include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
66#include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h"
[email protected]8bd0fe62011-01-17 06:44:3767#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispatcher.h"
68#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
69#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
[email protected]18ad6772011-09-20 21:51:3270#include "ui/base/ui_base_switches.h"
[email protected]7f3a2cf2011-04-06 00:10:5071#include "v8/include/v8.h"
[email protected]06533c0b2009-03-05 21:39:1172#include "webkit/extensions/v8/playback_extension.h"
[email protected]d471190a2011-02-16 14:52:3073#include "webkit/glue/webkit_glue.h"
[email protected]2c62b562009-01-27 19:04:5074
[email protected]94dc971d2011-03-05 19:08:3275// TODO(port)
76#if defined(OS_WIN)
[email protected]79fff822011-09-20 03:33:2177#include "content/common/child_process_messages.h"
[email protected]94dc971d2011-03-05 19:08:3278#else
[email protected]3b63f8f42011-03-28 01:54:1579#include "base/memory/scoped_handle.h"
[email protected]099587b72011-09-20 00:40:5080#include "content/common/np_channel_base.h"
[email protected]94dc971d2011-03-05 19:08:3281#endif
82
[email protected]da00a2882009-03-09 17:51:1983#if defined(OS_WIN)
84#include <windows.h>
85#include <objbase.h>
86#endif
87
[email protected]6217d392010-03-25 22:08:3588#if defined(OS_POSIX)
89#include "ipc/ipc_channel_posix.h"
90#endif
91
[email protected]b6cb3a842011-06-24 18:28:4192using WebKit::WebDocument;
[email protected]f85f0702010-01-30 09:31:0193using WebKit::WebFrame;
[email protected]6eac57a2011-07-12 21:15:0994using WebKit::WebNetworkStateNotifier;
[email protected]adf00bc2009-11-02 18:35:0095using WebKit::WebRuntimeFeatures;
[email protected]98d7127b2009-10-23 18:26:5196using WebKit::WebScriptController;
[email protected]2c434b32009-03-19 06:27:4797using WebKit::WebString;
[email protected]b7c7bcf2009-10-03 07:07:3498using WebKit::WebStorageEventDispatcher;
[email protected]50ae00ef2009-10-19 05:11:0399using WebKit::WebView;
[email protected]64ffa0442011-10-03 22:08:36100using content::RenderProcessObserver;
initial.commit09911bf2008-07-26 23:55:29101
[email protected]42f1d7822009-07-23 18:17:55102namespace {
[email protected]bee16aab2009-08-26 15:55:03103static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */;
104
[email protected]4bd55a32011-07-28 13:28:38105#if defined(TOUCH_UI)
106static const int kPopupListBoxMinimumRowHeight = 60;
107#endif
108
[email protected]f1a29a02011-10-06 23:08:44109// Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
[email protected]f3ede412010-06-21 22:52:16110// incorrectly from the wrong thread.
[email protected]f1a29a02011-10-06 23:08:44111static base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > lazy_tls(
[email protected]94f9a0f682009-06-15 18:30:30112 base::LINKER_INITIALIZED);
[email protected]1edc16b82009-04-07 17:45:54113
[email protected]64ffa0442011-10-03 22:08:36114class RenderViewZoomer : public content::RenderViewVisitor {
[email protected]40bd6582009-12-04 23:49:51115 public:
[email protected]b75b8292010-10-01 07:28:25116 RenderViewZoomer(const GURL& url, double zoom_level)
[email protected]9d797f32010-04-23 07:17:54117 : zoom_level_(zoom_level) {
118 host_ = net::GetHostOrSpecFromURL(url);
[email protected]40bd6582009-12-04 23:49:51119 }
120
[email protected]a2ef54c2011-10-10 16:20:31121 virtual bool Visit(content::RenderView* render_view) {
122 WebView* webview = render_view->GetWebView();
[email protected]b6cb3a842011-06-24 18:28:41123 WebDocument document = webview->mainFrame()->document();
[email protected]b75b8292010-10-01 07:28:25124
125 // Don't set zoom level for full-page plugin since they don't use the same
126 // zoom settings.
[email protected]b6cb3a842011-06-24 18:28:41127 if (document.isPluginDocument())
[email protected]b75b8292010-10-01 07:28:25128 return true;
129
[email protected]b6cb3a842011-06-24 18:28:41130 if (net::GetHostOrSpecFromURL(GURL(document.url())) == host_)
[email protected]40bd6582009-12-04 23:49:51131 webview->setZoomLevel(false, zoom_level_);
132 return true;
133 }
134
135 private:
136 std::string host_;
[email protected]b75b8292010-10-01 07:28:25137 double zoom_level_;
[email protected]40bd6582009-12-04 23:49:51138
139 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
140};
[email protected]0478d0162010-08-28 08:29:40141
[email protected]42f1d7822009-07-23 18:17:55142} // namespace
143
[email protected]d1b8fccc2011-08-03 01:20:13144static void* CreateHistogram(
145 const char *name, int min, int max, size_t buckets) {
146 if (min <= 0)
147 min = 1;
148 base::Histogram* histogram = base::Histogram::FactoryGet(
149 name, min, max, buckets, base::Histogram::kUmaTargetedHistogramFlag);
150 return histogram;
151}
152
153static void AddHistogramSample(void* hist, int sample) {
154 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
155 histogram->Add(sample);
156}
157
[email protected]f1a29a02011-10-06 23:08:44158RenderThreadImpl* RenderThreadImpl::current() {
[email protected]526476902011-10-06 20:34:06159 return lazy_tls.Pointer()->Get();
160}
161
[email protected]42f1d7822009-07-23 18:17:55162// When we run plugins in process, we actually run them on the render thread,
163// which means that we need to make the render thread pump UI events.
[email protected]f1a29a02011-10-06 23:08:44164RenderThreadImpl::RenderThreadImpl() {
[email protected]42f1d7822009-07-23 18:17:55165 Init();
166}
167
[email protected]f1a29a02011-10-06 23:08:44168RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
[email protected]42f1d7822009-07-23 18:17:55169 : ChildThread(channel_name) {
170 Init();
171}
[email protected]5fa1c542009-05-05 20:36:07172
[email protected]f1a29a02011-10-06 23:08:44173void RenderThreadImpl::Init() {
174 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, "");
[email protected]a872ea1f2010-08-11 04:45:33175
[email protected]53c607c2011-03-21 23:19:04176#if defined(OS_MACOSX)
177 // On Mac, the select popups are rendered by the browser.
178 WebKit::WebView::setUseExternalPopupMenus(true);
179#endif
180
[email protected]94f9a0f682009-06-15 18:30:30181 lazy_tls.Pointer()->Set(this);
[email protected]2c62b562009-01-27 19:04:50182#if defined(OS_WIN)
[email protected]bdef78b52009-04-16 19:31:34183 // If you are running plugins in this thread you need COM active but in
184 // the normal case you don't.
[email protected]00c39612010-03-06 02:53:28185 if (RenderProcessImpl::InProcessPlugins())
[email protected]bdef78b52009-04-16 19:31:34186 CoInitialize(0);
[email protected]2c62b562009-01-27 19:04:50187#endif
initial.commit09911bf2008-07-26 23:55:29188
[email protected]31f87132010-04-21 23:36:21189 // In single process the single process is all there is.
[email protected]80fc08c52010-03-09 07:43:50190 suspend_webkit_shared_timer_ = true;
191 notify_webkit_of_modal_loop_ = true;
[email protected]42f1d7822009-07-23 18:17:55192 plugin_refresh_allowed_ = true;
[email protected]bee16aab2009-08-26 15:55:03193 widget_count_ = 0;
194 hidden_widget_count_ = 0;
[email protected]6779aa12011-03-29 17:32:24195 idle_notification_delay_in_s_ = kInitialIdleHandlerDelayS;
[email protected]f1a29a02011-10-06 23:08:44196 task_factory_.reset(new ScopedRunnableMethodFactory<RenderThreadImpl>(this));
[email protected]8d86fce2009-02-26 23:37:55197
[email protected]526476902011-10-06 20:34:06198 appcache_dispatcher_.reset(new AppCacheDispatcher(Get()));
[email protected]70c19a932010-05-14 12:59:11199 indexed_db_dispatcher_.reset(new IndexedDBDispatcher());
[email protected]dd9241932010-02-24 19:23:13200
[email protected]017022b2009-07-27 23:06:34201 db_message_filter_ = new DBMessageFilter();
202 AddFilter(db_message_filter_.get());
[email protected]dd9241932010-02-24 19:23:13203
[email protected]80b161a2011-06-27 17:42:11204 vc_manager_ = new VideoCaptureImplManager();
205 AddFilter(vc_manager_->video_capture_message_filter());
[email protected]e25f4d72011-06-08 20:58:46206
[email protected]f7eb0a392011-07-12 10:19:51207 audio_input_message_filter_ = new AudioInputMessageFilter();
208 AddFilter(audio_input_message_filter_.get());
209
210 audio_message_filter_ = new AudioMessageFilter();
211 AddFilter(audio_message_filter_.get());
212
[email protected]82622452011-07-22 09:57:20213 devtools_agent_message_filter_ = new DevToolsAgentFilter();
214 AddFilter(devtools_agent_message_filter_.get());
215
[email protected]8d97ade2011-04-14 18:17:08216 content::GetContentClient()->renderer()->RenderThreadStarted();
[email protected]6779aa12011-03-29 17:32:24217
[email protected]f1a29a02011-10-06 23:08:44218 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
initial.commit09911bf2008-07-26 23:55:29219}
220
[email protected]f1a29a02011-10-06 23:08:44221RenderThreadImpl::~RenderThreadImpl() {
[email protected]1223d6ef2011-03-28 16:47:50222 FOR_EACH_OBSERVER(
223 RenderProcessObserver, observers_, OnRenderProcessShutdown());
224
[email protected]12cbfda32010-01-30 01:04:25225 // Wait for all databases to be closed.
[email protected]2b437e232010-04-02 01:30:08226 if (web_database_observer_impl_.get())
227 web_database_observer_impl_->WaitForAllDatabasesToClose();
[email protected]12cbfda32010-01-30 01:04:25228
[email protected]8d86fce2009-02-26 23:37:55229 // Shutdown in reverse of the initialization order.
[email protected]82622452011-07-22 09:57:20230 RemoveFilter(devtools_agent_message_filter_.get());
231 devtools_agent_message_filter_ = NULL;
232
[email protected]f7eb0a392011-07-12 10:19:51233 RemoveFilter(audio_input_message_filter_.get());
234 audio_input_message_filter_ = NULL;
235
236 RemoveFilter(audio_message_filter_.get());
237 audio_message_filter_ = NULL;
238
[email protected]80b161a2011-06-27 17:42:11239 RemoveFilter(vc_manager_->video_capture_message_filter());
240
[email protected]017022b2009-07-27 23:06:34241 RemoveFilter(db_message_filter_.get());
242 db_message_filter_ = NULL;
[email protected]12cbfda32010-01-30 01:04:25243
[email protected]c6a7b862010-08-20 22:19:38244 // Shutdown the file thread if it's running.
245 if (file_thread_.get())
246 file_thread_->Stop();
247
[email protected]a9fb30aa2011-10-06 06:58:46248 if (compositor_thread_.get()) {
249 RemoveFilter(compositor_thread_->GetMessageFilter());
250 compositor_thread_.reset();
251 }
252
[email protected]8d6cba42011-09-02 10:05:19253 if (webkit_platform_support_.get())
[email protected]9291ed12009-07-23 17:33:22254 WebKit::shutdown();
[email protected]9291ed12009-07-23 17:33:22255
[email protected]94f9a0f682009-06-15 18:30:30256 lazy_tls.Pointer()->Set(NULL);
[email protected]8fd8de92008-08-12 23:50:30257
[email protected]8d86fce2009-02-26 23:37:55258 // TODO(port)
[email protected]2c62b562009-01-27 19:04:50259#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29260 // Clean up plugin channels before this thread goes away.
[email protected]099587b72011-09-20 00:40:50261 NPChannelBase::CleanupChannels();
[email protected]bdef78b52009-04-16 19:31:34262 // Don't call COM if the renderer is in the sandbox.
[email protected]00c39612010-03-06 02:53:28263 if (RenderProcessImpl::InProcessPlugins())
[email protected]bdef78b52009-04-16 19:31:34264 CoUninitialize();
[email protected]2c62b562009-01-27 19:04:50265#endif
initial.commit09911bf2008-07-26 23:55:29266}
267
[email protected]f1a29a02011-10-06 23:08:44268bool RenderThreadImpl::Send(IPC::Message* msg) {
[email protected]f23d4da92010-11-24 21:36:14269 // Certain synchronous messages cannot always be processed synchronously by
270 // the browser, e.g., Chrome frame communicating with the embedding browser.
[email protected]80fc08c52010-03-09 07:43:50271 // This could cause a complete hang of Chrome if a windowed plug-in is trying
272 // to communicate with the renderer thread since the browser's UI thread
273 // could be stuck (within a Windows API call) trying to synchronously
274 // communicate with the plug-in. The remedy is to pump messages on this
[email protected]f23d4da92010-11-24 21:36:14275 // thread while the browser is processing this request. This creates an
276 // opportunity for re-entrancy into WebKit, so we need to take care to disable
277 // callbacks, timers, and pending network loads that could trigger such
278 // callbacks.
[email protected]38b592902011-04-16 02:08:42279 bool pumping_events = false;
[email protected]80fc08c52010-03-09 07:43:50280 if (msg->is_sync()) {
281 if (msg->is_caller_pumping_messages()) {
282 pumping_events = true;
283 } else {
[email protected]38b592902011-04-16 02:08:42284 if ((msg->type() == ViewHostMsg_GetCookies::ID ||
285 msg->type() == ViewHostMsg_GetRawCookies::ID ||
286 msg->type() == ViewHostMsg_CookiesEnabled::ID) &&
287 content::GetContentClient()->renderer()->
288 ShouldPumpEventsDuringCookieMessage()) {
289 pumping_events = true;
[email protected]80fc08c52010-03-09 07:43:50290 }
291 }
[email protected]c1f50aa2010-02-18 03:46:57292 }
293
[email protected]80fc08c52010-03-09 07:43:50294 bool suspend_webkit_shared_timer = true; // default value
295 std::swap(suspend_webkit_shared_timer, suspend_webkit_shared_timer_);
[email protected]c1f50aa2010-02-18 03:46:57296
[email protected]80fc08c52010-03-09 07:43:50297 bool notify_webkit_of_modal_loop = true; // default value
298 std::swap(notify_webkit_of_modal_loop, notify_webkit_of_modal_loop_);
299
300 gfx::NativeViewId host_window = 0;
[email protected]c1f50aa2010-02-18 03:46:57301
302 if (pumping_events) {
[email protected]80fc08c52010-03-09 07:43:50303 if (suspend_webkit_shared_timer)
[email protected]8d6cba42011-09-02 10:05:19304 webkit_platform_support_->SuspendSharedTimer();
[email protected]c1f50aa2010-02-18 03:46:57305
[email protected]39065d012010-07-09 11:22:46306 if (notify_webkit_of_modal_loop)
[email protected]c1f50aa2010-02-18 03:46:57307 WebView::willEnterModalLoop();
[email protected]c1f50aa2010-02-18 03:46:57308
[email protected]80fc08c52010-03-09 07:43:50309 RenderWidget* widget =
310 static_cast<RenderWidget*>(ResolveRoute(msg->routing_id()));
311 if (widget) {
312 host_window = widget->host_window();
[email protected]c1f50aa2010-02-18 03:46:57313 PluginChannelHost::Broadcast(
314 new PluginMsg_SignalModalDialogEvent(host_window));
315 }
316 }
317
318 bool rv = ChildThread::Send(msg);
319
320 if (pumping_events) {
321 if (host_window) {
322 PluginChannelHost::Broadcast(
323 new PluginMsg_ResetModalDialogEvent(host_window));
324 }
325
[email protected]39065d012010-07-09 11:22:46326 if (notify_webkit_of_modal_loop)
[email protected]c1f50aa2010-02-18 03:46:57327 WebView::didExitModalLoop();
[email protected]c1f50aa2010-02-18 03:46:57328
[email protected]80fc08c52010-03-09 07:43:50329 if (suspend_webkit_shared_timer)
[email protected]8d6cba42011-09-02 10:05:19330 webkit_platform_support_->ResumeSharedTimer();
[email protected]c1f50aa2010-02-18 03:46:57331 }
332
333 return rv;
334}
335
[email protected]f1a29a02011-10-06 23:08:44336MessageLoop* RenderThreadImpl::GetMessageLoop() {
[email protected]526476902011-10-06 20:34:06337 return message_loop();
338}
339
[email protected]f1a29a02011-10-06 23:08:44340IPC::SyncChannel* RenderThreadImpl::GetChannel() {
[email protected]526476902011-10-06 20:34:06341 return channel();
342}
343
[email protected]f1a29a02011-10-06 23:08:44344std::string RenderThreadImpl::GetLocale() {
[email protected]526476902011-10-06 20:34:06345 // The browser process should have passed the locale to the renderer via the
346 // --lang command line flag. In single process mode, this will return the
347 // wrong value. TODO(tc): Fix this for single process mode.
348 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
349 const std::string& lang =
350 parsed_command_line.GetSwitchValueASCII(switches::kLang);
351 DCHECK(!lang.empty() ||
352 (!parsed_command_line.HasSwitch(switches::kRendererProcess) &&
353 !parsed_command_line.HasSwitch(switches::kPluginProcess)));
354 return lang;
355}
356
[email protected]f1a29a02011-10-06 23:08:44357void RenderThreadImpl::AddRoute(int32 routing_id,
358 IPC::Channel::Listener* listener) {
[email protected]c1f50aa2010-02-18 03:46:57359 widget_count_++;
360 return ChildThread::AddRoute(routing_id, listener);
361}
362
[email protected]f1a29a02011-10-06 23:08:44363void RenderThreadImpl::RemoveRoute(int32 routing_id) {
[email protected]c1f50aa2010-02-18 03:46:57364 widget_count_--;
365 return ChildThread::RemoveRoute(routing_id);
366}
367
[email protected]f1a29a02011-10-06 23:08:44368void RenderThreadImpl::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
[email protected]42f1d7822009-07-23 18:17:55369 channel()->AddFilter(filter);
370}
371
[email protected]f1a29a02011-10-06 23:08:44372void RenderThreadImpl::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
[email protected]42f1d7822009-07-23 18:17:55373 channel()->RemoveFilter(filter);
374}
375
[email protected]f1a29a02011-10-06 23:08:44376void RenderThreadImpl::SetOutgoingMessageFilter(
[email protected]526476902011-10-06 20:34:06377 IPC::ChannelProxy::OutgoingMessageFilter* filter) {
378}
379
[email protected]f1a29a02011-10-06 23:08:44380void RenderThreadImpl::AddObserver(content::RenderProcessObserver* observer) {
[email protected]526476902011-10-06 20:34:06381 observers_.AddObserver(observer);
382}
383
[email protected]f1a29a02011-10-06 23:08:44384void RenderThreadImpl::RemoveObserver(
385 content::RenderProcessObserver* observer) {
[email protected]526476902011-10-06 20:34:06386 observers_.RemoveObserver(observer);
387}
388
[email protected]359dfa32011-10-12 01:10:15389void RenderThreadImpl::SetResourceDispatcherDelegate(
390 content::ResourceDispatcherDelegate* delegate) {
391 resource_dispatcher()->set_delegate(delegate);
392}
393
[email protected]f1a29a02011-10-06 23:08:44394void RenderThreadImpl::WidgetHidden() {
[email protected]bee16aab2009-08-26 15:55:03395 DCHECK(hidden_widget_count_ < widget_count_);
[email protected]4a3dab22009-11-11 17:36:50396 hidden_widget_count_++;
[email protected]6779aa12011-03-29 17:32:24397
398 if (!content::GetContentClient()->renderer()->
399 RunIdleHandlerWhenWidgetsHidden()) {
400 return;
401 }
402
403 if (widget_count_ && hidden_widget_count_ == widget_count_)
[email protected]71d6d852009-12-07 22:12:36404 ScheduleIdleHandler(kInitialIdleHandlerDelayS);
[email protected]bee16aab2009-08-26 15:55:03405}
406
[email protected]f1a29a02011-10-06 23:08:44407void RenderThreadImpl::WidgetRestored() {
[email protected]61a9b2d82010-02-26 00:31:08408 DCHECK_GT(hidden_widget_count_, 0);
[email protected]bee16aab2009-08-26 15:55:03409 hidden_widget_count_--;
[email protected]6779aa12011-03-29 17:32:24410 if (!content::GetContentClient()->renderer()->
411 RunIdleHandlerWhenWidgetsHidden()) {
412 return;
413 }
[email protected]bee16aab2009-08-26 15:55:03414
[email protected]6779aa12011-03-29 17:32:24415 idle_timer_.Stop();
[email protected]e4be2dd2010-12-14 00:44:39416}
417
[email protected]f1a29a02011-10-06 23:08:44418void RenderThreadImpl::EnsureWebKitInitialized() {
[email protected]8d6cba42011-09-02 10:05:19419 if (webkit_platform_support_.get())
[email protected]d1b8fccc2011-08-03 01:20:13420 return;
421
422 v8::V8::SetCounterFunction(base::StatsTable::FindLocation);
423 v8::V8::SetCreateHistogramFunction(CreateHistogram);
424 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample);
425
[email protected]8d6cba42011-09-02 10:05:19426 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl);
427 WebKit::initialize(webkit_platform_support_.get());
[email protected]d1b8fccc2011-08-03 01:20:13428
[email protected]a9fb30aa2011-10-06 06:58:46429 compositor_thread_.reset(new CompositorThread(this));
430 AddFilter(compositor_thread_->GetMessageFilter());
431
[email protected]d1b8fccc2011-08-03 01:20:13432 WebScriptController::enableV8SingleThreadMode();
433
434 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
435
436 webkit_glue::EnableWebCoreLogChannels(
437 command_line.GetSwitchValueASCII(switches::kWebCoreLogChannels));
438
[email protected]d1b8fccc2011-08-03 01:20:13439 if (command_line.HasSwitch(switches::kPlaybackMode) ||
440 command_line.HasSwitch(switches::kRecordMode) ||
441 command_line.HasSwitch(switches::kNoJsRandomness)) {
442 RegisterExtension(extensions_v8::PlaybackExtension::Get());
443 }
444
[email protected]526476902011-10-06 20:34:06445 web_database_observer_impl_.reset(new WebDatabaseObserverImpl(Get()));
[email protected]d1b8fccc2011-08-03 01:20:13446 WebKit::WebDatabase::setObserver(web_database_observer_impl_.get());
447
448 WebRuntimeFeatures::enableSockets(
449 !command_line.HasSwitch(switches::kDisableWebSockets));
450
451 WebRuntimeFeatures::enableDatabase(
452 !command_line.HasSwitch(switches::kDisableDatabases));
453
454 WebRuntimeFeatures::enableDataTransferItems(
455 !command_line.HasSwitch(switches::kDisableDataTransferItems));
456
457 WebRuntimeFeatures::enableApplicationCache(
458 !command_line.HasSwitch(switches::kDisableApplicationCache));
459
460 WebRuntimeFeatures::enableNotifications(
461 !command_line.HasSwitch(switches::kDisableDesktopNotifications));
462
463 WebRuntimeFeatures::enableLocalStorage(
464 !command_line.HasSwitch(switches::kDisableLocalStorage));
465 WebRuntimeFeatures::enableSessionStorage(
466 !command_line.HasSwitch(switches::kDisableSessionStorage));
467
468 WebRuntimeFeatures::enableIndexedDatabase(
469 !command_line.HasSwitch(switches::kDisableIndexedDatabase));
470
471 WebRuntimeFeatures::enableGeolocation(
472 !command_line.HasSwitch(switches::kDisableGeolocation));
473
474 WebKit::WebRuntimeFeatures::enableMediaStream(
475 command_line.HasSwitch(switches::kEnableMediaStream));
476
[email protected]efdc0282011-08-26 00:36:12477 WebKit::WebRuntimeFeatures::enableFullScreenAPI(
[email protected]5e5671a2011-09-08 02:12:21478 !command_line.HasSwitch(switches::kDisableFullScreen));
[email protected]efdc0282011-08-26 00:36:12479
[email protected]f5da41d2011-10-08 17:40:07480 WebKit::WebRuntimeFeatures::enableVideoTrack(
481 command_line.HasSwitch(switches::kEnableVideoTrack));
482
[email protected]d1b8fccc2011-08-03 01:20:13483#if defined(OS_CHROMEOS)
484 // TODO(crogers): enable once Web Audio has been tested and optimized.
485 WebRuntimeFeatures::enableWebAudio(false);
486#else
487 WebRuntimeFeatures::enableWebAudio(
488 !command_line.HasSwitch(switches::kDisableWebAudio));
489#endif
490
491 WebRuntimeFeatures::enablePushState(true);
492
493#ifdef TOUCH_UI
494 WebRuntimeFeatures::enableTouch(true);
495 WebKit::WebPopupMenu::setMinimumRowHeight(kPopupListBoxMinimumRowHeight);
496#else
497 // TODO(saintlou): in the future touch should always be enabled
498 WebRuntimeFeatures::enableTouch(false);
499#endif
500
501 WebRuntimeFeatures::enableDeviceMotion(
502 command_line.HasSwitch(switches::kEnableDeviceMotion));
503
504 WebRuntimeFeatures::enableDeviceOrientation(
505 !command_line.HasSwitch(switches::kDisableDeviceOrientation));
506
507 WebRuntimeFeatures::enableSpeechInput(
508 !command_line.HasSwitch(switches::kDisableSpeechInput));
509
510 WebRuntimeFeatures::enableFileSystem(
511 !command_line.HasSwitch(switches::kDisableFileSystem));
512
513 WebRuntimeFeatures::enableJavaScriptI18NAPI(
514 !command_line.HasSwitch(switches::kDisableJavaScriptI18NAPI));
515
516 WebRuntimeFeatures::enableQuota(true);
517
518 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized());
519}
520
[email protected]f1a29a02011-10-06 23:08:44521void RenderThreadImpl::RecordUserMetrics(const std::string& action) {
[email protected]526476902011-10-06 20:34:06522 Send(new ViewHostMsg_UserMetricsRecordAction(action));
523}
524
[email protected]00614a82011-10-07 22:39:31525base::SharedMemoryHandle RenderThreadImpl::HostAllocateSharedMemoryBuffer(
526 uint32 buffer_size) {
527 base::SharedMemoryHandle mem_handle;
528 Send(new ViewHostMsg_AllocateSharedMemoryBuffer(buffer_size, &mem_handle));
529 return mem_handle;
530}
531
[email protected]f1a29a02011-10-06 23:08:44532void RenderThreadImpl::RegisterExtension(v8::Extension* extension) {
[email protected]526476902011-10-06 20:34:06533 WebScriptController::registerExtension(extension);
534 v8_extensions_.insert(extension->name());
535}
536
[email protected]f1a29a02011-10-06 23:08:44537bool RenderThreadImpl::IsRegisteredExtension(
[email protected]526476902011-10-06 20:34:06538 const std::string& v8_extension_name) const {
539 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end();
540}
541
[email protected]f1a29a02011-10-06 23:08:44542void RenderThreadImpl::ScheduleIdleHandler(double initial_delay_s) {
[email protected]526476902011-10-06 20:34:06543 idle_notification_delay_in_s_ = initial_delay_s;
544 idle_timer_.Stop();
545 idle_timer_.Start(FROM_HERE,
546 base::TimeDelta::FromSeconds(static_cast<int64>(initial_delay_s)),
[email protected]f1a29a02011-10-06 23:08:44547 this, &RenderThreadImpl::IdleHandler);
[email protected]526476902011-10-06 20:34:06548}
549
[email protected]f1a29a02011-10-06 23:08:44550void RenderThreadImpl::IdleHandler() {
[email protected]526476902011-10-06 20:34:06551 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
552 MallocExtension::instance()->ReleaseFreeMemory();
553#endif
554
555 v8::V8::IdleNotification();
556
557 // Schedule next invocation.
558 // Dampen the delay using the algorithm:
559 // delay = delay + 1 / (delay + 2)
560 // Using floor(delay) has a dampening effect such as:
561 // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
562 // Note that idle_notification_delay_in_s_ would be reset to
[email protected]f1a29a02011-10-06 23:08:44563 // kInitialIdleHandlerDelayS in RenderThreadImpl::WidgetHidden.
[email protected]526476902011-10-06 20:34:06564 ScheduleIdleHandler(idle_notification_delay_in_s_ +
565 1.0 / (idle_notification_delay_in_s_ + 2.0));
566
567 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, IdleNotification());
568}
569
[email protected]f1a29a02011-10-06 23:08:44570double RenderThreadImpl::GetIdleNotificationDelayInS() const {
[email protected]526476902011-10-06 20:34:06571 return idle_notification_delay_in_s_;
572}
573
[email protected]f1a29a02011-10-06 23:08:44574void RenderThreadImpl::SetIdleNotificationDelayInS(
[email protected]526476902011-10-06 20:34:06575 double idle_notification_delay_in_s) {
576 idle_notification_delay_in_s_ = idle_notification_delay_in_s;
[email protected]4a7d6392011-09-19 20:55:08577}
578
579#if defined(OS_WIN)
[email protected]f1a29a02011-10-06 23:08:44580void RenderThreadImpl::PreCacheFont(const LOGFONT& log_font) {
[email protected]526476902011-10-06 20:34:06581 Send(new ChildProcessHostMsg_PreCacheFont(log_font));
[email protected]79fff822011-09-20 03:33:21582}
583
[email protected]f1a29a02011-10-06 23:08:44584void RenderThreadImpl::ReleaseCachedFonts() {
[email protected]526476902011-10-06 20:34:06585 Send(new ChildProcessHostMsg_ReleaseCachedFonts());
[email protected]4a7d6392011-09-19 20:55:08586}
[email protected]526476902011-10-06 20:34:06587
[email protected]4a7d6392011-09-19 20:55:08588#endif // OS_WIN
589
[email protected]f1a29a02011-10-06 23:08:44590int32 RenderThreadImpl::RoutingIDForCurrentContext() {
[email protected]526476902011-10-06 20:34:06591 int32 routing_id = MSG_ROUTING_CONTROL;
592 if (v8::Context::InContext()) {
593 WebFrame* frame = WebFrame::frameForCurrentContext();
594 if (frame) {
[email protected]310ebd6302011-10-10 19:06:28595 RenderViewImpl* view = RenderViewImpl::FromWebView(frame->view());
[email protected]526476902011-10-06 20:34:06596 if (view)
597 routing_id = view->routing_id();
598 }
599 } else {
600 DLOG(WARNING) << "Not called within a script context!";
601 }
602 return routing_id;
603}
604
[email protected]f1a29a02011-10-06 23:08:44605void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
[email protected]526476902011-10-06 20:34:06606 suspend_webkit_shared_timer_ = false;
607}
608
[email protected]f1a29a02011-10-06 23:08:44609void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
[email protected]526476902011-10-06 20:34:06610 notify_webkit_of_modal_loop_ = false;
611}
612
[email protected]f1a29a02011-10-06 23:08:44613void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const GURL& url,
614 double zoom_level) {
[email protected]526476902011-10-06 20:34:06615 RenderViewZoomer zoomer(url, zoom_level);
[email protected]310ebd6302011-10-10 19:06:28616 content::RenderView::ForEach(&zoomer);
[email protected]526476902011-10-06 20:34:06617}
618
[email protected]f1a29a02011-10-06 23:08:44619void RenderThreadImpl::OnDOMStorageEvent(
[email protected]526476902011-10-06 20:34:06620 const DOMStorageMsg_Event_Params& params) {
621 if (!dom_storage_event_dispatcher_.get())
622 dom_storage_event_dispatcher_.reset(WebStorageEventDispatcher::create());
623 dom_storage_event_dispatcher_->dispatchStorageEvent(params.key,
624 params.old_value, params.new_value, params.origin, params.url,
625 params.storage_type == DOM_STORAGE_LOCAL);
626}
627
[email protected]f1a29a02011-10-06 23:08:44628bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
[email protected]1223d6ef2011-03-28 16:47:50629 ObserverListBase<RenderProcessObserver>::Iterator it(observers_);
630 RenderProcessObserver* observer;
631 while ((observer = it.GetNext()) != NULL) {
632 if (observer->OnControlMessageReceived(msg))
633 return true;
634 }
635
[email protected]70c19a932010-05-14 12:59:11636 // Some messages are handled by delegates.
[email protected]f430b5712009-08-21 21:46:31637 if (appcache_dispatcher_->OnMessageReceived(msg))
[email protected]a95986a82010-12-24 06:19:28638 return true;
[email protected]70c19a932010-05-14 12:59:11639 if (indexed_db_dispatcher_->OnMessageReceived(msg))
[email protected]a95986a82010-12-24 06:19:28640 return true;
[email protected]1edc16b82009-04-07 17:45:54641
[email protected]a95986a82010-12-24 06:19:28642 bool handled = true;
[email protected]f1a29a02011-10-06 23:08:44643 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg)
[email protected]9d797f32010-04-23 07:17:54644 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL,
645 OnSetZoomLevelForCurrentURL)
[email protected]8930d472009-02-21 08:05:28646 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
[email protected]b9ab10c2009-08-07 18:09:55647 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors)
[email protected]8930d472009-02-21 08:05:28648 // TODO(port): removed from render_messages_internal.h;
649 // is there a new non-windows message I should add here?
650 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
[email protected]3e267192011-03-25 01:55:45651 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache)
[email protected]6eac57a2011-07-12 21:15:09652 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged)
[email protected]3e267192011-03-25 01:55:45653 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent)
[email protected]a95986a82010-12-24 06:19:28654 IPC_MESSAGE_UNHANDLED(handled = false)
[email protected]8930d472009-02-21 08:05:28655 IPC_END_MESSAGE_MAP()
[email protected]a95986a82010-12-24 06:19:28656 return handled;
initial.commit09911bf2008-07-26 23:55:29657}
658
[email protected]f1a29a02011-10-06 23:08:44659void RenderThreadImpl::OnSetNextPageID(int32 next_page_id) {
initial.commit09911bf2008-07-26 23:55:29660 // This should only be called at process initialization time, so we shouldn't
661 // have to worry about thread-safety.
[email protected]310ebd6302011-10-10 19:06:28662 RenderViewImpl::SetNextPageID(next_page_id);
initial.commit09911bf2008-07-26 23:55:29663}
664
[email protected]b9ab10c2009-08-07 18:09:55665// Called when to register CSS Color name->system color mappings.
666// We update the colors one by one and then tell WebKit to refresh all render
667// views.
[email protected]f1a29a02011-10-06 23:08:44668void RenderThreadImpl::OnSetCSSColors(
[email protected]b9ab10c2009-08-07 18:09:55669 const std::vector<CSSColors::CSSColorMapping>& colors) {
[email protected]f5e4b9bf2009-10-08 00:59:59670 EnsureWebKitInitialized();
[email protected]b9ab10c2009-08-07 18:09:55671 size_t num_colors = colors.size();
672 scoped_array<WebKit::WebColorName> color_names(
673 new WebKit::WebColorName[num_colors]);
674 scoped_array<WebKit::WebColor> web_colors(new WebKit::WebColor[num_colors]);
675 size_t i = 0;
676 for (std::vector<CSSColors::CSSColorMapping>::const_iterator it =
677 colors.begin();
678 it != colors.end();
679 ++it, ++i) {
680 color_names[i] = it->first;
681 web_colors[i] = it->second;
682 }
683 WebKit::setNamedColors(color_names.get(), web_colors.get(), num_colors);
684}
685
[email protected]f1a29a02011-10-06 23:08:44686void RenderThreadImpl::OnCreateNewView(const ViewMsg_New_Params& params) {
[email protected]90a3fbb12009-02-28 01:13:47687 EnsureWebKitInitialized();
[email protected]be645db2009-02-06 20:36:33688 // When bringing in render_view, also bring in webkit's glue and jsbindings.
[email protected]310ebd6302011-10-10 19:06:28689 RenderViewImpl::Create(
[email protected]8ab04652010-06-12 02:47:26690 params.parent_window,
691 MSG_ROUTING_NONE,
692 params.renderer_preferences,
693 params.web_preferences,
694 new SharedRenderViewCounter(0),
695 params.view_id,
696 params.session_storage_namespace_id,
697 params.frame_name);
[email protected]7f874dec2009-02-06 01:48:27698}
[email protected]4274e582009-01-27 22:09:56699
[email protected]f1a29a02011-10-06 23:08:44700GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync(
[email protected]7f3a2cf2011-04-06 00:10:50701 content::CauseForGpuLaunch cause_for_gpu_launch) {
[email protected]6217d392010-03-25 22:08:35702 if (gpu_channel_.get()) {
[email protected]1082b1d2010-03-30 00:31:22703 // Do nothing if we already have a GPU channel or are already
704 // establishing one.
[email protected]e09cee42010-11-09 01:50:08705 if (gpu_channel_->state() == GpuChannelHost::kUnconnected ||
706 gpu_channel_->state() == GpuChannelHost::kConnected)
[email protected]b42a9f62011-06-08 20:36:04707 return GetGpuChannel();
[email protected]6217d392010-03-25 22:08:35708
709 // Recreate the channel if it has been lost.
[email protected]e09cee42010-11-09 01:50:08710 if (gpu_channel_->state() == GpuChannelHost::kLost)
[email protected]6217d392010-03-25 22:08:35711 gpu_channel_ = NULL;
712 }
713
714 if (!gpu_channel_.get())
715 gpu_channel_ = new GpuChannelHost;
716
717 // Ask the browser for the channel name.
[email protected]b42a9f62011-06-08 20:36:04718 IPC::ChannelHandle channel_handle;
719 base::ProcessHandle renderer_process_for_gpu;
720 GPUInfo gpu_info;
721 if (!Send(new GpuHostMsg_EstablishGpuChannel(cause_for_gpu_launch,
722 &channel_handle,
723 &renderer_process_for_gpu,
724 &gpu_info)) ||
725 channel_handle.name.empty() ||
726 renderer_process_for_gpu == base::kNullProcessHandle) {
727 // Otherwise cancel the connection.
728 gpu_channel_ = NULL;
729 return NULL;
730 }
[email protected]6217d392010-03-25 22:08:35731
[email protected]b42a9f62011-06-08 20:36:04732 gpu_channel_->set_gpu_info(gpu_info);
733 content::GetContentClient()->SetGpuInfo(gpu_info);
734
735 // Connect to the GPU process if a channel name was received.
736 gpu_channel_->Connect(channel_handle, renderer_process_for_gpu);
737
[email protected]f9a2b2fe2010-07-15 21:13:23738 return GetGpuChannel();
[email protected]3bf4d532010-03-27 00:23:34739}
740
[email protected]f1a29a02011-10-06 23:08:44741GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
[email protected]6217d392010-03-25 22:08:35742 if (!gpu_channel_.get())
743 return NULL;
744
[email protected]e09cee42010-11-09 01:50:08745 if (gpu_channel_->state() != GpuChannelHost::kConnected)
[email protected]6217d392010-03-25 22:08:35746 return NULL;
747
748 return gpu_channel_.get();
749}
750
[email protected]f1a29a02011-10-06 23:08:44751void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) {
[email protected]f5e4b9bf2009-10-08 00:59:59752 EnsureWebKitInitialized();
[email protected]b547fd42009-04-23 23:16:27753 // The call below will cause a GetPlugins call with refresh=true, but at this
754 // point we already know that the browser has refreshed its list, so disable
755 // refresh temporarily to prevent each renderer process causing the list to be
756 // regenerated.
757 plugin_refresh_allowed_ = false;
[email protected]b78e168b2009-09-21 22:05:45758 WebKit::resetPluginCache(reload_pages);
[email protected]b547fd42009-04-23 23:16:27759 plugin_refresh_allowed_ = true;
760}
[email protected]85c55dc2009-11-06 03:05:46761
[email protected]f1a29a02011-10-06 23:08:44762void RenderThreadImpl::OnNetworkStateChanged(bool online) {
[email protected]6eac57a2011-07-12 21:15:09763 EnsureWebKitInitialized();
764 WebNetworkStateNotifier::setOnLine(online);
765}
766
[email protected]c6a7b862010-08-20 22:19:38767scoped_refptr<base::MessageLoopProxy>
[email protected]f1a29a02011-10-06 23:08:44768RenderThreadImpl::GetFileThreadMessageLoopProxy() {
[email protected]c6a7b862010-08-20 22:19:38769 DCHECK(message_loop() == MessageLoop::current());
770 if (!file_thread_.get()) {
771 file_thread_.reset(new base::Thread("Renderer::FILE"));
772 file_thread_->Start();
773 }
774 return file_thread_->message_loop_proxy();
775}