Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 23618014: This defers starting background extension page RenderViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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()) {

Powered by Google App Engine
This is Rietveld 408576698