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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRController.h

Issue 2167643003: Refactored VRService interaction and added VRServiceClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Liberal sprinkling of 'u's Created 4 years, 4 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 VRController_h 5 #ifndef VRController_h
6 #define VRController_h 6 #define VRController_h
7 7
8 #include "core/frame/LocalFrame.h" 8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "core/dom/Document.h"
9 #include "device/vr/vr_service.mojom-blink.h" 10 #include "device/vr/vr_service.mojom-blink.h"
10 #include "modules/ModulesExport.h" 11 #include "modules/vr/VRDisplay.h"
11 #include "platform/Supplementable.h" 12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "platform/heap/Handle.h"
12 #include "wtf/Deque.h" 14 #include "wtf/Deque.h"
13 15
14 #include <memory> 16 #include <memory>
15 17
16 namespace blink { 18 namespace blink {
17 19
20 class NavigatorVR;
18 class ServiceRegistry; 21 class ServiceRegistry;
19 class VRGetDevicesCallback; 22 class VRGetDevicesCallback;
20 23
21 class MODULES_EXPORT VRController final 24 class VRController final
22 : public GarbageCollectedFinalized<VRController> 25 : public GarbageCollectedFinalized<VRController>
23 , public Supplement<LocalFrame> { 26 , public device::blink::VRServiceClient
27 , public ContextLifecycleObserver {
24 USING_GARBAGE_COLLECTED_MIXIN(VRController); 28 USING_GARBAGE_COLLECTED_MIXIN(VRController);
25 WTF_MAKE_NONCOPYABLE(VRController); 29 WTF_MAKE_NONCOPYABLE(VRController);
26 public: 30 public:
31 VRController(NavigatorVR*);
27 virtual ~VRController(); 32 virtual ~VRController();
28 33
29 void getDisplays(std::unique_ptr<VRGetDevicesCallback>); 34 // VRService.
30 35 void getDisplays(ScriptPromiseResolver*);
31 device::blink::VRPosePtr getPose(unsigned index); 36 device::blink::VRPosePtr getPose(unsigned index);
32
33 void resetPose(unsigned index); 37 void resetPose(unsigned index);
34 38
35 static void provideTo(LocalFrame&, ServiceRegistry*); 39 VRDisplay* createOrUpdateDisplay(const device::blink::VRDisplayPtr&);
36 static VRController* from(LocalFrame&); 40 VRDisplayVector updateDisplays(mojo::WTFArray<device::blink::VRDisplayPtr>);
37 static const char* supplementName(); 41 VRDisplay* getDisplayForIndex(unsigned index);
38 42
39 DECLARE_VIRTUAL_TRACE(); 43 DECLARE_VIRTUAL_TRACE();
40 44
41 private: 45 private:
42 VRController(LocalFrame&, ServiceRegistry*);
43
44 // Binding callbacks. 46 // Binding callbacks.
45 void onGetDisplays(mojo::WTFArray<device::blink::VRDisplayPtr>); 47 void onGetDisplays(mojo::WTFArray<device::blink::VRDisplayPtr>);
46 48
49 // VRServiceClient.
50 void OnDisplayChanged(device::blink::VRDisplayPtr) override;
51
52 // ContextLifecycleObserver.
53 void contextDestroyed() override;
54
55 Member<NavigatorVR> m_navigatorVR;
56 VRDisplayVector m_displays;
57
47 Deque<std::unique_ptr<VRGetDevicesCallback>> m_pendingGetDevicesCallbacks; 58 Deque<std::unique_ptr<VRGetDevicesCallback>> m_pendingGetDevicesCallbacks;
48 device::blink::VRServicePtr m_service; 59 device::blink::VRServicePtr m_service;
60 mojo::Binding<device::blink::VRServiceClient> m_binding;
49 }; 61 };
50 62
51 } // namespace blink 63 } // namespace blink
52 64
53 #endif // VRController_h 65 #endif // VRController_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.cpp ('k') | third_party/WebKit/Source/modules/vr/VRController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698