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

Side by Side Diff: third_party/WebKit/Source/modules/nfc/NFC.h

Issue 1708543002: [webnfc] Implement push() method in blink nfc module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onionsoup_webnfc
Patch Set: Fixes for Reilly's comments. Created 4 years, 7 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/UnionTypesModules.h" 10 #include "bindings/modules/v8/UnionTypesModules.h"
11 #include "core/frame/LocalFrameLifecycleObserver.h"
12 #include "core/page/PageLifecycleObserver.h" 11 #include "core/page/PageLifecycleObserver.h"
12 #include "device/nfc/nfc.mojom-wtf.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class MessageCallback; 16 class MessageCallback;
17 class NFCError;
17 class NFCPushOptions; 18 class NFCPushOptions;
18 using NFCPushMessage = StringOrArrayBufferOrNFCMessage; 19 using NFCPushMessage = StringOrArrayBufferOrNFCMessage;
19 class NFCWatchOptions; 20 class NFCWatchOptions;
21 class ServiceRegistry;
20 22
21 class NFC final 23 class NFC final
22 : public GarbageCollected<NFC> 24 : public GarbageCollectedFinalized<NFC>
23 , public ScriptWrappable 25 , public ScriptWrappable
24 , public LocalFrameLifecycleObserver
25 , public PageLifecycleObserver { 26 , public PageLifecycleObserver {
26 DEFINE_WRAPPERTYPEINFO(); 27 DEFINE_WRAPPERTYPEINFO();
27 USING_GARBAGE_COLLECTED_MIXIN(NFC); 28 USING_GARBAGE_COLLECTED_MIXIN(NFC);
28 29
29 public: 30 public:
30 static NFC* create(LocalFrame*); 31 static NFC* create(LocalFrame*);
31 32
33 virtual ~NFC();
34
32 // Pushes NFCPushMessage asynchronously to NFC tag / peer. 35 // Pushes NFCPushMessage asynchronously to NFC tag / peer.
33 ScriptPromise push(ScriptState*, const NFCPushMessage&, const NFCPushOptions &); 36 ScriptPromise push(ScriptState*, const NFCPushMessage&, const NFCPushOptions &);
34 37
35 // Cancels ongoing push operation. 38 // Cancels ongoing push operation.
36 ScriptPromise cancelPush(ScriptState*, const String&); 39 ScriptPromise cancelPush(ScriptState*, const String&);
37 40
38 // Starts watching for NFC messages that match NFCWatchOptions criteria. 41 // Starts watching for NFC messages that match NFCWatchOptions criteria.
39 ScriptPromise watch(ScriptState*, MessageCallback*, const NFCWatchOptions&); 42 ScriptPromise watch(ScriptState*, MessageCallback*, const NFCWatchOptions&);
40 43
41 // Cancels watch operation with id. 44 // Cancels watch operation with id.
42 ScriptPromise cancelWatch(ScriptState*, long id); 45 ScriptPromise cancelWatch(ScriptState*, long id);
43 46
44 // Cancels all watch operations. 47 // Cancels all watch operations.
45 ScriptPromise cancelWatch(ScriptState*); 48 ScriptPromise cancelWatch(ScriptState*);
46 49
47 // Implementation of LocalFrameLifecycleObserver.
48 void willDetachFrameHost() override;
49
50 // Implementation of PageLifecycleObserver. 50 // Implementation of PageLifecycleObserver.
51 void pageVisibilityChanged() override; 51 void pageVisibilityChanged() override;
52 52
53 // Interface required by garbage collection. 53 // Interface required by garbage collection.
54 DECLARE_VIRTUAL_TRACE(); 54 DECLARE_VIRTUAL_TRACE();
55 55
56 private: 56 private:
57 bool Initialize(ServiceRegistry*);
58 void OnRequestCompleted(ScriptPromiseResolver*, device::wtf::NFCErrorPtr);
59 void OnConnectionError();
60
61 private:
57 explicit NFC(LocalFrame*); 62 explicit NFC(LocalFrame*);
63 device::wtf::NFCPtr m_nfc;
64 HeapHashSet<Member<ScriptPromiseResolver>> m_requests;
58 }; 65 };
59 66
60 } // namespace blink 67 } // namespace blink
61 68
62 #endif // NFC_h 69 #endif // NFC_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698