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" |
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/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "chrome/browser/extensions/api/image_writer_private/image_writer_privat
e_api.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/operation.h" | 16 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
17 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 17 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | |
19 #include "chrome/common/extensions/api/image_writer_private.h" | 18 #include "chrome/common/extensions/api/image_writer_private.h" |
20 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
22 #include "url/gurl.h" | 21 #include "url/gurl.h" |
23 | 22 |
24 namespace image_writer_api = extensions::api::image_writer_private; | 23 namespace image_writer_api = extensions::api::image_writer_private; |
25 | 24 |
| 25 class Profile; |
| 26 |
| 27 namespace content { |
| 28 class BrowserContext; |
| 29 } |
| 30 |
26 namespace extensions { | 31 namespace extensions { |
27 namespace image_writer { | 32 namespace image_writer { |
28 | 33 |
29 class Operation; | 34 class Operation; |
30 | 35 |
31 // Manages image writer operations for the current profile. Including clean-up | 36 // Manages image writer operations for the current profile. Including clean-up |
32 // and message routing. | 37 // and message routing. |
33 class OperationManager | 38 class OperationManager |
34 : public ProfileKeyedAPI, | 39 : public ProfileKeyedAPI, |
35 public content::NotificationObserver, | 40 public content::NotificationObserver, |
36 public base::SupportsWeakPtr<OperationManager> { | 41 public base::SupportsWeakPtr<OperationManager> { |
37 public: | 42 public: |
38 typedef std::string ExtensionId; | 43 typedef std::string ExtensionId; |
39 | 44 |
40 explicit OperationManager(Profile* profile); | 45 explicit OperationManager(content::BrowserContext* context); |
41 virtual ~OperationManager(); | 46 virtual ~OperationManager(); |
42 | 47 |
43 virtual void Shutdown() OVERRIDE; | 48 virtual void Shutdown() OVERRIDE; |
44 | 49 |
45 // Starts a WriteFromUrl operation. | 50 // Starts a WriteFromUrl operation. |
46 void StartWriteFromUrl(const ExtensionId& extension_id, | 51 void StartWriteFromUrl(const ExtensionId& extension_id, |
47 GURL url, | 52 GURL url, |
48 const std::string& hash, | 53 const std::string& hash, |
49 const std::string& device_path, | 54 const std::string& device_path, |
50 const Operation::StartWriteCallback& callback); | 55 const Operation::StartWriteCallback& callback); |
(...skipping 22 matching lines...) Expand all Loading... |
73 | 78 |
74 // Callback for error events. | 79 // Callback for error events. |
75 virtual void OnError(const ExtensionId& extension_id, | 80 virtual void OnError(const ExtensionId& extension_id, |
76 image_writer_api::Stage stage, | 81 image_writer_api::Stage stage, |
77 int progress, | 82 int progress, |
78 const std::string& error_message); | 83 const std::string& error_message); |
79 | 84 |
80 // ProfileKeyedAPI | 85 // ProfileKeyedAPI |
81 static ProfileKeyedAPIFactory<OperationManager>* | 86 static ProfileKeyedAPIFactory<OperationManager>* |
82 GetFactoryInstance(); | 87 GetFactoryInstance(); |
83 static OperationManager* Get(Profile* profile); | 88 static OperationManager* Get(content::BrowserContext* context); |
84 | 89 |
85 Profile* profile() { return profile_; } | 90 Profile* profile() { return profile_; } |
86 | 91 |
87 private: | 92 private: |
88 | 93 |
89 static const char* service_name() { | 94 static const char* service_name() { |
90 return "OperationManager"; | 95 return "OperationManager"; |
91 } | 96 } |
92 | 97 |
93 // NotificationObserver | 98 // NotificationObserver |
(...skipping 13 matching lines...) Expand all Loading... |
107 | 112 |
108 base::WeakPtrFactory<OperationManager> weak_factory_; | 113 base::WeakPtrFactory<OperationManager> weak_factory_; |
109 | 114 |
110 DISALLOW_COPY_AND_ASSIGN(OperationManager); | 115 DISALLOW_COPY_AND_ASSIGN(OperationManager); |
111 }; | 116 }; |
112 | 117 |
113 } // namespace image_writer | 118 } // namespace image_writer |
114 } // namespace extensions | 119 } // namespace extensions |
115 | 120 |
116 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_
H_ | 121 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_
H_ |
OLD | NEW |