OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const PendingTask& task) { | 71 const PendingTask& task) { |
72 if (ExtensionsBrowserClient::Get()->IsShuttingDown()) { | 72 if (ExtensionsBrowserClient::Get()->IsShuttingDown()) { |
73 task.Run(NULL); | 73 task.Run(NULL); |
74 return; | 74 return; |
75 } | 75 } |
76 PendingTasksList* tasks_list = NULL; | 76 PendingTasksList* tasks_list = NULL; |
77 PendingTasksKey key(browser_context, extension_id); | 77 PendingTasksKey key(browser_context, extension_id); |
78 PendingTasksMap::iterator it = pending_tasks_.find(key); | 78 PendingTasksMap::iterator it = pending_tasks_.find(key); |
79 if (it == pending_tasks_.end()) { | 79 if (it == pending_tasks_.end()) { |
80 tasks_list = new PendingTasksList(); | 80 tasks_list = new PendingTasksList(); |
81 pending_tasks_[key] = linked_ptr<PendingTasksList>(tasks_list); | 81 pending_tasks_[key] = base::WrapUnique(tasks_list); |
82 | 82 |
83 const Extension* extension = | 83 const Extension* extension = |
84 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID( | 84 ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID( |
85 extension_id); | 85 extension_id); |
86 if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) { | 86 if (extension && BackgroundInfo::HasLazyBackgroundPage(extension)) { |
87 // If this is the first enqueued task, and we're not waiting for the | 87 // If this is the first enqueued task, and we're not waiting for the |
88 // background page to unload, ensure the background page is loaded. | 88 // background page to unload, ensure the background page is loaded. |
89 ProcessManager* pm = ProcessManager::Get(browser_context); | 89 ProcessManager* pm = ProcessManager::Get(browser_context); |
90 pm->IncrementLazyKeepaliveCount(extension); | 90 pm->IncrementLazyKeepaliveCount(extension); |
91 // Creating the background host may fail, e.g. if |profile| is incognito | 91 // Creating the background host may fail, e.g. if |profile| is incognito |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // task queue as well. | 184 // task queue as well. |
185 ExtensionsBrowserClient* browser_client = ExtensionsBrowserClient::Get(); | 185 ExtensionsBrowserClient* browser_client = ExtensionsBrowserClient::Get(); |
186 if (browser_client->HasOffTheRecordContext(browser_context)) { | 186 if (browser_client->HasOffTheRecordContext(browser_context)) { |
187 ProcessPendingTasks(NULL, | 187 ProcessPendingTasks(NULL, |
188 browser_client->GetOffTheRecordContext(browser_context), | 188 browser_client->GetOffTheRecordContext(browser_context), |
189 extension); | 189 extension); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 } // namespace extensions | 193 } // namespace extensions |
OLD | NEW |