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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.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
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/BluetoothRemoteGATTServer.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.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" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/inspector/ConsoleMessage.h"
12 #include "modules/bluetooth/BluetoothError.h" 13 #include "modules/bluetooth/BluetoothError.h"
13 #include "modules/bluetooth/BluetoothRemoteGATTService.h" 14 #include "modules/bluetooth/BluetoothRemoteGATTService.h"
14 #include "modules/bluetooth/BluetoothSupplement.h" 15 #include "modules/bluetooth/BluetoothSupplement.h"
15 #include "modules/bluetooth/BluetoothUUID.h" 16 #include "modules/bluetooth/BluetoothUUID.h"
16 #include "public/platform/modules/bluetooth/WebBluetooth.h" 17 #include "public/platform/modules/bluetooth/WebBluetooth.h"
17 #include "wtf/OwnPtr.h" 18 #include "wtf/OwnPtr.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device) 22 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) 75 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState)
75 { 76 {
76 m_connected = false; 77 m_connected = false;
77 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 78 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
78 webbluetooth->disconnect(device()->id()); 79 webbluetooth->disconnect(device()->id());
79 } 80 }
80 81
81 ScriptPromise BluetoothRemoteGATTServer::getPrimaryService(ScriptState* scriptSt ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState) 82 ScriptPromise BluetoothRemoteGATTServer::getPrimaryService(ScriptState* scriptSt ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState)
82 { 83 {
84 #if OS(MACOSX)
85 // TODO(jlebel): Remove when getPrimaryService is implemented.
86 return ScriptPromise::rejectWithDOMException(scriptState,
87 DOMException::create(NotSupportedError,
88 "getPrimaryService is not implemented yet. See https://goo.gl/J6ASzs "));
89 #endif // OS(MACOSX)
90
83 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 91 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
84 92
85 String serviceUUID = BluetoothUUID::getService(service, exceptionState); 93 String serviceUUID = BluetoothUUID::getService(service, exceptionState);
86 if (exceptionState.hadException()) 94 if (exceptionState.hadException())
87 return exceptionState.reject(scriptState); 95 return exceptionState.reject(scriptState);
88 96
89 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 97 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
90 ScriptPromise promise = resolver->promise(); 98 ScriptPromise promise = resolver->promise();
91 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver)); 99 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver));
92 100
93 return promise; 101 return promise;
94 } 102 }
95 103
96 } // namespace blink 104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698