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

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 and improved tests Created 4 years, 3 months 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 26 class NFC final
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Cancels all watch operations. 58 // Cancels all watch operations.
57 ScriptPromise cancelWatch(ScriptState*); 59 ScriptPromise cancelWatch(ScriptState*);
58 60
59 // Implementation of PageVisibilityObserver. 61 // Implementation of PageVisibilityObserver.
60 void pageVisibilityChanged() override; 62 void pageVisibilityChanged() override;
61 63
62 // Interface required by garbage collection. 64 // Interface required by garbage collection.
63 DECLARE_VIRTUAL_TRACE(); 65 DECLARE_VIRTUAL_TRACE();
64 66
65 private: 67 private:
68 // Returns promise with DOMException if feature is not supported
69 // or when context is not secure. Otherwise, returns empty promise.
70 ScriptPromise RejectIfNotSupported(ScriptState*);
dcheng 2016/09/08 04:42:38 Nit: blink naming convention is still camelCaseWit
shalamov 2016/09/22 13:53:22 Done.
71
66 void OnRequestCompleted(ScriptPromiseResolver*, device::nfc::blink::NFCError Ptr); 72 void OnRequestCompleted(ScriptPromiseResolver*, device::nfc::blink::NFCError Ptr);
67 void OnConnectionError(); 73 void OnConnectionError();
74 void OnWatchRegistered(MessageCallback*, ScriptPromiseResolver*, uint32_t id , device::nfc::blink::NFCErrorPtr);
68 75
69 // device::nfc::blink::NFCClient implementation. 76 // device::nfc::blink::NFCClient implementation.
70 void OnWatch(mojo::WTFArray<uint32_t> ids, device::nfc::blink::NFCMessagePtr ) override; 77 void OnWatch(mojo::WTFArray<uint32_t> ids, device::nfc::blink::NFCMessagePtr ) override;
71 78
72 private: 79 private:
73 explicit NFC(LocalFrame*); 80 explicit NFC(LocalFrame*);
74 device::nfc::blink::NFCPtr m_nfc; 81 device::nfc::blink::NFCPtr m_nfc;
75 mojo::Binding<device::nfc::blink::NFCClient> m_client; 82 mojo::Binding<device::nfc::blink::NFCClient> m_client;
76 HeapHashSet<Member<ScriptPromiseResolver>> m_requests; 83 HeapHashSet<Member<ScriptPromiseResolver>> m_requests;
84 using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>;
85 WatchCallbacksMap m_callbacks;
77 }; 86 };
78 87
79 } // namespace blink 88 } // namespace blink
80 89
81 #endif // NFC_h 90 #endif // NFC_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698