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

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

Issue 11075006: Moved bluetooth adapter files to device/bluetooth/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Marked BluetoothReadFunction::Work and BluetoothWriteFunction::Work ChromeOs only. Created 8 years, 2 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 "chrome/browser/extensions/api/api_function.h" 11 #include "chrome/browser/extensions/api/api_function.h"
11 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
13 #include "device/bluetooth/bluetooth_device.h"
12 14
13 #if defined(OS_CHROMEOS) 15 namespace bluetooth {
14 #include "base/memory/ref_counted.h"
15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
16 #include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h"
17
18 namespace chromeos {
19 16
20 class BluetoothSocket; 17 class BluetoothSocket;
21 struct BluetoothOutOfBandPairingData; 18 struct BluetoothOutOfBandPairingData;
22 19
23 } // namespace chromeos 20 } // namespace bluetooth
24 #endif
25 21
26 namespace extensions { 22 namespace extensions {
27 namespace api { 23 namespace api {
28 24
29 class BluetoothIsAvailableFunction : public SyncExtensionFunction { 25 class BluetoothIsAvailableFunction : public SyncExtensionFunction {
30 public: 26 public:
31 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable") 27 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.isAvailable")
32 28
33 protected: 29 protected:
34 virtual ~BluetoothIsAvailableFunction() {} 30 virtual ~BluetoothIsAvailableFunction() {}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 virtual ~BluetoothGetNameFunction() {} 63 virtual ~BluetoothGetNameFunction() {}
68 64
69 // ExtensionFunction: 65 // ExtensionFunction:
70 virtual bool RunImpl() OVERRIDE; 66 virtual bool RunImpl() OVERRIDE;
71 }; 67 };
72 68
73 class BluetoothGetDevicesFunction : public AsyncExtensionFunction { 69 class BluetoothGetDevicesFunction : public AsyncExtensionFunction {
74 public: 70 public:
75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getDevices") 71 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getDevices")
76 72
77 #if defined(OS_CHROMEOS)
78 BluetoothGetDevicesFunction(); 73 BluetoothGetDevicesFunction();
79 #endif
80 74
81 protected: 75 protected:
82 virtual ~BluetoothGetDevicesFunction() {} 76 virtual ~BluetoothGetDevicesFunction() {}
83 77
84 // ExtensionFunction: 78 // ExtensionFunction:
85 virtual bool RunImpl() OVERRIDE; 79 virtual bool RunImpl() OVERRIDE;
86 80
87 private: 81 private:
88 #if defined(OS_CHROMEOS) 82 void DispatchDeviceSearchResult(const bluetooth::BluetoothDevice& device);
89 void DispatchDeviceSearchResult(const chromeos::BluetoothDevice& device); 83 void ProvidesServiceCallback(const bluetooth::BluetoothDevice* device,
90 void ProvidesServiceCallback(const chromeos::BluetoothDevice* device,
91 bool providesService); 84 bool providesService);
92 85
93 int callbacks_pending_; 86 int callbacks_pending_;
94 #endif
95 }; 87 };
96 88
97 class BluetoothGetServicesFunction : public AsyncExtensionFunction { 89 class BluetoothGetServicesFunction : public AsyncExtensionFunction {
98 public: 90 public:
99 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices") 91 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.getServices")
100 92
101 protected: 93 protected:
102 virtual ~BluetoothGetServicesFunction() {} 94 virtual ~BluetoothGetServicesFunction() {}
103 95
104 // ExtensionFunction: 96 // ExtensionFunction:
105 virtual bool RunImpl() OVERRIDE; 97 virtual bool RunImpl() OVERRIDE;
106 98
107 #if defined(OS_CHROMEOS)
108 private: 99 private:
109 void GetServiceRecordsCallback( 100 void GetServiceRecordsCallback(
110 base::ListValue* services, 101 base::ListValue* services,
111 const chromeos::BluetoothDevice::ServiceRecordList& records); 102 const bluetooth::BluetoothDevice::ServiceRecordList& records);
112 void OnErrorCallback(); 103 void OnErrorCallback();
113 #endif
114 }; 104 };
115 105
116 class BluetoothConnectFunction : public AsyncExtensionFunction { 106 class BluetoothConnectFunction : public AsyncExtensionFunction {
117 public: 107 public:
118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect") 108 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.connect")
119 109
120 protected: 110 protected:
121 virtual ~BluetoothConnectFunction() {} 111 virtual ~BluetoothConnectFunction() {}
122 112
123 virtual bool RunImpl() OVERRIDE; 113 virtual bool RunImpl() OVERRIDE;
124 114
125 private: 115 private:
126 #if defined(OS_CHROMEOS)
127 void ConnectToServiceCallback( 116 void ConnectToServiceCallback(
128 const chromeos::BluetoothDevice* device, 117 const bluetooth::BluetoothDevice* device,
129 const std::string& service_uuid, 118 const std::string& service_uuid,
130 scoped_refptr<chromeos::BluetoothSocket> socket); 119 scoped_refptr<bluetooth::BluetoothSocket> socket);
131 #endif
132 }; 120 };
133 121
134 class BluetoothDisconnectFunction : public SyncExtensionFunction { 122 class BluetoothDisconnectFunction : public SyncExtensionFunction {
135 public: 123 public:
136 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect") 124 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.disconnect")
137 125
138 protected: 126 protected:
139 virtual ~BluetoothDisconnectFunction() {} 127 virtual ~BluetoothDisconnectFunction() {}
140 128
141 // ExtensionFunction: 129 // ExtensionFunction:
142 virtual bool RunImpl() OVERRIDE; 130 virtual bool RunImpl() OVERRIDE;
143 }; 131 };
144 132
145 class BluetoothReadFunction : public AsyncApiFunction { 133 class BluetoothReadFunction : public AsyncApiFunction {
146 public: 134 public:
147 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.read") 135 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.read")
148 BluetoothReadFunction(); 136 BluetoothReadFunction();
149 137
150 protected: 138 protected:
151 virtual ~BluetoothReadFunction(); 139 virtual ~BluetoothReadFunction();
152 140
153 // AsyncApiFunction: 141 // AsyncApiFunction:
154 virtual bool Prepare() OVERRIDE; 142 virtual bool Prepare() OVERRIDE;
155 virtual bool Respond() OVERRIDE; 143 virtual bool Respond() OVERRIDE;
156 virtual void Work() OVERRIDE; 144 virtual void Work() OVERRIDE;
157 145
158 private: 146 private:
159 #if defined(OS_CHROMEOS)
160 bool success_; 147 bool success_;
161 scoped_refptr<chromeos::BluetoothSocket> socket_; 148 scoped_refptr<bluetooth::BluetoothSocket> socket_;
162 #endif
163 }; 149 };
164 150
165 class BluetoothWriteFunction : public AsyncApiFunction { 151 class BluetoothWriteFunction : public AsyncApiFunction {
166 public: 152 public:
167 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write") 153 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.write")
168 BluetoothWriteFunction(); 154 BluetoothWriteFunction();
169 155
170 protected: 156 protected:
171 virtual ~BluetoothWriteFunction(); 157 virtual ~BluetoothWriteFunction();
172 158
173 // AsyncApiFunction: 159 // AsyncApiFunction:
174 virtual bool Prepare() OVERRIDE; 160 virtual bool Prepare() OVERRIDE;
175 virtual bool Respond() OVERRIDE; 161 virtual bool Respond() OVERRIDE;
176 virtual void Work() OVERRIDE; 162 virtual void Work() OVERRIDE;
177 163
178 private: 164 private:
179 #if defined(OS_CHROMEOS)
180 bool success_; 165 bool success_;
181 const base::BinaryValue* data_to_write_; // memory is owned by args_ 166 const base::BinaryValue* data_to_write_; // memory is owned by args_
182 scoped_refptr<chromeos::BluetoothSocket> socket_; 167 scoped_refptr<bluetooth::BluetoothSocket> socket_;
183 #endif
184 }; 168 };
185 169
186 class BluetoothSetOutOfBandPairingDataFunction 170 class BluetoothSetOutOfBandPairingDataFunction
187 : public AsyncExtensionFunction { 171 : public AsyncExtensionFunction {
188 public: 172 public:
189 DECLARE_EXTENSION_FUNCTION_NAME( 173 DECLARE_EXTENSION_FUNCTION_NAME(
190 "experimental.bluetooth.setOutOfBandPairingData") 174 "experimental.bluetooth.setOutOfBandPairingData")
191 175
192 protected: 176 protected:
193 virtual ~BluetoothSetOutOfBandPairingDataFunction() {} 177 virtual ~BluetoothSetOutOfBandPairingDataFunction() {}
194 178
195 #if defined(OS_CHROMEOS)
196 void OnSuccessCallback(); 179 void OnSuccessCallback();
197 void OnErrorCallback(); 180 void OnErrorCallback();
198 #endif
199 181
200 // ExtensionFunction: 182 // ExtensionFunction:
201 virtual bool RunImpl() OVERRIDE; 183 virtual bool RunImpl() OVERRIDE;
202 }; 184 };
203 185
204 class BluetoothGetLocalOutOfBandPairingDataFunction 186 class BluetoothGetLocalOutOfBandPairingDataFunction
205 : public AsyncExtensionFunction { 187 : public AsyncExtensionFunction {
206 public: 188 public:
207 DECLARE_EXTENSION_FUNCTION_NAME( 189 DECLARE_EXTENSION_FUNCTION_NAME(
208 "experimental.bluetooth.getLocalOutOfBandPairingData") 190 "experimental.bluetooth.getLocalOutOfBandPairingData")
209 191
210 protected: 192 protected:
211 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {} 193 virtual ~BluetoothGetLocalOutOfBandPairingDataFunction() {}
212 194
213 #if defined(OS_CHROMEOS) 195 void ReadCallback(
214 void ReadCallback(const chromeos::BluetoothOutOfBandPairingData& data); 196 const bluetooth::BluetoothOutOfBandPairingData& data);
215 void ErrorCallback(); 197 void ErrorCallback();
216 #endif
217 198
218 // ExtensionFunction: 199 // ExtensionFunction:
219 virtual bool RunImpl() OVERRIDE; 200 virtual bool RunImpl() OVERRIDE;
220 }; 201 };
221 202
222 class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction { 203 class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction {
223 public: 204 public:
224 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.startDiscovery") 205 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.startDiscovery")
225 206
226 protected: 207 protected:
227 virtual ~BluetoothStartDiscoveryFunction() {} 208 virtual ~BluetoothStartDiscoveryFunction() {}
228 209
229 // ExtensionFunction: 210 // ExtensionFunction:
230 virtual bool RunImpl() OVERRIDE; 211 virtual bool RunImpl() OVERRIDE;
231 212
232 #if defined(OS_CHROMEOS)
233 private: 213 private:
234 void OnSuccessCallback(); 214 void OnSuccessCallback();
235 void OnErrorCallback(); 215 void OnErrorCallback();
236 #endif
237 }; 216 };
238 217
239 class BluetoothStopDiscoveryFunction : public AsyncExtensionFunction { 218 class BluetoothStopDiscoveryFunction : public AsyncExtensionFunction {
240 public: 219 public:
241 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.stopDiscovery") 220 DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.stopDiscovery")
242 221
243 protected: 222 protected:
244 virtual ~BluetoothStopDiscoveryFunction() {} 223 virtual ~BluetoothStopDiscoveryFunction() {}
245 224
246 // ExtensionFunction: 225 // ExtensionFunction:
247 virtual bool RunImpl() OVERRIDE; 226 virtual bool RunImpl() OVERRIDE;
248 227
249 #if defined(OS_CHROMEOS)
250 private: 228 private:
251 void OnSuccessCallback(); 229 void OnSuccessCallback();
252 void OnErrorCallback(); 230 void OnErrorCallback();
253 #endif
254 }; 231 };
255 232
256 } // namespace api 233 } // namespace api
257 } // namespace extensions 234 } // namespace extensions
258 235
259 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_ 236 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698