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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothAttributeInstanceMap.cpp

Issue 2474863004: bluetooth: Add characteristics to the device's attribute instance map (Closed)
Patch Set: clean up Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "modules/bluetooth/BluetoothAttributeInstanceMap.h" 5 #include "modules/bluetooth/BluetoothAttributeInstanceMap.h"
6 6
7 #include "modules/bluetooth/BluetoothDevice.h" 7 #include "modules/bluetooth/BluetoothDevice.h"
8 #include "modules/bluetooth/BluetoothRemoteGATTService.h" 8 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
9 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic Init.h"
9 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h" 10 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h"
10 #include <memory> 11 #include <memory>
11 #include <utility> 12 #include <utility>
12 13
13 namespace blink { 14 namespace blink {
14 15
15 BluetoothAttributeInstanceMap::BluetoothAttributeInstanceMap( 16 BluetoothAttributeInstanceMap::BluetoothAttributeInstanceMap(
16 BluetoothDevice* device) 17 BluetoothDevice* device)
17 : m_device(device) {} 18 : m_device(device) {}
18 19
(...skipping 12 matching lines...) Expand all
31 } 32 }
32 33
33 return service; 34 return service;
34 } 35 }
35 36
36 bool BluetoothAttributeInstanceMap::containsService( 37 bool BluetoothAttributeInstanceMap::containsService(
37 const String& serviceInstanceId) { 38 const String& serviceInstanceId) {
38 return m_serviceIdToObject.contains(serviceInstanceId); 39 return m_serviceIdToObject.contains(serviceInstanceId);
39 } 40 }
40 41
42 BluetoothRemoteGATTCharacteristic*
43 BluetoothAttributeInstanceMap::getOrCreateBluetoothRemoteGATTCharacteristic(
44 ExecutionContext* context,
45 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> webCharacteristic,
46 BluetoothRemoteGATTService* service) {
47 String characteristicInstanceId = webCharacteristic->characteristicInstanceID;
48
49 BluetoothRemoteGATTCharacteristic* characteristic =
50 m_characteristicIdToObject.get(characteristicInstanceId);
51
52 if (!characteristic) {
53 characteristic = BluetoothRemoteGATTCharacteristic::create(
54 context, std::move(webCharacteristic), service);
55 m_characteristicIdToObject.add(characteristicInstanceId, characteristic);
56 }
57
58 return characteristic;
59 }
60
41 void BluetoothAttributeInstanceMap::Clear() { 61 void BluetoothAttributeInstanceMap::Clear() {
42 m_serviceIdToObject.clear(); 62 m_serviceIdToObject.clear();
43 } 63 }
44 64
45 DEFINE_TRACE(BluetoothAttributeInstanceMap) { 65 DEFINE_TRACE(BluetoothAttributeInstanceMap) {
46 visitor->trace(m_device); 66 visitor->trace(m_device);
47 visitor->trace(m_serviceIdToObject); 67 visitor->trace(m_serviceIdToObject);
68 visitor->trace(m_characteristicIdToObject);
48 } 69 }
49 70
50 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698