| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 return resolver->promise(); | 683 return resolver->promise(); |
| 684 } | 684 } |
| 685 | 685 |
| 686 // https://w3c.github.io/web-nfc/#dom-nfc-cancelwatch | 686 // https://w3c.github.io/web-nfc/#dom-nfc-cancelwatch |
| 687 ScriptPromise NFC::cancelWatch(ScriptState* scriptState, long id) { | 687 ScriptPromise NFC::cancelWatch(ScriptState* scriptState, long id) { |
| 688 ScriptPromise promise = rejectIfNotSupported(scriptState); | 688 ScriptPromise promise = rejectIfNotSupported(scriptState); |
| 689 if (!promise.isEmpty()) | 689 if (!promise.isEmpty()) |
| 690 return promise; | 690 return promise; |
| 691 | 691 |
| 692 if (id) { | 692 if (id) { |
| 693 m_callbacks.remove(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, convertToBaseCallback(WTF::bind( |
| 702 &NFC::OnRequestCompleted, wrapPersistent(this), | 702 &NFC::OnRequestCompleted, wrapPersistent(this), |
| 703 wrapPersistent(resolver)))); | 703 wrapPersistent(resolver)))); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 824 } |
| 825 | 825 |
| 826 DEFINE_TRACE(NFC) { | 826 DEFINE_TRACE(NFC) { |
| 827 PageVisibilityObserver::trace(visitor); | 827 PageVisibilityObserver::trace(visitor); |
| 828 ContextLifecycleObserver::trace(visitor); | 828 ContextLifecycleObserver::trace(visitor); |
| 829 visitor->trace(m_requests); | 829 visitor->trace(m_requests); |
| 830 visitor->trace(m_callbacks); | 830 visitor->trace(m_callbacks); |
| 831 } | 831 } |
| 832 | 832 |
| 833 } // namespace blink | 833 } // namespace blink |
| OLD | NEW |