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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc

Issue 1966893003: IDL changes for BLE GATT server support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_api.h" 5 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 #include <vector> 10 #include <vector>
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return true; 179 return true;
180 return false; 180 return false;
181 } 181 }
182 182
183 device::BluetoothGattCharacteristic::Properties GetBluetoothProperties( 183 device::BluetoothGattCharacteristic::Properties GetBluetoothProperties(
184 const std::vector<apibtle::CharacteristicProperty>& api_properties) { 184 const std::vector<apibtle::CharacteristicProperty>& api_properties) {
185 device::BluetoothGattCharacteristic::Properties properties = 185 device::BluetoothGattCharacteristic::Properties properties =
186 device::BluetoothGattCharacteristic::PROPERTY_NONE; 186 device::BluetoothGattCharacteristic::PROPERTY_NONE;
187 187
188 static_assert( 188 static_assert(
189 apibtle::CHARACTERISTIC_PROPERTY_LAST == 10, 189 apibtle::CHARACTERISTIC_PROPERTY_LAST == 14,
190 "Update required if the number of characteristic properties changes."); 190 "Update required if the number of characteristic properties changes.");
191 191
192 if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_BROADCAST)) 192 if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_BROADCAST))
193 properties |= device::BluetoothGattCharacteristic::PROPERTY_BROADCAST; 193 properties |= device::BluetoothGattCharacteristic::PROPERTY_BROADCAST;
194 194
195 if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_READ)) 195 if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_READ))
196 properties |= device::BluetoothGattCharacteristic::PROPERTY_READ; 196 properties |= device::BluetoothGattCharacteristic::PROPERTY_READ;
197 if (HasProperty(api_properties, 197 if (HasProperty(api_properties,
198 apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE)) 198 apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE))
199 properties |= 199 properties |=
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 void BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback() { 1310 void BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback() {
1311 Respond(ArgumentList(apibtle::UnregisterService::Results::Create( 1311 Respond(ArgumentList(apibtle::UnregisterService::Results::Create(
1312 apibtle::SERVICE_RESULT_SUCCESS))); 1312 apibtle::SERVICE_RESULT_SUCCESS)));
1313 } 1313 }
1314 1314
1315 void BluetoothLowEnergyUnregisterServiceFunction::ErrorCallback( 1315 void BluetoothLowEnergyUnregisterServiceFunction::ErrorCallback(
1316 BluetoothLowEnergyEventRouter::Status status) { 1316 BluetoothLowEnergyEventRouter::Status status) {
1317 Respond(Error(StatusToString(status))); 1317 Respond(Error(StatusToString(status)));
1318 } 1318 }
1319 1319
1320 // notifyCharacteristicValueChanged:
1321
1322 template class BLEPeripheralExtensionFunction<
1323 apibtle::NotifyCharacteristicValueChanged::Params>;
1324
1325 void BluetoothLowEnergyNotifyCharacteristicValueChangedFunction::DoWork() {
1326 Respond(Error(kErrorPermissionDenied));
1327 }
1328
1329 // removeService:
1330
1331 template class BLEPeripheralExtensionFunction<apibtle::RemoveService::Params>;
1332
1333 void BluetoothLowEnergyRemoveServiceFunction::DoWork() {
1334 Respond(Error(kErrorPermissionDenied));
1335 }
1336
1320 // sendRequestResponse: 1337 // sendRequestResponse:
1321 1338
1322 template class BLEPeripheralExtensionFunction< 1339 template class BLEPeripheralExtensionFunction<
1323 apibtle::SendRequestResponse::Params>; 1340 apibtle::SendRequestResponse::Params>;
1324 1341
1325 void BluetoothLowEnergySendRequestResponseFunction::DoWork() { 1342 void BluetoothLowEnergySendRequestResponseFunction::DoWork() {
1326 std::vector<uint8_t> uint8_vector; 1343 std::vector<uint8_t> uint8_vector;
1327 if (params_->response.value) { 1344 if (params_->response.value) {
1328 uint8_vector.assign(params_->response.value->begin(), 1345 uint8_vector.assign(params_->response.value->begin(),
1329 params_->response.value->end()); 1346 params_->response.value->end());
1330 } 1347 }
1331 event_router_->HandleRequestResponse( 1348 event_router_->HandleRequestResponse(
1332 extension(), params_->response.request_id, params_->response.is_error, 1349 extension(), params_->response.request_id, params_->response.is_error,
1333 uint8_vector); 1350 uint8_vector);
1334 Respond(NoArguments()); 1351 Respond(NoArguments());
1335 } 1352 }
1336 1353
1337 } // namespace api 1354 } // namespace api
1338 } // namespace extensions 1355 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698