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

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

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 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 #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"
18 #include "chrome/common/extensions/api/image_writer_private.h" 17 #include "chrome/common/extensions/api/image_writer_private.h"
19 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/browser_context_keyed_api_factory.h"
21 #include "url/gurl.h" 21 #include "url/gurl.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 class Profile; 25 class Profile;
26 26
27 namespace content { 27 namespace content {
28 class BrowserContext; 28 class BrowserContext;
29 } 29 }
30 30
31 namespace extensions { 31 namespace extensions {
32 namespace image_writer { 32 namespace image_writer {
33 33
34 class Operation; 34 class Operation;
35 35
36 // Manages image writer operations for the current profile. Including clean-up 36 // Manages image writer operations for the current profile. Including clean-up
37 // and message routing. 37 // and message routing.
38 class OperationManager 38 class OperationManager : public BrowserContextKeyedAPI,
39 : public ProfileKeyedAPI, 39 public content::NotificationObserver,
40 public content::NotificationObserver, 40 public base::SupportsWeakPtr<OperationManager> {
41 public base::SupportsWeakPtr<OperationManager> {
42 public: 41 public:
43 typedef std::string ExtensionId; 42 typedef std::string ExtensionId;
44 43
45 explicit OperationManager(content::BrowserContext* context); 44 explicit OperationManager(content::BrowserContext* context);
46 virtual ~OperationManager(); 45 virtual ~OperationManager();
47 46
48 virtual void Shutdown() OVERRIDE; 47 virtual void Shutdown() OVERRIDE;
49 48
50 // Starts a WriteFromUrl operation. 49 // Starts a WriteFromUrl operation.
51 void StartWriteFromUrl(const ExtensionId& extension_id, 50 void StartWriteFromUrl(const ExtensionId& extension_id,
(...skipping 23 matching lines...) Expand all
75 int progress); 74 int progress);
76 // Callback for completion events. 75 // Callback for completion events.
77 virtual void OnComplete(const ExtensionId& extension_id); 76 virtual void OnComplete(const ExtensionId& extension_id);
78 77
79 // Callback for error events. 78 // Callback for error events.
80 virtual void OnError(const ExtensionId& extension_id, 79 virtual void OnError(const ExtensionId& extension_id,
81 image_writer_api::Stage stage, 80 image_writer_api::Stage stage,
82 int progress, 81 int progress,
83 const std::string& error_message); 82 const std::string& error_message);
84 83
85 // ProfileKeyedAPI 84 // BrowserContextKeyedAPI
86 static ProfileKeyedAPIFactory<OperationManager>* 85 static BrowserContextKeyedAPIFactory<OperationManager>* GetFactoryInstance();
87 GetFactoryInstance();
88 static OperationManager* Get(content::BrowserContext* context); 86 static OperationManager* Get(content::BrowserContext* context);
89 87
90 Profile* profile() { return profile_; } 88 Profile* profile() { return profile_; }
91 89
92 private: 90 private:
93 91
94 static const char* service_name() { 92 static const char* service_name() {
95 return "OperationManager"; 93 return "OperationManager";
96 } 94 }
97 95
98 // NotificationObserver 96 // NotificationObserver
99 virtual void Observe(int type, 97 virtual void Observe(int type,
100 const content::NotificationSource& source, 98 const content::NotificationSource& source,
101 const content::NotificationDetails& details) OVERRIDE; 99 const content::NotificationDetails& details) OVERRIDE;
102 100
103 Operation* GetOperation(const ExtensionId& extension_id); 101 Operation* GetOperation(const ExtensionId& extension_id);
104 void DeleteOperation(const ExtensionId& extension_id); 102 void DeleteOperation(const ExtensionId& extension_id);
105 103
106 friend class ProfileKeyedAPIFactory<OperationManager>; 104 friend class BrowserContextKeyedAPIFactory<OperationManager>;
107 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap; 105 typedef std::map<ExtensionId, scoped_refptr<Operation> > OperationMap;
108 106
109 Profile* profile_; 107 Profile* profile_;
110 OperationMap operations_; 108 OperationMap operations_;
111 content::NotificationRegistrar registrar_; 109 content::NotificationRegistrar registrar_;
112 110
113 base::WeakPtrFactory<OperationManager> weak_factory_; 111 base::WeakPtrFactory<OperationManager> weak_factory_;
114 112
115 DISALLOW_COPY_AND_ASSIGN(OperationManager); 113 DISALLOW_COPY_AND_ASSIGN(OperationManager);
116 }; 114 };
117 115
118 } // namespace image_writer 116 } // namespace image_writer
119 } // namespace extensions 117 } // namespace extensions
120 118
121 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_ H_ 119 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_OPERATION_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698