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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/operation_manager.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 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 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 "base/lazy_instance.h" 5 #include "base/lazy_instance.h"
6 #include "chrome/browser/browser_process.h" 6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h" 7 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h"
9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" 8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 9 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
11 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
12 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope ration.h" 11 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope ration.h"
13 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper ation.h" 12 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper ation.h"
14 #include "chrome/browser/extensions/event_router_forwarder.h" 13 #include "chrome/browser/extensions/event_router_forwarder.h"
15 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
19 #include "extensions/browser/event_router.h" 18 #include "extensions/browser/event_router.h"
20 #include "extensions/browser/extension_host.h" 19 #include "extensions/browser/extension_host.h"
21 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
21 #include "extensions/browser/notification_types.h"
22 22
23 namespace image_writer_api = extensions::api::image_writer_private; 23 namespace image_writer_api = extensions::api::image_writer_private;
24 24
25 namespace extensions { 25 namespace extensions {
26 namespace image_writer { 26 namespace image_writer {
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 OperationManager::OperationManager(content::BrowserContext* context) 30 OperationManager::OperationManager(content::BrowserContext* context)
31 : browser_context_(context), 31 : browser_context_(context),
32 extension_registry_observer_(this), 32 extension_registry_observer_(this),
33 weak_factory_(this) { 33 weak_factory_(this) {
34 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); 34 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
35 Profile* profile = Profile::FromBrowserContext(browser_context_); 35 Profile* profile = Profile::FromBrowserContext(browser_context_);
36 registrar_.Add(this, 36 registrar_.Add(this,
37 chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 37 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
38 content::Source<Profile>(profile)); 38 content::Source<Profile>(profile));
39 registrar_.Add(this, 39 registrar_.Add(this,
40 chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, 40 extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
41 content::Source<Profile>(profile)); 41 content::Source<Profile>(profile));
42 registrar_.Add(this, 42 registrar_.Add(this,
43 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, 43 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
44 content::Source<Profile>(profile)); 44 content::Source<Profile>(profile));
45 } 45 }
46 46
47 OperationManager::~OperationManager() { 47 OperationManager::~OperationManager() {
48 } 48 }
49 49
50 void OperationManager::Shutdown() { 50 void OperationManager::Shutdown() {
51 for (OperationMap::iterator iter = operations_.begin(); 51 for (OperationMap::iterator iter = operations_.begin();
52 iter != operations_.end(); 52 iter != operations_.end();
53 iter++) { 53 iter++) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 content::BrowserContext* browser_context, 222 content::BrowserContext* browser_context,
223 const Extension* extension, 223 const Extension* extension,
224 UnloadedExtensionInfo::Reason reason) { 224 UnloadedExtensionInfo::Reason reason) {
225 DeleteOperation(extension->id()); 225 DeleteOperation(extension->id());
226 } 226 }
227 227
228 void OperationManager::Observe(int type, 228 void OperationManager::Observe(int type,
229 const content::NotificationSource& source, 229 const content::NotificationSource& source,
230 const content::NotificationDetails& details) { 230 const content::NotificationDetails& details) {
231 switch (type) { 231 switch (type) {
232 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { 232 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: {
233 DeleteOperation(content::Details<const Extension>(details).ptr()->id()); 233 DeleteOperation(content::Details<const Extension>(details).ptr()->id());
234 break; 234 break;
235 } 235 }
236 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: { 236 case extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: {
237 DeleteOperation( 237 DeleteOperation(
238 content::Details<ExtensionHost>(details)->extension()->id()); 238 content::Details<ExtensionHost>(details)->extension()->id());
239 break; 239 break;
240 } 240 }
241 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 241 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
242 DeleteOperation( 242 DeleteOperation(
243 content::Details<ExtensionHost>(details)->extension()->id()); 243 content::Details<ExtensionHost>(details)->extension()->id());
244 break; 244 break;
245 } 245 }
246 default: { 246 default: {
247 NOTREACHED(); 247 NOTREACHED();
248 break; 248 break;
249 } 249 }
250 } 250 }
251 } 251 }
252 252
253 OperationManager* OperationManager::Get(content::BrowserContext* context) { 253 OperationManager* OperationManager::Get(content::BrowserContext* context) {
254 return BrowserContextKeyedAPIFactory<OperationManager>::Get(context); 254 return BrowserContextKeyedAPIFactory<OperationManager>::Get(context);
255 } 255 }
256 256
257 static base::LazyInstance<BrowserContextKeyedAPIFactory<OperationManager> > 257 static base::LazyInstance<BrowserContextKeyedAPIFactory<OperationManager> >
258 g_factory = LAZY_INSTANCE_INITIALIZER; 258 g_factory = LAZY_INSTANCE_INITIALIZER;
259 259
260 BrowserContextKeyedAPIFactory<OperationManager>* 260 BrowserContextKeyedAPIFactory<OperationManager>*
261 OperationManager::GetFactoryInstance() { 261 OperationManager::GetFactoryInstance() {
262 return g_factory.Pointer(); 262 return g_factory.Pointer();
263 } 263 }
264 264
265 265
266 } // namespace image_writer 266 } // namespace image_writer
267 } // namespace extensions 267 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698