OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/VRDisplay.h" | 5 #include "modules/vr/VRDisplay.h" |
6 | 6 |
7 #include "core/css/StylePropertySet.h" | 7 #include "core/css/StylePropertySet.h" |
8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
9 #include "core/dom/FrameRequestCallback.h" | 9 #include "core/dom/FrameRequestCallback.h" |
10 #include "core/dom/ScriptedAnimationController.h" | 10 #include "core/dom/ScriptedAnimationController.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "modules/vr/VRStageParameters.h" | 29 #include "modules/vr/VRStageParameters.h" |
30 #include "modules/webgl/WebGLRenderingContextBase.h" | 30 #include "modules/webgl/WebGLRenderingContextBase.h" |
31 #include "platform/Histogram.h" | 31 #include "platform/Histogram.h" |
32 #include "platform/UserGestureIndicator.h" | 32 #include "platform/UserGestureIndicator.h" |
33 #include "platform/instrumentation/tracing/TraceEvent.h" | 33 #include "platform/instrumentation/tracing/TraceEvent.h" |
34 #include "platform/wtf/AutoReset.h" | 34 #include "platform/wtf/AutoReset.h" |
35 #include "platform/wtf/Time.h" | 35 #include "platform/wtf/Time.h" |
36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
37 | 37 |
38 #include <array> | 38 #include <array> |
| 39 #include "core/dom/ExecutionContext.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 VREye StringToVREye(const String& which_eye) { | 45 VREye StringToVREye(const String& which_eye) { |
45 if (which_eye == "left") | 46 if (which_eye == "left") |
46 return kVREyeLeft; | 47 return kVREyeLeft; |
47 if (which_eye == "right") | 48 if (which_eye == "right") |
48 return kVREyeRight; | 49 return kVREyeRight; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // result. | 171 // result. |
171 DEFINE_STATIC_LOCAL( | 172 DEFINE_STATIC_LOCAL( |
172 EnumerationHistogram, vr_presentation_result_histogram, | 173 EnumerationHistogram, vr_presentation_result_histogram, |
173 ("VRDisplayPresentResult", | 174 ("VRDisplayPresentResult", |
174 static_cast<int>(PresentationResult::kPresentationResultMax))); | 175 static_cast<int>(PresentationResult::kPresentationResultMax))); |
175 vr_presentation_result_histogram.Count(static_cast<int>(result)); | 176 vr_presentation_result_histogram.Count(static_cast<int>(result)); |
176 } | 177 } |
177 | 178 |
178 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state, | 179 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state, |
179 const HeapVector<VRLayer>& layers) { | 180 const HeapVector<VRLayer>& layers) { |
180 ExecutionContext* execution_context = script_state->GetExecutionContext(); | 181 ExecutionContext* execution_context = ExecutionContext::From(script_state); |
181 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent); | 182 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent); |
182 if (!execution_context->IsSecureContext()) { | 183 if (!execution_context->IsSecureContext()) { |
183 UseCounter::Count(execution_context, | 184 UseCounter::Count(execution_context, |
184 UseCounter::kVRRequestPresentInsecureOrigin); | 185 UseCounter::kVRRequestPresentInsecureOrigin); |
185 } | 186 } |
186 | 187 |
187 ReportPresentationResult(PresentationResult::kRequested); | 188 ReportPresentationResult(PresentationResult::kRequested); |
188 | 189 |
189 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 190 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
190 ScriptPromise promise = resolver->Promise(); | 191 ScriptPromise promise = resolver->Promise(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return promise; | 272 return promise; |
272 } | 273 } |
273 | 274 |
274 if (!pending_present_resolvers_.IsEmpty()) { | 275 if (!pending_present_resolvers_.IsEmpty()) { |
275 // If we are waiting on the results of a previous requestPresent call don't | 276 // If we are waiting on the results of a previous requestPresent call don't |
276 // fire a new request, just cache the resolver and resolve it when the | 277 // fire a new request, just cache the resolver and resolve it when the |
277 // original request returns. | 278 // original request returns. |
278 pending_present_resolvers_.push_back(resolver); | 279 pending_present_resolvers_.push_back(resolver); |
279 } else if (first_present) { | 280 } else if (first_present) { |
280 bool secure_context = | 281 bool secure_context = |
281 script_state->GetExecutionContext()->IsSecureContext(); | 282 ExecutionContext::From(script_state)->IsSecureContext(); |
282 if (!display_) { | 283 if (!display_) { |
283 ForceExitPresent(); | 284 ForceExitPresent(); |
284 DOMException* exception = DOMException::Create( | 285 DOMException* exception = DOMException::Create( |
285 kInvalidStateError, "The service is no longer active."); | 286 kInvalidStateError, "The service is no longer active."); |
286 resolver->Reject(exception); | 287 resolver->Reject(exception); |
287 return promise; | 288 return promise; |
288 } | 289 } |
289 | 290 |
290 pending_present_resolvers_.push_back(resolver); | 291 pending_present_resolvers_.push_back(resolver); |
291 submit_frame_client_binding_.Close(); | 292 submit_frame_client_binding_.Close(); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 visitor->Trace(stage_parameters_); | 813 visitor->Trace(stage_parameters_); |
813 visitor->Trace(eye_parameters_left_); | 814 visitor->Trace(eye_parameters_left_); |
814 visitor->Trace(eye_parameters_right_); | 815 visitor->Trace(eye_parameters_right_); |
815 visitor->Trace(layer_); | 816 visitor->Trace(layer_); |
816 visitor->Trace(rendering_context_); | 817 visitor->Trace(rendering_context_); |
817 visitor->Trace(scripted_animation_controller_); | 818 visitor->Trace(scripted_animation_controller_); |
818 visitor->Trace(pending_present_resolvers_); | 819 visitor->Trace(pending_present_resolvers_); |
819 } | 820 } |
820 | 821 |
821 } // namespace blink | 822 } // namespace blink |
OLD | NEW |