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

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

Issue 2821443002: Revert of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Revert Created 3 years, 8 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 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
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"
40 39
41 namespace blink { 40 namespace blink {
42 41
43 namespace { 42 namespace {
44 43
45 VREye StringToVREye(const String& which_eye) { 44 VREye StringToVREye(const String& which_eye) {
46 if (which_eye == "left") 45 if (which_eye == "left")
47 return kVREyeLeft; 46 return kVREyeLeft;
48 if (which_eye == "right") 47 if (which_eye == "right")
49 return kVREyeRight; 48 return kVREyeRight;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // result. 170 // result.
172 DEFINE_STATIC_LOCAL( 171 DEFINE_STATIC_LOCAL(
173 EnumerationHistogram, vr_presentation_result_histogram, 172 EnumerationHistogram, vr_presentation_result_histogram,
174 ("VRDisplayPresentResult", 173 ("VRDisplayPresentResult",
175 static_cast<int>(PresentationResult::kPresentationResultMax))); 174 static_cast<int>(PresentationResult::kPresentationResultMax)));
176 vr_presentation_result_histogram.Count(static_cast<int>(result)); 175 vr_presentation_result_histogram.Count(static_cast<int>(result));
177 } 176 }
178 177
179 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state, 178 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state,
180 const HeapVector<VRLayer>& layers) { 179 const HeapVector<VRLayer>& layers) {
181 ExecutionContext* execution_context = ExecutionContext::From(script_state); 180 ExecutionContext* execution_context = script_state->GetExecutionContext();
182 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent); 181 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent);
183 if (!execution_context->IsSecureContext()) { 182 if (!execution_context->IsSecureContext()) {
184 UseCounter::Count(execution_context, 183 UseCounter::Count(execution_context,
185 UseCounter::kVRRequestPresentInsecureOrigin); 184 UseCounter::kVRRequestPresentInsecureOrigin);
186 } 185 }
187 186
188 ReportPresentationResult(PresentationResult::kRequested); 187 ReportPresentationResult(PresentationResult::kRequested);
189 188
190 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); 189 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
191 ScriptPromise promise = resolver->Promise(); 190 ScriptPromise promise = resolver->Promise();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return promise; 271 return promise;
273 } 272 }
274 273
275 if (!pending_present_resolvers_.IsEmpty()) { 274 if (!pending_present_resolvers_.IsEmpty()) {
276 // If we are waiting on the results of a previous requestPresent call don't 275 // If we are waiting on the results of a previous requestPresent call don't
277 // fire a new request, just cache the resolver and resolve it when the 276 // fire a new request, just cache the resolver and resolve it when the
278 // original request returns. 277 // original request returns.
279 pending_present_resolvers_.push_back(resolver); 278 pending_present_resolvers_.push_back(resolver);
280 } else if (first_present) { 279 } else if (first_present) {
281 bool secure_context = 280 bool secure_context =
282 ExecutionContext::From(script_state)->IsSecureContext(); 281 script_state->GetExecutionContext()->IsSecureContext();
283 if (!display_) { 282 if (!display_) {
284 ForceExitPresent(); 283 ForceExitPresent();
285 DOMException* exception = DOMException::Create( 284 DOMException* exception = DOMException::Create(
286 kInvalidStateError, "The service is no longer active."); 285 kInvalidStateError, "The service is no longer active.");
287 resolver->Reject(exception); 286 resolver->Reject(exception);
288 return promise; 287 return promise;
289 } 288 }
290 289
291 pending_present_resolvers_.push_back(resolver); 290 pending_present_resolvers_.push_back(resolver);
292 submit_frame_client_binding_.Close(); 291 submit_frame_client_binding_.Close();
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 visitor->Trace(stage_parameters_); 812 visitor->Trace(stage_parameters_);
814 visitor->Trace(eye_parameters_left_); 813 visitor->Trace(eye_parameters_left_);
815 visitor->Trace(eye_parameters_right_); 814 visitor->Trace(eye_parameters_right_);
816 visitor->Trace(layer_); 815 visitor->Trace(layer_);
817 visitor->Trace(rendering_context_); 816 visitor->Trace(rendering_context_);
818 visitor->Trace(scripted_animation_controller_); 817 visitor->Trace(scripted_animation_controller_);
819 visitor->Trace(pending_present_resolvers_); 818 visitor->Trace(pending_present_resolvers_);
820 } 819 }
821 820
822 } // namespace blink 821 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698