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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTService.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
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/BluetoothRemoteGATTService.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // disconnected so we reject. 69 // disconnected so we reject.
70 if (!m_service->device()->gatt()->RemoveFromActiveAlgorithms( 70 if (!m_service->device()->gatt()->RemoveFromActiveAlgorithms(
71 m_resolver.get())) { 71 m_resolver.get())) {
72 m_resolver->reject( 72 m_resolver->reject(
73 DOMException::create(NetworkError, kGATTServerDisconnected)); 73 DOMException::create(NetworkError, kGATTServerDisconnected));
74 return; 74 return;
75 } 75 }
76 76
77 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) { 77 if (m_quantity == mojom::blink::WebBluetoothGATTQueryQuantity::SINGLE) {
78 DCHECK_EQ(1u, webCharacteristics.size()); 78 DCHECK_EQ(1u, webCharacteristics.size());
79 m_resolver->resolve(BluetoothRemoteGATTCharacteristic::take( 79 m_resolver->resolve(
80 m_resolver, wrapUnique(webCharacteristics[0]), m_service)); 80 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic(
81 m_resolver->getExecutionContext(),
82 wrapUnique(webCharacteristics[0]), m_service));
81 return; 83 return;
82 } 84 }
83 85
84 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> characteristics; 86 HeapVector<Member<BluetoothRemoteGATTCharacteristic>> characteristics;
85 characteristics.reserveInitialCapacity(webCharacteristics.size()); 87 characteristics.reserveInitialCapacity(webCharacteristics.size());
86 for (WebBluetoothRemoteGATTCharacteristicInit* webCharacteristic : 88 for (WebBluetoothRemoteGATTCharacteristicInit* webCharacteristic :
87 webCharacteristics) { 89 webCharacteristics) {
88 characteristics.append(BluetoothRemoteGATTCharacteristic::take( 90 characteristics.append(
89 m_resolver, wrapUnique(webCharacteristic), m_service)); 91 m_service->device()->getOrCreateBluetoothRemoteGATTCharacteristic(
92 m_resolver->getExecutionContext(), wrapUnique(webCharacteristic),
93 m_service));
90 } 94 }
91 m_resolver->resolve(characteristics); 95 m_resolver->resolve(characteristics);
92 } 96 }
93 97
94 void onError( 98 void onError(
95 int32_t 99 int32_t
96 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) 100 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */)
97 override { 101 override {
98 if (!m_resolver->getExecutionContext() || 102 if (!m_resolver->getExecutionContext() ||
99 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 103 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 BluetoothSupplement::fromScriptState(scriptState); 178 BluetoothSupplement::fromScriptState(scriptState);
175 webbluetooth->getCharacteristics( 179 webbluetooth->getCharacteristics(
176 m_webService->serviceInstanceID, static_cast<int32_t>(quantity), 180 m_webService->serviceInstanceID, static_cast<int32_t>(quantity),
177 characteristicsUUID, 181 characteristicsUUID,
178 new GetCharacteristicsCallback(this, quantity, resolver)); 182 new GetCharacteristicsCallback(this, quantity, resolver));
179 183
180 return promise; 184 return promise;
181 } 185 }
182 186
183 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698