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

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

Issue 263393002: Remove NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED from c/b/e/api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
15 #include "chrome/browser/extensions/api/image_writer_private/image_writer_privat e_api.h" 16 #include "chrome/browser/extensions/api/image_writer_private/image_writer_privat e_api.h"
16 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 17 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
17 #include "chrome/common/extensions/api/image_writer_private.h" 18 #include "chrome/common/extensions/api/image_writer_private.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/browser_context_keyed_api_factory.h" 21 #include "extensions/browser/browser_context_keyed_api_factory.h"
22 #include "extensions/browser/extension_registry_observer.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
22 24
23 namespace image_writer_api = extensions::api::image_writer_private; 25 namespace image_writer_api = extensions::api::image_writer_private;
24 26
25 class Profile; 27 class Profile;
26 28
27 namespace content { 29 namespace content {
28 class BrowserContext; 30 class BrowserContext;
29 } 31 }
30 32
31 namespace extensions { 33 namespace extensions {
34 class ExtensionRegistry;
35
32 namespace image_writer { 36 namespace image_writer {
33 37
34 class Operation; 38 class Operation;
35 39
36 // Manages image writer operations for the current profile. Including clean-up 40 // Manages image writer operations for the current profile. Including clean-up
37 // and message routing. 41 // and message routing.
38 class OperationManager : public BrowserContextKeyedAPI, 42 class OperationManager : public BrowserContextKeyedAPI,
39 public content::NotificationObserver, 43 public content::NotificationObserver,
44 public extensions::ExtensionRegistryObserver,
40 public base::SupportsWeakPtr<OperationManager> { 45 public base::SupportsWeakPtr<OperationManager> {
41 public: 46 public:
42 typedef std::string ExtensionId; 47 typedef std::string ExtensionId;
43 48
44 explicit OperationManager(content::BrowserContext* context); 49 explicit OperationManager(content::BrowserContext* context);
45 virtual ~OperationManager(); 50 virtual ~OperationManager();
46 51
47 virtual void Shutdown() OVERRIDE; 52 virtual void Shutdown() OVERRIDE;
48 53
49 // Starts a WriteFromUrl operation. 54 // Starts a WriteFromUrl operation.
(...skipping 28 matching lines...) Expand all
78 // Callback for error events. 83 // Callback for error events.
79 virtual void OnError(const ExtensionId& extension_id, 84 virtual void OnError(const ExtensionId& extension_id,
80 image_writer_api::Stage stage, 85 image_writer_api::Stage stage,
81 int progress, 86 int progress,
82 const std::string& error_message); 87 const std::string& error_message);
83 88
84 // BrowserContextKeyedAPI 89 // BrowserContextKeyedAPI
85 static BrowserContextKeyedAPIFactory<OperationManager>* GetFactoryInstance(); 90 static BrowserContextKeyedAPIFactory<OperationManager>* GetFactoryInstance();
86 static OperationManager* Get(content::BrowserContext* context); 91 static OperationManager* Get(content::BrowserContext* context);
87 92
88 Profile* profile() { return profile_; }
89
90 private: 93 private:
91 94
92 static const char* service_name() { 95 static const char* service_name() {
93 return "OperationManager"; 96 return "OperationManager";
94 } 97 }
95 98
96 // NotificationObserver 99 // NotificationObserver implementation.
97 virtual void Observe(int type, 100 virtual void Observe(int type,
98 const content::NotificationSource& source, 101 const content::NotificationSource& source,
99 const content::NotificationDetails& details) OVERRIDE; 102 const content::NotificationDetails& details) OVERRIDE;
100 103
104 // ExtensionRegistryObserver implementation.
105 virtual void OnExtensionUnloaded(
106 content::BrowserContext* browser_context,
107 const Extension* extension,
108 UnloadedExtensionInfo::Reason reason) OVERRIDE;
109
101 Operation* GetOperation(const ExtensionId& extension_id); 110 Operation* GetOperation(const ExtensionId& extension_id);
102 void DeleteOperation(const ExtensionId& extension_id); 111 void DeleteOperation(const ExtensionId& extension_id);
103 112
104 friend class BrowserContextKeyedAPIFactory<OperationManager>; 113 friend class BrowserContextKeyedAPIFactory<OperationManager>;
105 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap; 114 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap;
106 115
107 Profile* profile_; 116 content::BrowserContext* browser_context_;
108 OperationMap operations_; 117 OperationMap operations_;
109 content::NotificationRegistrar registrar_; 118 content::NotificationRegistrar registrar_;
110 119
120 // Listen to extension unloaded notification.
121 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
122 extension_registry_observer_;
123
111 base::WeakPtrFactory<OperationManager> weak_factory_; 124 base::WeakPtrFactory<OperationManager> weak_factory_;
112 125
113 DISALLOW_COPY_AND_ASSIGN(OperationManager); 126 DISALLOW_COPY_AND_ASSIGN(OperationManager);
114 }; 127 };
115 128
116 } // namespace image_writer 129 } // namespace image_writer
117 } // namespace extensions 130 } // namespace extensions
118 131
119 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_ H_ 132 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698