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

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

Issue 2443063002: bluetooth: Require frame to be connected for stopNotifications to succeed. (Closed)
Patch Set: Fix test expectations 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/LayoutTests/bluetooth/stopNotifications/reconnect-during-success.html ('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/BluetoothRemoteGATTCharacteristic.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.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/DOMDataView.h" 10 #include "core/dom/DOMDataView.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 ScriptPromise BluetoothRemoteGATTCharacteristic::stopNotifications( 348 ScriptPromise BluetoothRemoteGATTCharacteristic::stopNotifications(
349 ScriptState* scriptState) { 349 ScriptState* scriptState) {
350 #if OS(MACOSX) 350 #if OS(MACOSX)
351 // TODO(jlebel): Remove when stopNotifications is implemented. 351 // TODO(jlebel): Remove when stopNotifications is implemented.
352 return ScriptPromise::rejectWithDOMException( 352 return ScriptPromise::rejectWithDOMException(
353 scriptState, DOMException::create(NotSupportedError, 353 scriptState, DOMException::create(NotSupportedError,
354 "stopNotifications is not implemented " 354 "stopNotifications is not implemented "
355 "yet. See https://goo.gl/J6ASzs")); 355 "yet. See https://goo.gl/J6ASzs"));
356 #endif // OS(MACOSX) 356 #endif // OS(MACOSX)
357 357
358 if (!gatt()->connected()) {
359 return ScriptPromise::rejectWithDOMException(
360 scriptState,
361 DOMException::create(NetworkError, kGATTServerNotConnected));
362 }
363
358 WebBluetooth* webbluetooth = 364 WebBluetooth* webbluetooth =
359 BluetoothSupplement::fromScriptState(scriptState); 365 BluetoothSupplement::fromScriptState(scriptState);
360 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 366 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
361 ScriptPromise promise = resolver->promise(); 367 ScriptPromise promise = resolver->promise();
362 webbluetooth->stopNotifications(m_webCharacteristic->characteristicInstanceID, 368 webbluetooth->stopNotifications(m_webCharacteristic->characteristicInstanceID,
363 new NotificationsCallback(this, resolver)); 369 new NotificationsCallback(this, resolver));
364 return promise; 370 return promise;
365 } 371 }
366 372
367 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { 373 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) {
368 visitor->trace(m_service); 374 visitor->trace(m_service);
369 visitor->trace(m_properties); 375 visitor->trace(m_properties);
370 visitor->trace(m_value); 376 visitor->trace(m_value);
371 EventTargetWithInlineData::trace(visitor); 377 EventTargetWithInlineData::trace(visitor);
372 ActiveDOMObject::trace(visitor); 378 ActiveDOMObject::trace(visitor);
373 } 379 }
374 380
375 } // namespace blink 381 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/bluetooth/stopNotifications/reconnect-during-success.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698