diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 22:59:09 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 22:59:09 +0000 |
commit | 552d3a448b43d6f98e0a28793f98099f5e7d7e05 (patch) | |
tree | b4e04f58dbae4bc58e50edcb5a486766019b0620 | |
parent | 753749223c8a87fbd4a9219e89a2f0c4e0d7b60a (diff) | |
download | chromium_src-552d3a448b43d6f98e0a28793f98099f5e7d7e05.zip chromium_src-552d3a448b43d6f98e0a28793f98099f5e7d7e05.tar.gz chromium_src-552d3a448b43d6f98e0a28793f98099f5e7d7e05.tar.bz2 |
Revert r27137: "Create renderers for ExtensionHosts one at a time to avoid
blocking the UI"
BUG=14040
TBR=erikkay
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27143 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/cocoa/extension_view_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 71 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 15 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_view_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/extensions/extension_view.cc | 2 |
6 files changed, 9 insertions, 85 deletions
diff --git a/chrome/browser/cocoa/extension_view_mac.mm b/chrome/browser/cocoa/extension_view_mac.mm index b8e11f7..a64eee8 100644 --- a/chrome/browser/cocoa/extension_view_mac.mm +++ b/chrome/browser/cocoa/extension_view_mac.mm @@ -64,5 +64,5 @@ void ExtensionViewMac::CreateWidgetHostView() { // disappear. [render_widget_host_view_->native_view() retain]; - extension_host_->CreateRenderViewSoon(render_widget_host_view_); + extension_host_->CreateRenderView(render_widget_host_view_); } diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 3d529e7..c83bb46 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -4,11 +4,7 @@ #include "chrome/browser/extensions/extension_host.h" -#include <list> - #include "app/resource_bundle.h" -#include "base/message_loop.h" -#include "base/singleton.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -43,66 +39,6 @@ bool ExtensionHost::enable_dom_automation_ = false; static const char* kToolstripTextColorSubstitution = "$TEXT_COLOR$"; -// Helper class that rate-limits the creation of renderer processes for -// ExtensionHosts, to avoid blocking the UI. -class ExtensionHost::ProcessCreationQueue { - public: - static ProcessCreationQueue* get() { - return Singleton<ProcessCreationQueue>::get(); - } - - // Add a host to the queue for RenderView creation. - void CreateSoon(ExtensionHost* host) { - queue_.push_back(host); - PostTask(); - } - - // Remove a host from the queue (in case it's being deleted). - void Remove(ExtensionHost* host) { - Queue::iterator it = std::find(queue_.begin(), queue_.end(), host); - if (it != queue_.end()) - queue_.erase(it); - } - - private: - friend class Singleton<ProcessCreationQueue>; - friend struct DefaultSingletonTraits<ProcessCreationQueue>; - ProcessCreationQueue() - : pending_create_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } - - // Queue up a delayed task to process the next ExtensionHost in the queue. - void PostTask() { - if (!pending_create_) { - MessageLoop::current()->PostTask(FROM_HERE, - method_factory_.NewRunnableMethod( - &ProcessCreationQueue::ProcessOneHost)); - pending_create_ = true; - } - } - - // Create the RenderView for the next host in the queue. - void ProcessOneHost() { - pending_create_ = false; - if (queue_.empty()) - return; // can happen on shutdown - - queue_.front()->CreateRenderViewNow(); - queue_.pop_front(); - - if (!queue_.empty()) - PostTask(); - } - - typedef std::list<ExtensionHost*> Queue; - Queue queue_; - bool pending_create_; - ScopedRunnableMethodFactory<ProcessCreationQueue> method_factory_; -}; - -//////////////// -// ExtensionHost - ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance, const GURL& url, ViewType::Type host_type) : extension_(extension), @@ -123,7 +59,6 @@ ExtensionHost::~ExtensionHost() { NotificationType::EXTENSION_HOST_DESTROYED, Source<Profile>(profile_), Details<ExtensionHost>(this)); - ProcessCreationQueue::get()->Remove(this); render_view_host_->Shutdown(); // deletes render_view_host } @@ -157,12 +92,8 @@ bool ExtensionHost::IsRenderViewLive() const { return render_view_host_->IsRenderViewLive(); } -void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) { +void ExtensionHost::CreateRenderView(RenderWidgetHostView* host_view) { render_view_host_->set_view(host_view); - ProcessCreationQueue::get()->CreateSoon(this); -} - -void ExtensionHost::CreateRenderViewNow() { render_view_host_->CreateRenderView(); NavigateToURL(url_); DCHECK(IsRenderViewLive()); diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 617cd8e..3b3d64e 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -38,8 +38,6 @@ class ExtensionHost : public RenderViewHostDelegate, public ExtensionFunctionDispatcher::Delegate, public NotificationObserver { public: - class ProcessCreationQueue; - // Enable DOM automation in created render view hosts. static void EnableDOMAutomation() { enable_dom_automation_ = true; } @@ -77,10 +75,10 @@ class ExtensionHost : public RenderViewHostDelegate, // Returns true if the render view is initialized and didn't crash. bool IsRenderViewLive() const; - // Prepares to initializes our RenderViewHost by creating its RenderView and - // navigating to this host's url. Uses host_view for the RenderViewHost's view - // (can be NULL). This happens delayed to avoid locking the UI. - void CreateRenderViewSoon(RenderWidgetHostView* host_view); + // Initializes our RenderViewHost by creating its RenderView and navigating + // to this host's url. Uses host_view for the RenderViewHost's view (can be + // NULL). + void CreateRenderView(RenderWidgetHostView* host_view); // Sets |url_| and navigates |render_view_host_|. void NavigateToURL(const GURL& url); @@ -140,15 +138,10 @@ class ExtensionHost : public RenderViewHostDelegate, const NotificationDetails& details); private: - friend class ProcessCreationQueue; - // Whether to allow DOM automation for created RenderViewHosts. This is used // for testing. static bool enable_dom_automation_; - // Actually create the RenderView for this host. See CreateRenderViewSoon. - void CreateRenderViewNow(); - // ExtensionFunctionDispatcher::Delegate // If this ExtensionHost has a view, this returns the Browser that view is a // part of. If this is a global background page, we use the active Browser diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 5c7d936..a8731d9 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -86,7 +86,7 @@ ExtensionHost* ExtensionProcessManager::CreateBackgroundHost( ExtensionHost* host = new ExtensionHost(extension, GetSiteInstanceForURL(url), url, ViewType::EXTENSION_BACKGROUND_PAGE); - host->CreateRenderViewSoon(NULL); // create a RenderViewHost with no view + host->CreateRenderView(NULL); // create a RenderViewHost with no view OnExtensionHostCreated(host, true); return host; } diff --git a/chrome/browser/gtk/extension_view_gtk.cc b/chrome/browser/gtk/extension_view_gtk.cc index b6bb3a4..4c06cfb 100644 --- a/chrome/browser/gtk/extension_view_gtk.cc +++ b/chrome/browser/gtk/extension_view_gtk.cc @@ -41,5 +41,5 @@ void ExtensionViewGtk::CreateWidgetHostView() { render_widget_host_view_ = new RenderWidgetHostViewGtk(render_view_host()); render_widget_host_view_->InitAsChild(); - extension_host_->CreateRenderViewSoon(render_widget_host_view_); + extension_host_->CreateRenderView(render_widget_host_view_); } diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc index 24ce5f1..4302c93 100644 --- a/chrome/browser/views/extensions/extension_view.cc +++ b/chrome/browser/views/extensions/extension_view.cc @@ -86,7 +86,7 @@ void ExtensionView::CreateWidgetHostView() { NOTIMPLEMENTED(); #endif - host_->CreateRenderViewSoon(view); + host_->CreateRenderView(view); SetVisible(false); if (!pending_background_.empty()) { |