| OLD | NEW |
| 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/nfc/NFC.h" | 5 #include "modules/nfc/NFC.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8StringResource.h" | 9 #include "bindings/core/v8/V8StringResource.h" |
| 10 #include "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 if (id) { | 692 if (id) { |
| 693 m_callbacks.erase(id); | 693 m_callbacks.erase(id); |
| 694 } else { | 694 } else { |
| 695 return ScriptPromise::rejectWithDOMException( | 695 return ScriptPromise::rejectWithDOMException( |
| 696 scriptState, DOMException::create(NotFoundError)); | 696 scriptState, DOMException::create(NotFoundError)); |
| 697 } | 697 } |
| 698 | 698 |
| 699 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 699 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 700 m_requests.insert(resolver); | 700 m_requests.insert(resolver); |
| 701 m_nfc->CancelWatch(id, convertToBaseCallback(WTF::bind( | 701 m_nfc->CancelWatch(id, |
| 702 &NFC::OnRequestCompleted, wrapPersistent(this), | 702 convertToBaseCallback(WTF::bind( |
| 703 wrapPersistent(resolver)))); | 703 &NFC::OnRequestCompleted, wrapPersistent(this), |
| 704 wrapPersistent(resolver)))); |
| 704 return resolver->promise(); | 705 return resolver->promise(); |
| 705 } | 706 } |
| 706 | 707 |
| 707 // https://w3c.github.io/web-nfc/#dom-nfc-cancelwatch | 708 // https://w3c.github.io/web-nfc/#dom-nfc-cancelwatch |
| 708 // If watchId is not provided to nfc.cancelWatch, cancel all watch operations. | 709 // If watchId is not provided to nfc.cancelWatch, cancel all watch operations. |
| 709 ScriptPromise NFC::cancelWatch(ScriptState* scriptState) { | 710 ScriptPromise NFC::cancelWatch(ScriptState* scriptState) { |
| 710 ScriptPromise promise = rejectIfNotSupported(scriptState); | 711 ScriptPromise promise = rejectIfNotSupported(scriptState); |
| 711 if (!promise.isEmpty()) | 712 if (!promise.isEmpty()) |
| 712 return promise; | 713 return promise; |
| 713 | 714 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 825 } |
| 825 | 826 |
| 826 DEFINE_TRACE(NFC) { | 827 DEFINE_TRACE(NFC) { |
| 827 PageVisibilityObserver::trace(visitor); | 828 PageVisibilityObserver::trace(visitor); |
| 828 ContextLifecycleObserver::trace(visitor); | 829 ContextLifecycleObserver::trace(visitor); |
| 829 visitor->trace(m_requests); | 830 visitor->trace(m_requests); |
| 830 visitor->trace(m_callbacks); | 831 visitor->trace(m_callbacks); |
| 831 } | 832 } |
| 832 | 833 |
| 833 } // namespace blink | 834 } // namespace blink |
| OLD | NEW |