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

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

Issue 11743024: Implemented BluetoothExtensionFunction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth/bluetooth_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/event_router.h" 14 #include "chrome/browser/extensions/event_router.h"
14 #include "chrome/browser/extensions/extension_function.h"
15 #include "chrome/browser/profiles/profile_keyed_service.h" 15 #include "chrome/browser/profiles/profile_keyed_service.h"
16 #include "device/bluetooth/bluetooth_device.h" 16 #include "device/bluetooth/bluetooth_device.h"
17 17
18 namespace device { 18 namespace device {
19 19
20 class BluetoothAdapter;
21 class BluetoothDevice;
20 class BluetoothSocket; 22 class BluetoothSocket;
21 struct BluetoothOutOfBandPairingData; 23 struct BluetoothOutOfBandPairingData;
22 24
23 } // namespace device 25 } // namespace device
24 26
25 namespace extensions { 27 namespace extensions {
26 28
27 class ExtensionBluetoothEventRouter; 29 class ExtensionBluetoothEventRouter;
28 30
29 // The profile-keyed service that manages the bluetooth extension API. 31 // The profile-keyed service that manages the bluetooth extension API.
(...skipping 17 matching lines...) Expand all
47 49
48 private: 50 private:
49 Profile* profile_; 51 Profile* profile_;
50 52
51 // Created lazily on first access. 53 // Created lazily on first access.
52 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_; 54 scoped_ptr<ExtensionBluetoothEventRouter> bluetooth_event_router_;
53 }; 55 };
54 56
55 namespace api { 57 namespace api {
56 58
57 class BluetoothGetAdapterStateFunction : public SyncExtensionFunction { 59 class BluetoothGetAdapterStateFunction : public BluetoothExtensionFunction {
58 public: 60 public:
59 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getAdapterState") 61 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getAdapterState")
60 62
61 protected: 63 protected:
62 virtual ~BluetoothGetAdapterStateFunction() {} 64 virtual ~BluetoothGetAdapterStateFunction() {}
63 65
64 // ExtensionFunction: 66 // BluetoothExtensionFunction:
65 virtual bool RunImpl() OVERRIDE; 67 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
66 }; 68 };
67 69
68 class BluetoothGetDevicesFunction : public AsyncExtensionFunction { 70 class BluetoothGetDevicesFunction : public BluetoothExtensionFunction {
69 public: 71 public:
70 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getDevices") 72 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getDevices")
71 73
72 BluetoothGetDevicesFunction(); 74 BluetoothGetDevicesFunction();
73 75
74 protected: 76 protected:
75 virtual ~BluetoothGetDevicesFunction() {} 77 virtual ~BluetoothGetDevicesFunction() {}
76 78
77 // ExtensionFunction: 79 // BluetoothExtensionFunction:
78 virtual bool RunImpl() OVERRIDE; 80 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
79 81
80 private: 82 private:
81 void DispatchDeviceSearchResult(const device::BluetoothDevice& device); 83 void DispatchDeviceSearchResult(const device::BluetoothDevice& device);
82 void ProvidesServiceCallback(const device::BluetoothDevice* device, 84 void ProvidesServiceCallback(const device::BluetoothDevice* device,
83 bool providesService); 85 bool providesService);
84 void FinishDeviceSearch(); 86 void FinishDeviceSearch();
85 87
86 int callbacks_pending_; 88 int callbacks_pending_;
87 int device_events_sent_; 89 int device_events_sent_;
88 }; 90 };
89 91
90 class BluetoothGetServicesFunction : public AsyncExtensionFunction { 92 class BluetoothGetServicesFunction : public BluetoothExtensionFunction {
91 public: 93 public:
92 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getServices") 94 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getServices")
93 95
94 protected: 96 protected:
95 virtual ~BluetoothGetServicesFunction() {} 97 virtual ~BluetoothGetServicesFunction() {}
96 98
97 // ExtensionFunction: 99 // BluetoothExtensionFunction:
98 virtual bool RunImpl() OVERRIDE; 100 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
99 101
100 private: 102 private:
101 void GetServiceRecordsCallback( 103 void GetServiceRecordsCallback(
102 base::ListValue* services, 104 base::ListValue* services,
103 const device::BluetoothDevice::ServiceRecordList& records); 105 const device::BluetoothDevice::ServiceRecordList& records);
104 void OnErrorCallback(); 106 void OnErrorCallback();
105 }; 107 };
106 108
107 class BluetoothConnectFunction : public AsyncExtensionFunction { 109 class BluetoothConnectFunction : public BluetoothExtensionFunction {
108 public: 110 public:
109 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.connect") 111 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.connect")
110 112
111 protected: 113 protected:
112 virtual ~BluetoothConnectFunction() {} 114 virtual ~BluetoothConnectFunction() {}
113 115
114 virtual bool RunImpl() OVERRIDE; 116 // BluetoothExtensionFunction:
117 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
115 118
116 private: 119 private:
117 void ConnectToServiceCallback( 120 void ConnectToServiceCallback(
118 const device::BluetoothDevice* device, 121 const device::BluetoothDevice* device,
119 const std::string& service_uuid, 122 const std::string& service_uuid,
120 scoped_refptr<device::BluetoothSocket> socket); 123 scoped_refptr<device::BluetoothSocket> socket);
121 }; 124 };
122 125
123 class BluetoothDisconnectFunction : public SyncExtensionFunction { 126 class BluetoothDisconnectFunction : public SyncExtensionFunction {
124 public: 127 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 virtual bool Respond() OVERRIDE; 165 virtual bool Respond() OVERRIDE;
163 virtual void Work() OVERRIDE; 166 virtual void Work() OVERRIDE;
164 167
165 private: 168 private:
166 bool success_; 169 bool success_;
167 const base::BinaryValue* data_to_write_; // memory is owned by args_ 170 const base::BinaryValue* data_to_write_; // memory is owned by args_
168 scoped_refptr<device::BluetoothSocket> socket_; 171 scoped_refptr<device::BluetoothSocket> socket_;
169 }; 172 };
170 173
171 class BluetoothSetOutOfBandPairingDataFunction 174 class BluetoothSetOutOfBandPairingDataFunction
172 : public AsyncExtensionFunction { 175 : public BluetoothExtensionFunction {
173 public: 176 public:
174 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.setOutOfBandPairingData") 177 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.setOutOfBandPairingData")
175 178
176 protected: 179 protected:
177 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} 180 virtual ~BluetoothSetOutOfBandPairingDataFunction() {}
178 181
179 void OnSuccessCallback(); 182 void OnSuccessCallback();
180 void OnErrorCallback(); 183 void OnErrorCallback();
181 184
182 // ExtensionFunction: 185 // BluetoothExtensionFunction:
183 virtual bool RunImpl() OVERRIDE; 186 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
184 }; 187 };
185 188
186 class BluetoothGetLocalOutOfBandPairingDataFunction 189 class BluetoothGetLocalOutOfBandPairingDataFunction
187 : public AsyncExtensionFunction { 190 : public BluetoothExtensionFunction {
188 public: 191 public:
189 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getLocalOutOfBandPairingData") 192 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.getLocalOutOfBandPairingData")
190 193
191 protected: 194 protected:
192 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} 195 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {}
193 196
194 void ReadCallback( 197 void ReadCallback(
195 const device::BluetoothOutOfBandPairingData& data); 198 const device::BluetoothOutOfBandPairingData& data);
196 void ErrorCallback(); 199 void ErrorCallback();
197 200
198 // ExtensionFunction: 201 // BluetoothExtensionFunction:
199 virtual bool RunImpl() OVERRIDE; 202 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
200 }; 203 };
201 204
202 class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction { 205 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction {
203 public: 206 public:
204 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.startDiscovery") 207 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.startDiscovery")
205 208
206 protected: 209 protected:
207 virtual ~BluetoothStartDiscoveryFunction() {} 210 virtual ~BluetoothStartDiscoveryFunction() {}
208 211
209 // ExtensionFunction: 212 // BluetoothExtensionFunction:
210 virtual bool RunImpl() OVERRIDE; 213 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
211 214
212 private: 215 private:
213 void OnSuccessCallback(); 216 void OnSuccessCallback();
214 void OnErrorCallback(); 217 void OnErrorCallback();
215 }; 218 };
216 219
217 class BluetoothStopDiscoveryFunction : public AsyncExtensionFunction { 220 class BluetoothStopDiscoveryFunction : public BluetoothExtensionFunction {
218 public: 221 public:
219 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.stopDiscovery") 222 DECLARE_EXTENSION_FUNCTION_NAME("bluetooth.stopDiscovery")
220 223
221 protected: 224 protected:
222 virtual ~BluetoothStopDiscoveryFunction() {} 225 virtual ~BluetoothStopDiscoveryFunction() {}
223 226
224 // ExtensionFunction: 227 // BluetoothExtensionFunction:
225 virtual bool RunImpl() OVERRIDE; 228 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
226 229
227 private: 230 private:
228 void OnSuccessCallback(); 231 void OnSuccessCallback();
229 void OnErrorCallback(); 232 void OnErrorCallback();
230 }; 233 };
231 234
232 } // namespace api 235 } // namespace api
233 } // namespace extensions 236 } // namespace extensions
234 237
235 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ 238 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/bluetooth/bluetooth_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698