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

Unified Diff: third_party/WebKit/Source/modules/nfc/NFC.h

Issue 1759373003: [webnfc] Implement nfc.watch in blink nfc module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implement_nfc_push_in_android
Patch Set: Rebased to master 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/nfc/NFC.h
diff --git a/third_party/WebKit/Source/modules/nfc/NFC.h b/third_party/WebKit/Source/modules/nfc/NFC.h
index 9dabcebd9ed9a131c70ed78c1bacb3024f771656..2847d87f7629afb40de46613315eccc6eaf37c19 100644
--- a/third_party/WebKit/Source/modules/nfc/NFC.h
+++ b/third_party/WebKit/Source/modules/nfc/NFC.h
@@ -11,7 +11,9 @@
#include "core/dom/ContextLifecycleObserver.h"
#include "core/page/PageVisibilityObserver.h"
#include "device/nfc/nfc.mojom-blink.h"
+#include "modules/nfc/MessageCallback.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "wtf/HashMap.h"
namespace blink {
@@ -64,9 +66,17 @@ class NFC final : public GarbageCollectedFinalized<NFC>,
DECLARE_VIRTUAL_TRACE();
private:
+ // Returns promise with DOMException if feature is not supported
+ // or when context is not secure. Otherwise, returns empty promise.
+ ScriptPromise rejectIfNotSupported(ScriptState*);
+
void OnRequestCompleted(ScriptPromiseResolver*,
device::nfc::mojom::blink::NFCErrorPtr);
void OnConnectionError();
+ void OnWatchRegistered(MessageCallback*,
+ ScriptPromiseResolver*,
+ uint32_t id,
+ device::nfc::mojom::blink::NFCErrorPtr);
// device::nfc::mojom::blink::NFCClient implementation.
void OnWatch(const WTF::Vector<uint32_t>& ids,
@@ -77,6 +87,8 @@ class NFC final : public GarbageCollectedFinalized<NFC>,
device::nfc::mojom::blink::NFCPtr m_nfc;
mojo::Binding<device::nfc::mojom::blink::NFCClient> m_client;
HeapHashSet<Member<ScriptPromiseResolver>> m_requests;
+ using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>;
+ WatchCallbacksMap m_callbacks;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698