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

Side by Side 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 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 #ifndef NFC_h 5 #ifndef NFC_h
6 #define NFC_h 6 #define NFC_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "bindings/modules/v8/StringOrArrayBufferOrNFCMessage.h" 10 #include "bindings/modules/v8/StringOrArrayBufferOrNFCMessage.h"
11 #include "core/dom/ContextLifecycleObserver.h" 11 #include "core/dom/ContextLifecycleObserver.h"
12 #include "core/page/PageVisibilityObserver.h" 12 #include "core/page/PageVisibilityObserver.h"
13 #include "device/nfc/nfc.mojom-blink.h" 13 #include "device/nfc/nfc.mojom-blink.h"
14 #include "modules/nfc/MessageCallback.h"
14 #include "mojo/public/cpp/bindings/binding.h" 15 #include "mojo/public/cpp/bindings/binding.h"
16 #include "wtf/HashMap.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 class MessageCallback; 20 class MessageCallback;
19 class NFCError; 21 class NFCError;
20 class NFCPushOptions; 22 class NFCPushOptions;
21 using NFCPushMessage = StringOrArrayBufferOrNFCMessage; 23 using NFCPushMessage = StringOrArrayBufferOrNFCMessage;
22 class NFCWatchOptions; 24 class NFCWatchOptions;
23 25
24 class NFC final : public GarbageCollectedFinalized<NFC>, 26 class NFC final : public GarbageCollectedFinalized<NFC>,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // Cancels all watch operations. 59 // Cancels all watch operations.
58 ScriptPromise cancelWatch(ScriptState*); 60 ScriptPromise cancelWatch(ScriptState*);
59 61
60 // Implementation of PageVisibilityObserver. 62 // Implementation of PageVisibilityObserver.
61 void pageVisibilityChanged() override; 63 void pageVisibilityChanged() override;
62 64
63 // Interface required by garbage collection. 65 // Interface required by garbage collection.
64 DECLARE_VIRTUAL_TRACE(); 66 DECLARE_VIRTUAL_TRACE();
65 67
66 private: 68 private:
69 // Returns promise with DOMException if feature is not supported
70 // or when context is not secure. Otherwise, returns empty promise.
71 ScriptPromise rejectIfNotSupported(ScriptState*);
72
67 void OnRequestCompleted(ScriptPromiseResolver*, 73 void OnRequestCompleted(ScriptPromiseResolver*,
68 device::nfc::mojom::blink::NFCErrorPtr); 74 device::nfc::mojom::blink::NFCErrorPtr);
69 void OnConnectionError(); 75 void OnConnectionError();
76 void OnWatchRegistered(MessageCallback*,
77 ScriptPromiseResolver*,
78 uint32_t id,
79 device::nfc::mojom::blink::NFCErrorPtr);
70 80
71 // device::nfc::mojom::blink::NFCClient implementation. 81 // device::nfc::mojom::blink::NFCClient implementation.
72 void OnWatch(const WTF::Vector<uint32_t>& ids, 82 void OnWatch(const WTF::Vector<uint32_t>& ids,
73 device::nfc::mojom::blink::NFCMessagePtr) override; 83 device::nfc::mojom::blink::NFCMessagePtr) override;
74 84
75 private: 85 private:
76 explicit NFC(LocalFrame*); 86 explicit NFC(LocalFrame*);
77 device::nfc::mojom::blink::NFCPtr m_nfc; 87 device::nfc::mojom::blink::NFCPtr m_nfc;
78 mojo::Binding<device::nfc::mojom::blink::NFCClient> m_client; 88 mojo::Binding<device::nfc::mojom::blink::NFCClient> m_client;
79 HeapHashSet<Member<ScriptPromiseResolver>> m_requests; 89 HeapHashSet<Member<ScriptPromiseResolver>> m_requests;
90 using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>;
91 WatchCallbacksMap m_callbacks;
80 }; 92 };
81 93
82 } // namespace blink 94 } // namespace blink
83 95
84 #endif // NFC_h 96 #endif // NFC_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698