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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_socket/bluetooth_socket_api.h

Issue 278663002: Implement chrome.bluetoothSocket.listenUsing*() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix BluetoothAdapterMac include typo Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SOCKET_BLUETOOTH_SOCKET_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 // BluetoothSocketAsyncApiFunction: 113 // BluetoothSocketAsyncApiFunction:
114 virtual bool Prepare() OVERRIDE; 114 virtual bool Prepare() OVERRIDE;
115 virtual void Work() OVERRIDE; 115 virtual void Work() OVERRIDE;
116 116
117 private: 117 private:
118 scoped_ptr<bluetooth_socket::SetPaused::Params> params_; 118 scoped_ptr<bluetooth_socket::SetPaused::Params> params_;
119 BluetoothSocketEventDispatcher* socket_event_dispatcher_; 119 BluetoothSocketEventDispatcher* socket_event_dispatcher_;
120 }; 120 };
121 121
122 class BluetoothSocketListenUsingRfcommFunction : public AsyncExtensionFunction { 122 class BluetoothSocketListenFunction : public BluetoothSocketAsyncApiFunction {
123 public:
124 BluetoothSocketListenFunction();
125
126 virtual bool CreateParams() = 0;
127 virtual void CreateService(
128 scoped_refptr<device::BluetoothAdapter> adapter,
129 const device::BluetoothUUID& uuid,
130 const device::BluetoothAdapter::CreateServiceCallback& callback,
131 const device::BluetoothAdapter::CreateServiceErrorCallback&
132 error_callback) = 0;
133 virtual void CreateResults() = 0;
134
135 virtual int socket_id() const = 0;
136 virtual const std::string& uuid() const = 0;
137
138 // BluetoothSocketAsyncApiFunction:
139 virtual bool Prepare() OVERRIDE;
140 virtual void AsyncWorkStart() OVERRIDE;
141
142 protected:
143 virtual ~BluetoothSocketListenFunction();
144
145 virtual void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
146 virtual void OnCreateService(scoped_refptr<device::BluetoothSocket> socket);
147 virtual void OnCreateServiceError(const std::string& message);
148
149 BluetoothSocketEventDispatcher* socket_event_dispatcher_;
150 };
151
152 class BluetoothSocketListenUsingRfcommFunction
153 : public BluetoothSocketListenFunction {
123 public: 154 public:
124 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingRfcomm", 155 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingRfcomm",
125 BLUETOOTHSOCKET_LISTENUSINGRFCOMM); 156 BLUETOOTHSOCKET_LISTENUSINGRFCOMM);
126 157
158 BluetoothSocketListenUsingRfcommFunction();
159
160 // BluetoothSocketListenFunction:
161 virtual int socket_id() const OVERRIDE;
162 virtual const std::string& uuid() const OVERRIDE;
163
164 virtual bool CreateParams() OVERRIDE;
165 virtual void CreateService(
166 scoped_refptr<device::BluetoothAdapter> adapter,
167 const device::BluetoothUUID& uuid,
168 const device::BluetoothAdapter::CreateServiceCallback& callback,
169 const device::BluetoothAdapter::CreateServiceErrorCallback&
170 error_callback) OVERRIDE;
171 virtual void CreateResults() OVERRIDE;
172
127 protected: 173 protected:
128 virtual ~BluetoothSocketListenUsingRfcommFunction() {} 174 virtual ~BluetoothSocketListenUsingRfcommFunction();
129 175
130 // AsyncExtensionFunction override: 176 private:
131 virtual bool RunAsync() OVERRIDE; 177 scoped_ptr<bluetooth_socket::ListenUsingRfcomm::Params> params_;
132 }; 178 };
133 179
134 class BluetoothSocketListenUsingInsecureRfcommFunction 180 class BluetoothSocketListenUsingInsecureRfcommFunction
135 : public AsyncExtensionFunction { 181 : public BluetoothSocketListenFunction {
136 public: 182 public:
137 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingInsecureRfcomm", 183 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingInsecureRfcomm",
138 BLUETOOTHSOCKET_LISTENUSINGINSECURERFCOMM); 184 BLUETOOTHSOCKET_LISTENUSINGINSECURERFCOMM);
139 185
186 BluetoothSocketListenUsingInsecureRfcommFunction();
187
188 // BluetoothSocketListenFunction:
189 virtual int socket_id() const OVERRIDE;
190 virtual const std::string& uuid() const OVERRIDE;
191
192 virtual bool CreateParams() OVERRIDE;
193 virtual void CreateService(
194 scoped_refptr<device::BluetoothAdapter> adapter,
195 const device::BluetoothUUID& uuid,
196 const device::BluetoothAdapter::CreateServiceCallback& callback,
197 const device::BluetoothAdapter::CreateServiceErrorCallback&
198 error_callback) OVERRIDE;
199 virtual void CreateResults() OVERRIDE;
200
140 protected: 201 protected:
141 virtual ~BluetoothSocketListenUsingInsecureRfcommFunction() {} 202 virtual ~BluetoothSocketListenUsingInsecureRfcommFunction();
142 203
143 // AsyncExtensionFunction override: 204 private:
144 virtual bool RunAsync() OVERRIDE; 205 scoped_ptr<bluetooth_socket::ListenUsingInsecureRfcomm::Params> params_;
145 }; 206 };
146 207
147 class BluetoothSocketListenUsingL2capFunction : public AsyncExtensionFunction { 208 class BluetoothSocketListenUsingL2capFunction
209 : public BluetoothSocketListenFunction {
148 public: 210 public:
149 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingL2cap", 211 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingL2cap",
150 BLUETOOTHSOCKET_LISTENUSINGL2CAP); 212 BLUETOOTHSOCKET_LISTENUSINGL2CAP);
151 213
214 BluetoothSocketListenUsingL2capFunction();
215
216 // BluetoothSocketListenFunction:
217 virtual int socket_id() const OVERRIDE;
218 virtual const std::string& uuid() const OVERRIDE;
219
220 virtual bool CreateParams() OVERRIDE;
221 virtual void CreateService(
222 scoped_refptr<device::BluetoothAdapter> adapter,
223 const device::BluetoothUUID& uuid,
224 const device::BluetoothAdapter::CreateServiceCallback& callback,
225 const device::BluetoothAdapter::CreateServiceErrorCallback&
226 error_callback) OVERRIDE;
227 virtual void CreateResults() OVERRIDE;
228
152 protected: 229 protected:
153 virtual ~BluetoothSocketListenUsingL2capFunction() {} 230 virtual ~BluetoothSocketListenUsingL2capFunction();
154 231
155 // AsyncExtensionFunction override: 232 private:
156 virtual bool RunAsync() OVERRIDE; 233 scoped_ptr<bluetooth_socket::ListenUsingL2cap::Params> params_;
157 }; 234 };
158 235
159 class BluetoothSocketConnectFunction : public BluetoothSocketAsyncApiFunction { 236 class BluetoothSocketConnectFunction : public BluetoothSocketAsyncApiFunction {
160 public: 237 public:
161 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.connect", 238 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.connect",
162 BLUETOOTHSOCKET_CONNECT); 239 BLUETOOTHSOCKET_CONNECT);
163 240
164 BluetoothSocketConnectFunction(); 241 BluetoothSocketConnectFunction();
165 242
166 protected: 243 protected:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 348
272 // BluetoothSocketAsyncApiFunction: 349 // BluetoothSocketAsyncApiFunction:
273 virtual bool Prepare() OVERRIDE; 350 virtual bool Prepare() OVERRIDE;
274 virtual void Work() OVERRIDE; 351 virtual void Work() OVERRIDE;
275 }; 352 };
276 353
277 } // namespace api 354 } // namespace api
278 } // namespace extensions 355 } // namespace extensions
279 356
280 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H _ 357 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698