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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.h

Issue 168253002: Cleanup many APIs to use ProfileKeyedAPI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BLUETOOTH_BLUETOOTH_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/api/api_function.h" 12 #include "chrome/browser/extensions/api/api_function.h"
13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h " 13 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h "
14 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
15 #include "device/bluetooth/bluetooth_device.h" 15 #include "device/bluetooth/bluetooth_device.h"
16 #include "device/bluetooth/bluetooth_profile.h" 16 #include "device/bluetooth/bluetooth_profile.h"
17 #include "extensions/browser/event_router.h" 17 #include "extensions/browser/event_router.h"
18 18
19 namespace device { 19 namespace device {
20 20
21 class BluetoothAdapter; 21 class BluetoothAdapter;
22 class BluetoothDevice; 22 class BluetoothDevice;
23 class BluetoothSocket; 23 class BluetoothSocket;
24 struct BluetoothOutOfBandPairingData; 24 struct BluetoothOutOfBandPairingData;
25 25
26 } // namespace device 26 } // namespace device
27 27
28 namespace extensions { 28 namespace extensions {
29 29
30 class ExtensionBluetoothEventRouter; 30 class ExtensionBluetoothEventRouter;
31 31
32 // The profile-keyed service that manages the bluetooth extension API. 32 // The profile-keyed service that manages the bluetooth extension API.
33 class BluetoothAPI : public BrowserContextKeyedService, 33 class BluetoothAPI : public ProfileKeyedAPI, public EventRouter::Observer {
34 public EventRouter::Observer {
35 public: 34 public:
36 // Convenience method to get the BluetoothAPI for a profile. 35 // Convenience method to get the BluetoothAPI for a profile.
37 static BluetoothAPI* Get(Profile* profile); 36 static BluetoothAPI* Get(content::BrowserContext* context);
38 37
39 explicit BluetoothAPI(Profile* profile); 38 static ProfileKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance();
39
40 explicit BluetoothAPI(content::BrowserContext* context);
40 virtual ~BluetoothAPI(); 41 virtual ~BluetoothAPI();
41 42
42 ExtensionBluetoothEventRouter* bluetooth_event_router(); 43 ExtensionBluetoothEventRouter* bluetooth_event_router();
43 44
44 // BrowserContextKeyedService implementation. 45 // BrowserContextKeyedService implementation.
45 virtual void Shutdown() OVERRIDE; 46 virtual void Shutdown() OVERRIDE;
46 47
47 // EventRouter::Observer implementation. 48 // EventRouter::Observer implementation.
48 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; 49 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
49 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE; 50 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
50 51
51 private: 52 private:
53 friend class ProfileKeyedAPIFactory<BluetoothAPI>;
54
55 // ProfileKeyedAPI implementation.
56 static const char* service_name() { return "BluetoothAPI"; }
57 static const bool kServiceRedirectedInIncognito = true;
58 static const bool kServiceIsNULLWhileTesting = true;
59
52 Profile* profile_; 60 Profile* profile_;
53 61
54 // Created lazily on first access. 62 // Created lazily on first access.
55 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; 63 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_;
56 }; 64 };
57 65
58 namespace api { 66 namespace api {
59 67
60 class BluetoothAddProfileFunction : public ChromeAsyncExtensionFunction { 68 class BluetoothAddProfileFunction : public ChromeAsyncExtensionFunction {
61 public: 69 public:
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 278
271 private: 279 private:
272 void OnSuccessCallback(); 280 void OnSuccessCallback();
273 void OnErrorCallback(); 281 void OnErrorCallback();
274 }; 282 };
275 283
276 } // namespace api 284 } // namespace api
277 } // namespace extensions 285 } // namespace extensions
278 286
279 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ 287 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698