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

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

Issue 1940923002: bluetooth: Add JS error messages for unimplemented features (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.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/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/ExceptionCode.h"
12 #include "core/inspector/ConsoleMessage.h"
11 #include "modules/bluetooth/BluetoothError.h" 13 #include "modules/bluetooth/BluetoothError.h"
12 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" 14 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h"
13 #include "modules/bluetooth/BluetoothSupplement.h" 15 #include "modules/bluetooth/BluetoothSupplement.h"
14 #include "modules/bluetooth/BluetoothUUID.h" 16 #include "modules/bluetooth/BluetoothUUID.h"
15 #include "public/platform/modules/bluetooth/WebBluetooth.h" 17 #include "public/platform/modules/bluetooth/WebBluetooth.h"
16 18
17 namespace blink { 19 namespace blink {
18 20
19 BluetoothRemoteGATTService::BluetoothRemoteGATTService(PassOwnPtr<WebBluetoothRe moteGATTService> webService) 21 BluetoothRemoteGATTService::BluetoothRemoteGATTService(PassOwnPtr<WebBluetoothRe moteGATTService> webService)
20 : m_webService(std::move(webService)) 22 : m_webService(std::move(webService))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return; 64 return;
63 m_resolver->reject(BluetoothError::take(m_resolver, e)); 65 m_resolver->reject(BluetoothError::take(m_resolver, e));
64 } 66 }
65 private: 67 private:
66 Persistent<ScriptPromiseResolver> m_resolver; 68 Persistent<ScriptPromiseResolver> m_resolver;
67 mojom::WebBluetoothGATTQueryQuantity m_quantity; 69 mojom::WebBluetoothGATTQueryQuantity m_quantity;
68 }; 70 };
69 71
70 ScriptPromise BluetoothRemoteGATTService::getCharacteristic(ScriptState* scriptS tate, const StringOrUnsignedLong& characteristic, ExceptionState& exceptionState ) 72 ScriptPromise BluetoothRemoteGATTService::getCharacteristic(ScriptState* scriptS tate, const StringOrUnsignedLong& characteristic, ExceptionState& exceptionState )
71 { 73 {
74 #if OS(MACOSX)
75 // TODO(jlebel): Remove when getCharacteristic is implemented.
76 return ScriptPromise::rejectWithDOMException(scriptState,
77 DOMException::create(NotSupportedError,
78 "getCharacteristic is not implemented yet. See https://goo.gl/J6ASzs "));
79 #endif // OS(MACOSX)
80
72 String characteristicUUID = BluetoothUUID::getCharacteristic(characteristic, exceptionState); 81 String characteristicUUID = BluetoothUUID::getCharacteristic(characteristic, exceptionState);
73 if (exceptionState.hadException()) 82 if (exceptionState.hadException())
74 return exceptionState.reject(scriptState); 83 return exceptionState.reject(scriptState);
75 84
76 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::SINGLE, characteristicUUID); 85 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::SINGLE, characteristicUUID);
77 } 86 }
78 87
79 ScriptPromise BluetoothRemoteGATTService::getCharacteristics(ScriptState* script State, const StringOrUnsignedLong& characteristic, ExceptionState& exceptionStat e) 88 ScriptPromise BluetoothRemoteGATTService::getCharacteristics(ScriptState* script State, const StringOrUnsignedLong& characteristic, ExceptionState& exceptionStat e)
80 { 89 {
81 String characteristicUUID = BluetoothUUID::getCharacteristic(characteristic, exceptionState); 90 String characteristicUUID = BluetoothUUID::getCharacteristic(characteristic, exceptionState);
82 if (exceptionState.hadException()) 91 if (exceptionState.hadException())
83 return exceptionState.reject(scriptState); 92 return exceptionState.reject(scriptState);
84 93
85 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::MULTIPLE, characteristicUUID); 94 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::MULTIPLE, characteristicUUID);
86 } 95 }
87 96
88 ScriptPromise BluetoothRemoteGATTService::getCharacteristics(ScriptState* script State, ExceptionState&) 97 ScriptPromise BluetoothRemoteGATTService::getCharacteristics(ScriptState* script State, ExceptionState&)
89 { 98 {
90 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::MULTIPLE); 99 return getCharacteristicsImpl(scriptState, mojom::WebBluetoothGATTQueryQuant ity::MULTIPLE);
91 } 100 }
92 101
93 ScriptPromise BluetoothRemoteGATTService::getCharacteristicsImpl(ScriptState* sc riptState, mojom::WebBluetoothGATTQueryQuantity quantity, String characteristics UUID) 102 ScriptPromise BluetoothRemoteGATTService::getCharacteristicsImpl(ScriptState* sc riptState, mojom::WebBluetoothGATTQueryQuantity quantity, String characteristics UUID)
94 { 103 {
104 #if OS(MACOSX)
105 // TODO(jlebel): Remove when getCharacteristics is implemented.
106 return ScriptPromise::rejectWithDOMException(scriptState,
107 DOMException::create(NotSupportedError,
108 "getCharacteristics is not implemented yet. See https://goo.gl/J6ASz s"));
109 #endif // OS(MACOSX)
110
95 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 111 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
96 ScriptPromise promise = resolver->promise(); 112 ScriptPromise promise = resolver->promise();
97 113
98 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 114 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
99 webbluetooth->getCharacteristics(m_webService->serviceInstanceID, quantity, characteristicsUUID, new GetCharacteristicsCallback(quantity, resolver)); 115 webbluetooth->getCharacteristics(m_webService->serviceInstanceID, quantity, characteristicsUUID, new GetCharacteristicsCallback(quantity, resolver));
100 116
101 return promise; 117 return promise;
102 } 118 }
103 119
104 } // namespace blink 120 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698