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 #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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class OperationManager : public BrowserContextKeyedAPI, | 42 class OperationManager : public BrowserContextKeyedAPI, |
43 public content::NotificationObserver, | 43 public content::NotificationObserver, |
44 public extensions::ExtensionRegistryObserver, | 44 public extensions::ExtensionRegistryObserver, |
45 public base::SupportsWeakPtr<OperationManager> { | 45 public base::SupportsWeakPtr<OperationManager> { |
46 public: | 46 public: |
47 typedef std::string ExtensionId; | 47 typedef std::string ExtensionId; |
48 | 48 |
49 explicit OperationManager(content::BrowserContext* context); | 49 explicit OperationManager(content::BrowserContext* context); |
50 virtual ~OperationManager(); | 50 virtual ~OperationManager(); |
51 | 51 |
52 virtual void Shutdown() OVERRIDE; | 52 virtual void Shutdown() override; |
53 | 53 |
54 // Starts a WriteFromUrl operation. | 54 // Starts a WriteFromUrl operation. |
55 void StartWriteFromUrl(const ExtensionId& extension_id, | 55 void StartWriteFromUrl(const ExtensionId& extension_id, |
56 GURL url, | 56 GURL url, |
57 const std::string& hash, | 57 const std::string& hash, |
58 const std::string& device_path, | 58 const std::string& device_path, |
59 const Operation::StartWriteCallback& callback); | 59 const Operation::StartWriteCallback& callback); |
60 | 60 |
61 // Starts a WriteFromFile operation. | 61 // Starts a WriteFromFile operation. |
62 void StartWriteFromFile(const ExtensionId& extension_id, | 62 void StartWriteFromFile(const ExtensionId& extension_id, |
(...skipping 29 matching lines...) Expand all Loading... |
92 | 92 |
93 private: | 93 private: |
94 | 94 |
95 static const char* service_name() { | 95 static const char* service_name() { |
96 return "OperationManager"; | 96 return "OperationManager"; |
97 } | 97 } |
98 | 98 |
99 // NotificationObserver implementation. | 99 // NotificationObserver implementation. |
100 virtual void Observe(int type, | 100 virtual void Observe(int type, |
101 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
102 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) override; |
103 | 103 |
104 // ExtensionRegistryObserver implementation. | 104 // ExtensionRegistryObserver implementation. |
105 virtual void OnExtensionUnloaded( | 105 virtual void OnExtensionUnloaded( |
106 content::BrowserContext* browser_context, | 106 content::BrowserContext* browser_context, |
107 const Extension* extension, | 107 const Extension* extension, |
108 UnloadedExtensionInfo::Reason reason) OVERRIDE; | 108 UnloadedExtensionInfo::Reason reason) override; |
109 | 109 |
110 Operation* GetOperation(const ExtensionId& extension_id); | 110 Operation* GetOperation(const ExtensionId& extension_id); |
111 void DeleteOperation(const ExtensionId& extension_id); | 111 void DeleteOperation(const ExtensionId& extension_id); |
112 | 112 |
113 friend class BrowserContextKeyedAPIFactory<OperationManager>; | 113 friend class BrowserContextKeyedAPIFactory<OperationManager>; |
114 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap; | 114 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap; |
115 | 115 |
116 content::BrowserContext* browser_context_; | 116 content::BrowserContext* browser_context_; |
117 OperationMap operations_; | 117 OperationMap operations_; |
118 content::NotificationRegistrar registrar_; | 118 content::NotificationRegistrar registrar_; |
119 | 119 |
120 // Listen to extension unloaded notification. | 120 // Listen to extension unloaded notification. |
121 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 121 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
122 extension_registry_observer_; | 122 extension_registry_observer_; |
123 | 123 |
124 base::WeakPtrFactory<OperationManager> weak_factory_; | 124 base::WeakPtrFactory<OperationManager> weak_factory_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(OperationManager); | 126 DISALLOW_COPY_AND_ASSIGN(OperationManager); |
127 }; | 127 }; |
128 | 128 |
129 } // namespace image_writer | 129 } // namespace image_writer |
130 } // namespace extensions | 130 } // namespace extensions |
131 | 131 |
132 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_
H_ | 132 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_
H_ |
OLD | NEW |