| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 namespace api { | 26 namespace api { |
| 27 | 27 |
| 28 class BluetoothSocketEventDispatcher; | 28 class BluetoothSocketEventDispatcher; |
| 29 | 29 |
| 30 // Asynchronous API function that performs its work on the BluetoothApiSocket | 30 // Asynchronous API function that performs its work on the BluetoothApiSocket |
| 31 // thread while providing methods to manage resources of that class. This | 31 // thread while providing methods to manage resources of that class. This |
| 32 // follows the pattern of AsyncApiFunction, but does not derive from it, | 32 // follows the pattern of AsyncApiFunction, but does not derive from it, |
| 33 // because BluetoothApiSocket methods must be called on the UI Thread. | 33 // because BluetoothApiSocket methods must be called on the UI Thread. |
| 34 class BluetoothSocketAsyncApiFunction : public UIThreadExtensionFunction { | 34 class BluetoothSocketAsyncApiFunction : public AsyncExtensionFunction { |
| 35 public: | 35 public: |
| 36 BluetoothSocketAsyncApiFunction(); | 36 BluetoothSocketAsyncApiFunction(); |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 virtual ~BluetoothSocketAsyncApiFunction(); | 39 virtual ~BluetoothSocketAsyncApiFunction(); |
| 40 | 40 |
| 41 // UIThreadExtensionFunction: | 41 // AsyncExtensionFunction: |
| 42 virtual bool RunImpl() OVERRIDE; | 42 virtual bool RunAsync() OVERRIDE; |
| 43 | 43 |
| 44 bool PrePrepare(); | 44 bool PrePrepare(); |
| 45 bool Respond(); | 45 bool Respond(); |
| 46 void AsyncWorkCompleted(); | 46 void AsyncWorkCompleted(); |
| 47 | 47 |
| 48 virtual bool Prepare() = 0; | 48 virtual bool Prepare() = 0; |
| 49 virtual void Work(); | 49 virtual void Work(); |
| 50 virtual void AsyncWorkStart(); | 50 virtual void AsyncWorkStart(); |
| 51 | 51 |
| 52 content::BrowserThread::ID work_thread_id() const; | 52 content::BrowserThread::ID work_thread_id() const; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 // BluetoothSocketAsyncApiFunction: | 108 // BluetoothSocketAsyncApiFunction: |
| 109 virtual bool Prepare() OVERRIDE; | 109 virtual bool Prepare() OVERRIDE; |
| 110 virtual void Work() OVERRIDE; | 110 virtual void Work() OVERRIDE; |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 scoped_ptr<bluetooth_socket::SetPaused::Params> params_; | 113 scoped_ptr<bluetooth_socket::SetPaused::Params> params_; |
| 114 BluetoothSocketEventDispatcher* socket_event_dispatcher_; | 114 BluetoothSocketEventDispatcher* socket_event_dispatcher_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 class BluetoothSocketListenUsingRfcommFunction | 117 class BluetoothSocketListenUsingRfcommFunction : public AsyncExtensionFunction { |
| 118 : public UIThreadExtensionFunction { | |
| 119 public: | 118 public: |
| 120 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingRfcomm", | 119 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingRfcomm", |
| 121 BLUETOOTHSOCKET_LISTENUSINGRFCOMM); | 120 BLUETOOTHSOCKET_LISTENUSINGRFCOMM); |
| 122 | 121 |
| 123 protected: | 122 protected: |
| 124 virtual ~BluetoothSocketListenUsingRfcommFunction() {} | 123 virtual ~BluetoothSocketListenUsingRfcommFunction() {} |
| 125 | 124 |
| 126 // UIThreadExtensionFunction override: | 125 // AsyncExtensionFunction override: |
| 127 virtual bool RunImpl() OVERRIDE; | 126 virtual bool RunAsync() OVERRIDE; |
| 128 }; | 127 }; |
| 129 | 128 |
| 130 class BluetoothSocketListenUsingInsecureRfcommFunction | 129 class BluetoothSocketListenUsingInsecureRfcommFunction |
| 131 : public UIThreadExtensionFunction { | 130 : public AsyncExtensionFunction { |
| 132 public: | 131 public: |
| 133 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingInsecureRfcomm", | 132 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingInsecureRfcomm", |
| 134 BLUETOOTHSOCKET_LISTENUSINGINSECURERFCOMM); | 133 BLUETOOTHSOCKET_LISTENUSINGINSECURERFCOMM); |
| 135 | 134 |
| 136 protected: | 135 protected: |
| 137 virtual ~BluetoothSocketListenUsingInsecureRfcommFunction() {} | 136 virtual ~BluetoothSocketListenUsingInsecureRfcommFunction() {} |
| 138 | 137 |
| 139 // UIThreadExtensionFunction override: | 138 // AsyncExtensionFunction override: |
| 140 virtual bool RunImpl() OVERRIDE; | 139 virtual bool RunAsync() OVERRIDE; |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 class BluetoothSocketListenUsingL2capFunction | 142 class BluetoothSocketListenUsingL2capFunction : public AsyncExtensionFunction { |
| 144 : public UIThreadExtensionFunction { | |
| 145 public: | 143 public: |
| 146 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingL2cap", | 144 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.listenUsingL2cap", |
| 147 BLUETOOTHSOCKET_LISTENUSINGL2CAP); | 145 BLUETOOTHSOCKET_LISTENUSINGL2CAP); |
| 148 | 146 |
| 149 protected: | 147 protected: |
| 150 virtual ~BluetoothSocketListenUsingL2capFunction() {} | 148 virtual ~BluetoothSocketListenUsingL2capFunction() {} |
| 151 | 149 |
| 152 // UIThreadExtensionFunction override: | 150 // AsyncExtensionFunction override: |
| 153 virtual bool RunImpl() OVERRIDE; | 151 virtual bool RunAsync() OVERRIDE; |
| 154 }; | 152 }; |
| 155 | 153 |
| 156 class BluetoothSocketConnectFunction : public UIThreadExtensionFunction { | 154 class BluetoothSocketConnectFunction : public AsyncExtensionFunction { |
| 157 public: | 155 public: |
| 158 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.connect", | 156 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.connect", |
| 159 BLUETOOTHSOCKET_CONNECT); | 157 BLUETOOTHSOCKET_CONNECT); |
| 160 | 158 |
| 161 protected: | 159 protected: |
| 162 virtual ~BluetoothSocketConnectFunction() {} | 160 virtual ~BluetoothSocketConnectFunction() {} |
| 163 | 161 |
| 164 // UIThreadExtensionFunction override: | 162 // AsyncExtensionFunction override: |
| 165 virtual bool RunImpl() OVERRIDE; | 163 virtual bool RunAsync() OVERRIDE; |
| 166 }; | 164 }; |
| 167 | 165 |
| 168 class BluetoothSocketDisconnectFunction | 166 class BluetoothSocketDisconnectFunction |
| 169 : public BluetoothSocketAsyncApiFunction { | 167 : public BluetoothSocketAsyncApiFunction { |
| 170 public: | 168 public: |
| 171 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.disconnect", | 169 DECLARE_EXTENSION_FUNCTION("bluetoothSocket.disconnect", |
| 172 BLUETOOTHSOCKET_DISCONNECT); | 170 BLUETOOTHSOCKET_DISCONNECT); |
| 173 | 171 |
| 174 BluetoothSocketDisconnectFunction(); | 172 BluetoothSocketDisconnectFunction(); |
| 175 | 173 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 255 |
| 258 // BluetoothSocketAsyncApiFunction: | 256 // BluetoothSocketAsyncApiFunction: |
| 259 virtual bool Prepare() OVERRIDE; | 257 virtual bool Prepare() OVERRIDE; |
| 260 virtual void Work() OVERRIDE; | 258 virtual void Work() OVERRIDE; |
| 261 }; | 259 }; |
| 262 | 260 |
| 263 } // namespace api | 261 } // namespace api |
| 264 } // namespace extensions | 262 } // namespace extensions |
| 265 | 263 |
| 266 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H
_ | 264 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_SOCKET_BLUETOOTH_SOCKET_API_H
_ |
| OLD | NEW |