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

Side by Side Diff: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp

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 #include "modules/vr/NavigatorVR.h" 5 #include "modules/vr/NavigatorVR.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
11 #include "core/frame/LocalDOMWindow.h" 11 #include "core/frame/LocalDOMWindow.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/frame/Navigator.h" 13 #include "core/frame/Navigator.h"
14 #include "core/page/Page.h" 14 #include "core/page/Page.h"
15 #include "modules/vr/VRController.h" 15 #include "modules/vr/VRController.h"
16 #include "modules/vr/VRDisplay.h" 16 #include "modules/vr/VRDisplay.h"
17 #include "modules/vr/VRDisplayCollection.h"
18 #include "modules/vr/VRGetDevicesCallback.h" 17 #include "modules/vr/VRGetDevicesCallback.h"
19 #include "modules/vr/VRPose.h" 18 #include "modules/vr/VRPose.h"
20 #include "wtf/PtrUtil.h" 19 #include "wtf/PtrUtil.h"
21 20
22 namespace blink { 21 namespace blink {
23 22
24 NavigatorVR* NavigatorVR::from(Document& document) 23 NavigatorVR* NavigatorVR::from(Document& document)
25 { 24 {
26 if (!document.frame() || !document.frame()->domWindow()) 25 if (!document.frame() || !document.frame()->domWindow())
27 return 0; 26 return 0;
(...skipping 22 matching lines...) Expand all
50 ScriptPromise promise = resolver->promise(); 49 ScriptPromise promise = resolver->promise();
51 50
52 Document* document = m_frame ? m_frame->document() : 0; 51 Document* document = m_frame ? m_frame->document() : 0;
53 52
54 if (!document || !controller()) { 53 if (!document || !controller()) {
55 DOMException* exception = DOMException::create(InvalidStateError, "The o bject is no longer associated to a document."); 54 DOMException* exception = DOMException::create(InvalidStateError, "The o bject is no longer associated to a document.");
56 resolver->reject(exception); 55 resolver->reject(exception);
57 return promise; 56 return promise;
58 } 57 }
59 58
60 controller()->getDisplays(WTF::wrapUnique(new VRGetDevicesCallback(resolver, m_displays.get()))); 59 controller()->getDisplays(resolver);
61 60
62 return promise; 61 return promise;
63 } 62 }
64 63
65 VRController* NavigatorVR::controller() 64 VRController* NavigatorVR::controller()
66 { 65 {
67 if (!frame()) 66 if (!frame())
68 return 0; 67 return 0;
69 68
70 return VRController::from(*frame()); 69 if (!m_controller) {
70 m_controller = new VRController(this);
71 }
72
73 return m_controller;
71 } 74 }
72 75
73 Document* NavigatorVR::document() 76 Document* NavigatorVR::document()
74 { 77 {
75 return m_frame ? m_frame->document() : 0; 78 return m_frame ? m_frame->document() : 0;
76 } 79 }
77 80
78 DEFINE_TRACE(NavigatorVR) 81 DEFINE_TRACE(NavigatorVR)
79 { 82 {
80 visitor->trace(m_displays); 83 visitor->trace(m_controller);
81 84
82 Supplement<Navigator>::trace(visitor); 85 Supplement<Navigator>::trace(visitor);
83 DOMWindowProperty::trace(visitor); 86 DOMWindowProperty::trace(visitor);
84 } 87 }
85 88
86 NavigatorVR::NavigatorVR(LocalFrame* frame) 89 NavigatorVR::NavigatorVR(LocalFrame* frame)
87 : DOMWindowProperty(frame) 90 : DOMWindowProperty(frame)
88 { 91 {
89 m_displays = new VRDisplayCollection(this);
90 } 92 }
91 93
92 NavigatorVR::~NavigatorVR() 94 NavigatorVR::~NavigatorVR()
93 { 95 {
94 } 96 }
95 97
96 const char* NavigatorVR::supplementName() 98 const char* NavigatorVR::supplementName()
97 { 99 {
98 return "NavigatorVR"; 100 return "NavigatorVR";
99 } 101 }
100 102
101 } // namespace blink 103 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | third_party/WebKit/Source/modules/vr/VRController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698