summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 18:49:28 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 18:49:28 +0000
commite5ed44e3fb8e120b36a666d1c65fdfa750b6c579 (patch)
tree0a8bc0ffb074ae1f9f81cc6d1335df049ec13a49 /chrome/browser
parent24f46397f8a0e0b02167ab0807f13ad5637c4345 (diff)
downloadchromium_src-e5ed44e3fb8e120b36a666d1c65fdfa750b6c579.zip
chromium_src-e5ed44e3fb8e120b36a666d1c65fdfa750b6c579.tar.gz
chromium_src-e5ed44e3fb8e120b36a666d1c65fdfa750b6c579.tar.bz2
Revert old change that created an ExtensionHost's RenderView asynchronously.
With jam's recent change to spawn renderers from a background thread, ExtensionHost spawns processes asynchronously for free. Reverting this change also fixes a bug due to an extension popup closing before the next one can be created. BUG=28049 Review URL: http://codereview.chromium.org/399098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/extension_view_mac.mm2
-rw-r--r--chrome/browser/extensions/extension_host.cc71
-rw-r--r--chrome/browser/extensions/extension_host.h15
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc2
-rw-r--r--chrome/browser/gtk/extension_view_gtk.cc2
-rw-r--r--chrome/browser/views/extensions/extension_view.cc2
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 171cc30..c3ef722c 100644
--- a/chrome/browser/cocoa/extension_view_mac.mm
+++ b/chrome/browser/cocoa/extension_view_mac.mm
@@ -75,5 +75,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 7bf6c7b..9fce7cd 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -4,13 +4,9 @@
#include "chrome/browser/extensions/extension_host.h"
-#include <list>
-
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/keyboard_codes.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"
@@ -53,66 +49,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),
@@ -137,7 +73,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
}
@@ -171,13 +106,9 @@ bool ExtensionHost::IsRenderViewLive() const {
return render_view_host_->IsRenderViewLive();
}
-void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
+void ExtensionHost::CreateRenderView(RenderWidgetHostView* host_view) {
LOG(INFO) << "Creating RenderView for " + extension_->name();
render_view_host_->set_view(host_view);
- ProcessCreationQueue::get()->CreateSoon(this);
-}
-
-void ExtensionHost::CreateRenderViewNow() {
render_view_host_->CreateRenderView(profile_->GetRequestContext());
NavigateToURL(url_);
DCHECK(IsRenderViewLive());
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 9407b85..552bc8c 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -44,8 +44,6 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate,
public NotificationObserver,
public JavaScriptMessageBoxClient {
public:
- class ProcessCreationQueue;
-
// Enable DOM automation in created render view hosts.
static void EnableDOMAutomation() { enable_dom_automation_ = true; }
@@ -84,10 +82,10 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate,
// 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);
@@ -158,15 +156,10 @@ class ExtensionHost : public ExtensionPopupHost::PopupDelegate,
virtual TabContents* AsTabContents() { return NULL; }
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 02587a4..25a1fc2 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -106,7 +106,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 691ce54..3bbac61 100644
--- a/chrome/browser/gtk/extension_view_gtk.cc
+++ b/chrome/browser/gtk/extension_view_gtk.cc
@@ -49,7 +49,7 @@ 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_);
}
void ExtensionViewGtk::RenderViewCreated() {
diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc
index 7945307..b8bb0a6 100644
--- a/chrome/browser/views/extensions/extension_view.cc
+++ b/chrome/browser/views/extensions/extension_view.cc
@@ -108,7 +108,7 @@ void ExtensionView::CreateWidgetHostView() {
NOTIMPLEMENTED();
#endif
- host_->CreateRenderViewSoon(view);
+ host_->CreateRenderView(view);
SetVisible(false);
}