Index: chrome/browser/extensions/extension_host.cc |
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc |
index d7cd52829ab2171c9ea3e3db3d92d946e0fbc095..61429630b4697796bc59350aec575c8e046b3f07 100644 |
--- a/chrome/browser/extensions/extension_host.cc |
+++ b/chrome/browser/extensions/extension_host.cc |
@@ -84,11 +84,23 @@ class ExtensionHost::ProcessCreationQueue { |
PostTask(); |
} |
+ void DeferCreation(ExtensionHost* host) { |
+ deferred_queue_.push_back(host); |
+ } |
+ |
+ void CreateDeferredRenderViews() { |
+ queue_.splice(queue_.end(), deferred_queue_); |
+ 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); |
+ it = std::find(deferred_queue_.begin(), deferred_queue_.end(), host); |
+ if (it != deferred_queue_.end()) |
+ deferred_queue_.erase(it); |
} |
private: |
@@ -123,6 +135,7 @@ class ExtensionHost::ProcessCreationQueue { |
typedef std::list<ExtensionHost*> Queue; |
Queue queue_; |
+ Queue deferred_queue_; |
bool pending_create_; |
base::WeakPtrFactory<ProcessCreationQueue> ptr_factory_; |
}; |
@@ -231,13 +244,29 @@ void ExtensionHost::CreateRenderViewSoon() { |
if ((render_process_host() && render_process_host()->HasConnection())) { |
// If the process is already started, go ahead and initialize the RenderView |
// synchronously. The process creation is the real meaty part that we want |
+ // to rate limit. |
+ CreateRenderViewNow(); |
+ } else { |
+ ProcessCreationQueue::GetInstance()->CreateSoon(this); |
+ } |
+} |
+ |
+void ExtensionHost::CreateRenderViewDeferred() { |
+ if ((render_process_host() && render_process_host()->HasConnection())) { |
+ // If the process is already started, go ahead and initialize the RenderView |
+ // synchronously. The process creation is the real meaty part that we want |
// to defer. |
CreateRenderViewNow(); |
} else { |
- ProcessCreationQueue::GetInstance()->CreateSoon(this); |
+ ProcessCreationQueue::GetInstance()->DeferCreation(this); |
} |
} |
+// static |
+void ExtensionHost::CreateDeferredRenderViews() { |
+ ProcessCreationQueue::GetInstance()->CreateDeferredRenderViews(); |
+} |
+ |
void ExtensionHost::CreateRenderViewNow() { |
LoadInitialURL(); |
if (is_background_page()) { |