diff options
Diffstat (limited to 'chrome/browser/renderer_host')
10 files changed, 83 insertions, 86 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 38e163b..076b803 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -404,11 +404,11 @@ void BrowserRenderProcessHost::WidgetHidden() { } void BrowserRenderProcessHost::AddWord(const string16& word) { - base::Thread* io_thread = g_browser_process->io_thread(); SpellChecker* spellchecker = profile()->GetSpellChecker(); if (spellchecker) { - io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( - spellchecker, &SpellChecker::AddWord, word)); + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod(spellchecker, &SpellChecker::AddWord, word)); } } diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc index 45dec61..33e6489 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.cc +++ b/chrome/browser/renderer_host/buffered_resource_handler.cc @@ -404,8 +404,7 @@ bool BufferedResourceHandler::ShouldWaitForPlugins() { AddRef(); ChromeThread::PostTask( ChromeThread::FILE, FROM_HERE, - NewRunnableFunction(&BufferedResourceHandler::LoadPlugins, - this, host_->ui_loop())); + NewRunnableFunction(&BufferedResourceHandler::LoadPlugins, this)); return true; } @@ -469,34 +468,26 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) { GURL(), type, allow_wildcard, &info, NULL); } -void BufferedResourceHandler::LoadPlugins(BufferedResourceHandler* handler, - MessageLoop* main_message_loop) { +void BufferedResourceHandler::LoadPlugins(BufferedResourceHandler* handler) { std::vector<WebPluginInfo> plugins; NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); - // Note, we want to get to the IO thread now, but the file thread outlives it - // so we can't post a task to it directly as it might be in the middle of - // destruction. So hop through the main thread, where the destruction of the - // IO thread happens and hence no race conditions exist. - main_message_loop->PostTask(FROM_HERE, - NewRunnableFunction(&BufferedResourceHandler::NotifyPluginsLoaded, + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableFunction(&BufferedResourceHandler::OnPluginsLoaded, handler)); } -void BufferedResourceHandler::NotifyPluginsLoaded( +void BufferedResourceHandler::OnPluginsLoaded( BufferedResourceHandler* handler) { - g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(handler, &BufferedResourceHandler::OnPluginsLoaded)); -} - -void BufferedResourceHandler::OnPluginsLoaded() { - wait_for_plugins_ = false; - if (request_) { + handler->wait_for_plugins_ = false; + if (handler->request_) { ResourceDispatcherHostRequestInfo* info = - ResourceDispatcherHost::InfoForRequest(request_); - host_->PauseRequest(info->child_id(), info->request_id(), false); - if (!CompleteResponseStarted(info->request_id(), false)) - host_->CancelRequest(info->child_id(), info->request_id(), false); + ResourceDispatcherHost::InfoForRequest(handler->request_); + handler->host_->PauseRequest(info->child_id(), info->request_id(), false); + if (!handler->CompleteResponseStarted(info->request_id(), false)) + handler->host_->CancelRequest( + info->child_id(), info->request_id(), false); } - Release(); + handler->Release(); } diff --git a/chrome/browser/renderer_host/buffered_resource_handler.h b/chrome/browser/renderer_host/buffered_resource_handler.h index 919a675..fa0e249 100644 --- a/chrome/browser/renderer_host/buffered_resource_handler.h +++ b/chrome/browser/renderer_host/buffered_resource_handler.h @@ -62,15 +62,10 @@ class BufferedResourceHandler : public ResourceHandler { bool ShouldDownload(bool* need_plugin_list); // Called on the file thread to load the list of plugins. - static void LoadPlugins(BufferedResourceHandler* handler, - MessageLoop* main_message_loop); - - // Runs on the main thread to notify the IO thread that plugins have been - // loaded. This is needed since the file thread outlives the IO thread. - static void NotifyPluginsLoaded(BufferedResourceHandler* handler); + static void LoadPlugins(BufferedResourceHandler* handler); // Called on the IO thread once the list of plugins has been loaded. - void OnPluginsLoaded(); + static void OnPluginsLoaded(BufferedResourceHandler* handler); scoped_refptr<ResourceHandler> real_handler_; scoped_refptr<ResourceResponse> response_; diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index 6534edf..51a533f 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -6,7 +6,7 @@ #include "base/eintr_wrapper.h" #include "base/thread.h" -#include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" @@ -45,7 +45,6 @@ class RenderWidgetHelper::PaintMsgProxy : public Task { RenderWidgetHelper::RenderWidgetHelper() : render_process_id_(-1), - ui_loop_(MessageLoop::current()), #if defined(OS_WIN) event_(CreateEvent(NULL, FALSE /* auto-reset */, FALSE, NULL)), #elif defined(OS_POSIX) @@ -76,22 +75,23 @@ int RenderWidgetHelper::GetNextRoutingID() { } void RenderWidgetHelper::CancelResourceRequests(int render_widget_id) { - if (g_browser_process->io_thread() && render_process_id_ != -1) { - g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(this, - &RenderWidgetHelper::OnCancelResourceRequests, - render_widget_id)); - } + if (render_process_id_ == -1) + return; + + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod(this, + &RenderWidgetHelper::OnCancelResourceRequests, + render_widget_id)); } void RenderWidgetHelper::CrossSiteClosePageACK( const ViewMsg_ClosePage_Params& params) { - if (g_browser_process->io_thread()) { - g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, - NewRunnableMethod(this, - &RenderWidgetHelper::OnCrossSiteClosePageACK, - params)); - } + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, + NewRunnableMethod(this, + &RenderWidgetHelper::OnCrossSiteClosePageACK, + params)); } bool RenderWidgetHelper::WaitForPaintMsg(int render_widget_id, @@ -161,7 +161,7 @@ void RenderWidgetHelper::DidReceivePaintMsg(const IPC::Message& msg) { event_.Signal(); // The proxy will be deleted when it is run as a task. - ui_loop_->PostTask(FROM_HERE, proxy); + ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, proxy); } void RenderWidgetHelper::OnDiscardPaintMsg(PaintMsgProxy* proxy) { @@ -209,8 +209,10 @@ void RenderWidgetHelper::CreateNewWindow(int opener_id, resource_dispatcher_host_->BlockRequestsForRoute( render_process_id_, *route_id); - ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &RenderWidgetHelper::OnCreateWindowOnUI, opener_id, *route_id)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &RenderWidgetHelper::OnCreateWindowOnUI, opener_id, *route_id)); } void RenderWidgetHelper::OnCreateWindowOnUI(int opener_id, int route_id) { @@ -218,7 +220,8 @@ void RenderWidgetHelper::OnCreateWindowOnUI(int opener_id, int route_id) { if (host) host->CreateNewWindow(route_id); - g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, NewRunnableMethod(this, &RenderWidgetHelper::OnCreateWindowOnIO, route_id)); } @@ -232,9 +235,11 @@ void RenderWidgetHelper::CreateNewWidget(int opener_id, bool activatable, int* route_id) { *route_id = GetNextRoutingID(); - ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( - this, &RenderWidgetHelper::OnCreateWidgetOnUI, opener_id, *route_id, - activatable)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &RenderWidgetHelper::OnCreateWidgetOnUI, opener_id, *route_id, + activatable)); } void RenderWidgetHelper::OnCreateWidgetOnUI( diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h index 2b3b445..d3593da 100644 --- a/chrome/browser/renderer_host/render_widget_helper.h +++ b/chrome/browser/renderer_host/render_widget_helper.h @@ -23,7 +23,6 @@ namespace base { class TimeDelta; } -class MessageLoop; class ResourceDispatcherHost; struct ViewMsg_ClosePage_Params; @@ -120,8 +119,6 @@ class RenderWidgetHelper : // Called on the IO thread when a PaintRect message is received. void DidReceivePaintMsg(const IPC::Message& msg); - MessageLoop* ui_loop() { return ui_loop_; } - void CreateNewWindow(int opener_id, bool user_gesture, base::ProcessHandle render_process, @@ -184,7 +181,6 @@ class RenderWidgetHelper : Lock pending_paints_lock_; int render_process_id_; - MessageLoop* ui_loop_; // Event used to implement WaitForPaintMsg. base::WaitableEvent event_; diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index f10f728..f97d249 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -18,6 +18,7 @@ #include "chrome/browser/browser_accessibility_manager.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_trial.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/plugin_process_host.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -411,7 +412,8 @@ HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) { 0, 0, 0, 0, ::GetParent(window), 0, GetModuleHandle(NULL), 0); DCHECK(parent); ::SetParent(window, parent); - g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, + ChromeThread::PostTask( + ChromeThread::IO, FROM_HERE, new NotifyPluginProcessHostTask(window, parent)); return parent; } diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 4d0d451..c4ccda3 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -234,8 +234,7 @@ void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { // this object for sending messages. audio_renderer_host_->IPCChannelConnected(id(), handle(), this); - WorkerService::GetInstance()->Initialize( - resource_dispatcher_host_, ui_loop()); + WorkerService::GetInstance()->Initialize(resource_dispatcher_host_); appcache_dispatcher_host_->Initialize(this, id(), handle()); socket_stream_dispatcher_host_->Initialize(this, id()); dom_storage_dispatcher_host_->Init(handle()); @@ -430,8 +429,9 @@ void ResourceMessageFilter::OnReceiveContextMenuMsg(const IPC::Message& msg) { // Create a new ViewHostMsg_ContextMenu message. const ViewHostMsg_ContextMenu context_menu_message(msg.routing_id(), params); - ui_loop()->PostTask(FROM_HERE, new ContextMenuMessageDispatcher( - id(), context_menu_message)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + new ContextMenuMessageDispatcher(id(), context_menu_message)); } // Called on the IPC thread: @@ -456,10 +456,6 @@ URLRequestContext* ResourceMessageFilter::GetRequestContext( return request_context->GetURLRequestContext(); } -MessageLoop* ResourceMessageFilter::ui_loop() { - return render_widget_helper_->ui_loop(); -} - void ResourceMessageFilter::OnMsgCreateWindow( int opener_id, bool user_gesture, int* route_id) { render_widget_helper_->CreateNewWindow(opener_id, @@ -704,7 +700,8 @@ void ResourceMessageFilter::OnClipboardWriteObjects( Clipboard::DuplicateRemoteHandles(handle(), long_living_objects); #endif - ui_loop()->PostTask(FROM_HERE, new WriteClipboardTask(long_living_objects)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, new WriteClipboardTask(long_living_objects)); } #if !defined(OS_LINUX) @@ -823,8 +820,9 @@ void ResourceMessageFilter::OnResourceTypeStats( static_cast<int>(stats.fonts.size / 1024)); // We need to notify the TaskManager of these statistics from the UI // thread. - ui_loop()->PostTask( - FROM_HERE, NewRunnableFunction( + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableFunction( &ResourceMessageFilter::OnResourceTypeStatsOnUIThread, stats, base::GetProcId(handle()))); @@ -1170,7 +1168,8 @@ void ResourceMessageFilter::OnKeygen(uint32 key_size_index, #if defined(USE_TCMALLOC) void ResourceMessageFilter::OnRendererTcmalloc(base::ProcessId pid, const std::string& output) { - ui_loop()->PostTask(FROM_HERE, + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, NewRunnableFunction(AboutTcmallocRendererCallback, pid, output)); } #endif diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 1a91466..1c3d520 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -108,7 +108,6 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, ResourceDispatcherHost* resource_dispatcher_host() { return resource_dispatcher_host_; } - MessageLoop* ui_loop(); bool off_the_record() { return off_the_record_; } CallbackWithReturnValue<int>::Type* next_route_id_callback() { return next_route_id_callback_.get(); diff --git a/chrome/browser/renderer_host/resource_message_filter_gtk.cc b/chrome/browser/renderer_host/resource_message_filter_gtk.cc index f8c8986..5ed8fb0 100644 --- a/chrome/browser/renderer_host/resource_message_filter_gtk.cc +++ b/chrome/browser/renderer_host/resource_message_filter_gtk.cc @@ -248,33 +248,41 @@ void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId view, void ResourceMessageFilter::OnClipboardIsFormatAvailable( Clipboard::FormatType format, Clipboard::Buffer buffer, IPC::Message* reply_msg) { - ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( - this, &ResourceMessageFilter::DoOnClipboardIsFormatAvailable, format, - buffer, reply_msg)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::DoOnClipboardIsFormatAvailable, format, + buffer, reply_msg)); } // Called on the IO thread. void ResourceMessageFilter::OnClipboardReadText(Clipboard::Buffer buffer, IPC::Message* reply_msg) { - ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( - this, &ResourceMessageFilter::DoOnClipboardReadText, buffer, - reply_msg)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::DoOnClipboardReadText, buffer, + reply_msg)); } // Called on the IO thread. void ResourceMessageFilter::OnClipboardReadAsciiText(Clipboard::Buffer buffer, IPC::Message* reply_msg) { - ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( - this, &ResourceMessageFilter::DoOnClipboardReadAsciiText, buffer, - reply_msg)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::DoOnClipboardReadAsciiText, buffer, + reply_msg)); } // Called on the IO thread. void ResourceMessageFilter::OnClipboardReadHTML(Clipboard::Buffer buffer, IPC::Message* reply_msg) { - ui_loop()->PostTask(FROM_HERE, NewRunnableMethod( - this, &ResourceMessageFilter::DoOnClipboardReadHTML, buffer, - reply_msg)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, + NewRunnableMethod( + this, &ResourceMessageFilter::DoOnClipboardReadHTML, buffer, + reply_msg)); } // Called on the IO thread. @@ -298,7 +306,7 @@ void ResourceMessageFilter::OnTempFileForPrintingWritten(int fd_in_browser) { } #if defined(TOOLKIT_GTK) - PrintDialogGtk::CreatePrintDialogForPdf(it->second, ui_loop()); + PrintDialogGtk::CreatePrintDialogForPdf(it->second); #else NOTIMPLEMENTED(); #endif diff --git a/chrome/browser/renderer_host/resource_message_filter_mac.mm b/chrome/browser/renderer_host/resource_message_filter_mac.mm index f7687c9..ef83622 100644 --- a/chrome/browser/renderer_host/resource_message_filter_mac.mm +++ b/chrome/browser/renderer_host/resource_message_filter_mac.mm @@ -8,6 +8,7 @@ #include "base/message_loop.h" #include "base/sys_string_conversions.h" +#include "chrome/browser/chrome_thread.h" #import "chrome/browser/cocoa/find_pasteboard.h" // The number of utf16 code units that will be written to the find pasteboard, @@ -35,7 +36,8 @@ void ResourceMessageFilter::OnClipboardFindPboardWriteString( NSString* nsText = base::SysUTF16ToNSString(text); if (nsText) { // FindPasteboard must be used on the UI thread. - ui_loop()->PostTask(FROM_HERE, new WriteFindPboardTask(nsText)); + ChromeThread::PostTask( + ChromeThread::UI, FROM_HERE, new WriteFindPboardTask(nsText)); } } } |