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

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

Issue 120863003: Convert ExtensionRegistry to a BrowserContextKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/common/extensions/extension_messages.h" 11 #include "chrome/common/extensions/extension_messages.h"
13 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/site_instance.h" 16 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/extensions_browser_client.h" 19 #include "extensions/browser/extensions_browser_client.h"
20 #include "extensions/browser/process_manager.h" 20 #include "extensions/browser/process_manager.h"
21 #include "extensions/browser/process_map.h" 21 #include "extensions/browser/process_map.h"
22 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
23 #include "extensions/common/manifest_handlers/background_info.h" 23 #include "extensions/common/manifest_handlers/background_info.h"
24 #include "extensions/common/view_type.h" 24 #include "extensions/common/view_type.h"
25 25
26 namespace extensions { 26 namespace extensions {
27 27
28 LazyBackgroundTaskQueue::LazyBackgroundTaskQueue( 28 LazyBackgroundTaskQueue::LazyBackgroundTaskQueue(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 task.Run(NULL); 66 task.Run(NULL);
67 return; 67 return;
68 } 68 }
69 PendingTasksList* tasks_list = NULL; 69 PendingTasksList* tasks_list = NULL;
70 PendingTasksKey key(browser_context, extension_id); 70 PendingTasksKey key(browser_context, extension_id);
71 PendingTasksMap::iterator it = pending_tasks_.find(key); 71 PendingTasksMap::iterator it = pending_tasks_.find(key);
72 if (it == pending_tasks_.end()) { 72 if (it == pending_tasks_.end()) {
73 tasks_list = new PendingTasksList(); 73 tasks_list = new PendingTasksList();
74 pending_tasks_[key] = linked_ptr<PendingTasksList>(tasks_list); 74 pending_tasks_[key] = linked_ptr<PendingTasksList>(tasks_list);
75 75
76 ExtensionService* extension_service = ExtensionSystem::GetForBrowserContext(
77 browser_context)->extension_service();
78 DCHECK(extension_service);
79 const Extension* extension = 76 const Extension* extension =
80 extension_service->extensions()->GetByID(extension_id); 77 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID(
78 extension_id);
81 if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) { 79 if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) {
82 // If this is the first enqueued task, and we're not waiting for the 80 // If this is the first enqueued task, and we're not waiting for the
83 // background page to unload, ensure the background page is loaded. 81 // background page to unload, ensure the background page is loaded.
84 ProcessManager* pm = ExtensionSystem::GetForBrowserContext( 82 ProcessManager* pm = ExtensionSystem::GetForBrowserContext(
85 browser_context)->process_manager(); 83 browser_context)->process_manager();
86 pm->IncrementLazyKeepaliveCount(extension); 84 pm->IncrementLazyKeepaliveCount(extension);
87 // Creating the background host may fail, e.g. if |profile| is incognito 85 // Creating the background host may fail, e.g. if |profile| is incognito
88 // but the extension isn't enabled in incognito mode. 86 // but the extension isn't enabled in incognito mode.
89 if (!pm->CreateBackgroundHost( 87 if (!pm->CreateBackgroundHost(
90 extension, BackgroundInfo::GetBackgroundURL(extension))) { 88 extension, BackgroundInfo::GetBackgroundURL(extension))) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 180 }
183 break; 181 break;
184 } 182 }
185 default: 183 default:
186 NOTREACHED(); 184 NOTREACHED();
187 break; 185 break;
188 } 186 }
189 } 187 }
190 188
191 } // namespace extensions 189 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698