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

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: Use new createBaseCallback helper instead of custom callback class. 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/CallbackPromiseAdapter.h"
Reilly Grant (use Gerrit) 2016/04/27 23:32:53 Unused header.
shalamov 2016/04/28 14:16:14 Done.
8 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "bindings/modules/v8/UnionTypesModules.h" 11 #include "bindings/modules/v8/UnionTypesModules.h"
11 #include "core/frame/LocalFrameLifecycleObserver.h"
12 #include "core/page/PageLifecycleObserver.h" 12 #include "core/page/PageLifecycleObserver.h"
13 #include "device/nfc/nfc.mojom-wtf.h"
14 #include "mojo/public/cpp/bindings/binding.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 class MessageCallback; 18 class MessageCallback;
19 class NFCError;
17 class NFCPushOptions; 20 class NFCPushOptions;
18 using NFCPushMessage = StringOrArrayBufferOrNFCMessage; 21 using NFCPushMessage = StringOrArrayBufferOrNFCMessage;
19 class NFCWatchOptions; 22 class NFCWatchOptions;
23 class ServiceRegistry;
20 24
21 class NFC final 25 class NFC final
22 : public GarbageCollected<NFC> 26 : public GarbageCollectedFinalized<NFC>
23 , public ScriptWrappable 27 , public ScriptWrappable
24 , public LocalFrameLifecycleObserver 28 , public PageLifecycleObserver
25 , public PageLifecycleObserver { 29 , WTF_NON_EXPORTED_BASE(public device::wtf::NFCClient)
30 {
26 DEFINE_WRAPPERTYPEINFO(); 31 DEFINE_WRAPPERTYPEINFO();
27 USING_GARBAGE_COLLECTED_MIXIN(NFC); 32 USING_GARBAGE_COLLECTED_MIXIN(NFC);
28 33
29 public: 34 public:
30 static NFC* create(LocalFrame*); 35 static NFC* create(LocalFrame*);
31 36
37 virtual ~NFC();
38
32 // Pushes NFCPushMessage asynchronously to NFC tag / peer. 39 // Pushes NFCPushMessage asynchronously to NFC tag / peer.
33 ScriptPromise push(ScriptState*, const NFCPushMessage&, const NFCPushOptions &); 40 ScriptPromise push(ScriptState*, const NFCPushMessage&, const NFCPushOptions &);
34 41
35 // Cancels ongoing push operation. 42 // Cancels ongoing push operation.
36 ScriptPromise cancelPush(ScriptState*, const String&); 43 ScriptPromise cancelPush(ScriptState*, const String&);
37 44
38 // Starts watching for NFC messages that match NFCWatchOptions criteria. 45 // Starts watching for NFC messages that match NFCWatchOptions criteria.
39 ScriptPromise watch(ScriptState*, MessageCallback*, const NFCWatchOptions&); 46 ScriptPromise watch(ScriptState*, MessageCallback*, const NFCWatchOptions&);
40 47
41 // Cancels watch operation with id. 48 // Cancels watch operation with id.
42 ScriptPromise cancelWatch(ScriptState*, long id); 49 ScriptPromise cancelWatch(ScriptState*, long id);
43 50
44 // Cancels all watch operations. 51 // Cancels all watch operations.
45 ScriptPromise cancelWatch(ScriptState*); 52 ScriptPromise cancelWatch(ScriptState*);
46 53
47 // Implementation of LocalFrameLifecycleObserver.
48 void willDetachFrameHost() override;
49
50 // Implementation of PageLifecycleObserver. 54 // Implementation of PageLifecycleObserver.
51 void pageVisibilityChanged() override; 55 void pageVisibilityChanged() override;
52 56
53 // Interface required by garbage collection. 57 // Interface required by garbage collection.
54 DECLARE_VIRTUAL_TRACE(); 58 DECLARE_VIRTUAL_TRACE();
55 59
56 private: 60 private:
61 bool Initialize(ServiceRegistry*);
62 void OnRequestCompleted(ScriptPromiseResolver*, device::wtf::NFCErrorPtr);
63 // device::wtf::NFCClient implementation
64 void OnWatch(uint32_t id, device::wtf::NFCMessagePtr) override;
65
66 private:
57 explicit NFC(LocalFrame*); 67 explicit NFC(LocalFrame*);
68 device::wtf::NFCPtr m_nfc;
69 mojo::Binding<device::wtf::NFCClient> m_client;
Reilly Grant (use Gerrit) 2016/04/27 23:32:53 When building the USB Mojo interface rockot@ recom
shalamov 2016/04/28 14:16:14 Done.
Reilly Grant (use Gerrit) 2016/04/28 18:05:02 After checking again with rockot@ I was told that
70 HeapHashSet<Member<ScriptPromiseResolver>> m_requests;
58 }; 71 };
59 72
60 } // namespace blink 73 } // namespace blink
61 74
62 #endif // NFC_h 75 #endif // NFC_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698