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

Side by Side Diff: extensions/browser/lazy_background_task_queue.cc

Issue 1012823002: Revert of Make LoadMonitoringExtensionHostQueue remove itself as an ExtensionHost observer at the... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/lazy_background_task_queue.h" 5 #include "extensions/browser/lazy_background_task_queue.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 bool LazyBackgroundTaskQueue::ShouldEnqueueTask( 42 bool LazyBackgroundTaskQueue::ShouldEnqueueTask(
43 content::BrowserContext* browser_context, 43 content::BrowserContext* browser_context,
44 const Extension* extension) { 44 const Extension* extension) {
45 // Note: browser_context may not be the same as browser_context_ for incognito 45 // Note: browser_context may not be the same as browser_context_ for incognito
46 // extension tasks. 46 // extension tasks.
47 DCHECK(extension); 47 DCHECK(extension);
48 if (BackgroundInfo::HasBackgroundPage(extension)) { 48 if (BackgroundInfo::HasBackgroundPage(extension)) {
49 ProcessManager* pm = ProcessManager::Get(browser_context); 49 ProcessManager* pm = ProcessManager::Get(browser_context);
50 ExtensionHost* background_host = 50 ExtensionHost* background_host =
51 pm->GetBackgroundHostForExtension(extension->id()); 51 pm->GetBackgroundHostForExtension(extension->id());
52 if (!background_host || !background_host->has_loaded_once()) 52 if (!background_host || !background_host->did_stop_loading())
53 return true; 53 return true;
54 if (pm->IsBackgroundHostClosing(extension->id())) 54 if (pm->IsBackgroundHostClosing(extension->id()))
55 pm->CancelSuspend(extension); 55 pm->CancelSuspend(extension);
56 } 56 }
57 57
58 return false; 58 return false;
59 } 59 }
60 60
61 void LazyBackgroundTaskQueue::AddPendingTask( 61 void LazyBackgroundTaskQueue::AddPendingTask(
62 content::BrowserContext* browser_context, 62 content::BrowserContext* browser_context,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 int type, 135 int type,
136 const content::NotificationSource& source, 136 const content::NotificationSource& source,
137 const content::NotificationDetails& details) { 137 const content::NotificationDetails& details) {
138 switch (type) { 138 switch (type) {
139 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 139 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
140 // If an on-demand background page finished loading, dispatch queued up 140 // If an on-demand background page finished loading, dispatch queued up
141 // events for it. 141 // events for it.
142 ExtensionHost* host = 142 ExtensionHost* host =
143 content::Details<ExtensionHost>(details).ptr(); 143 content::Details<ExtensionHost>(details).ptr();
144 if (host->extension_host_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 144 if (host->extension_host_type() == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
145 CHECK(host->has_loaded_once()); 145 CHECK(host->did_stop_loading());
146 ProcessPendingTasks(host, host->browser_context(), host->extension()); 146 ProcessPendingTasks(host, host->browser_context(), host->extension());
147 } 147 }
148 break; 148 break;
149 } 149 }
150 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 150 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
151 // Notify consumers about the load failure when the background host dies. 151 // Notify consumers about the load failure when the background host dies.
152 // This can happen if the extension crashes. This is not strictly 152 // This can happen if the extension crashes. This is not strictly
153 // necessary, since we also unload the extension in that case (which 153 // necessary, since we also unload the extension in that case (which
154 // dispatches the tasks below), but is a good extra precaution. 154 // dispatches the tasks below), but is a good extra precaution.
155 content::BrowserContext* browser_context = 155 content::BrowserContext* browser_context =
(...skipping 21 matching lines...) Expand all
177 // task queue as well. 177 // task queue as well.
178 ExtensionsBrowserClient* browser_client = ExtensionsBrowserClient::Get(); 178 ExtensionsBrowserClient* browser_client = ExtensionsBrowserClient::Get();
179 if (browser_client->HasOffTheRecordContext(browser_context)) { 179 if (browser_client->HasOffTheRecordContext(browser_context)) {
180 ProcessPendingTasks(NULL, 180 ProcessPendingTasks(NULL,
181 browser_client->GetOffTheRecordContext(browser_context), 181 browser_client->GetOffTheRecordContext(browser_context),
182 extension); 182 extension);
183 } 183 }
184 } 184 }
185 185
186 } // namespace extensions 186 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_host.cc ('k') | extensions/browser/load_monitoring_extension_host_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698