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

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

Issue 2864363005: Prevents exiting presentation if triggering DON while presenting. (Closed)
Patch Set: Fix Created 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 DEFINE_STATIC_LOCAL( 176 DEFINE_STATIC_LOCAL(
177 EnumerationHistogram, vr_presentation_result_histogram, 177 EnumerationHistogram, vr_presentation_result_histogram,
178 ("VRDisplayPresentResult", 178 ("VRDisplayPresentResult",
179 static_cast<int>(PresentationResult::kPresentationResultMax))); 179 static_cast<int>(PresentationResult::kPresentationResultMax)));
180 vr_presentation_result_histogram.Count(static_cast<int>(result)); 180 vr_presentation_result_histogram.Count(static_cast<int>(result));
181 } 181 }
182 182
183 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state, 183 ScriptPromise VRDisplay::requestPresent(ScriptState* script_state,
184 const HeapVector<VRLayer>& layers) { 184 const HeapVector<VRLayer>& layers) {
185 DVLOG(1) << __FUNCTION__; 185 DVLOG(1) << __FUNCTION__;
186
187 if (in_display_activate_) {
188 requested_present_in_display_activate_ = true;
189 }
190
186 ExecutionContext* execution_context = ExecutionContext::From(script_state); 191 ExecutionContext* execution_context = ExecutionContext::From(script_state);
187 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent); 192 UseCounter::Count(execution_context, UseCounter::kVRRequestPresent);
188 if (!execution_context->IsSecureContext()) { 193 if (!execution_context->IsSecureContext()) {
189 UseCounter::Count(execution_context, 194 UseCounter::Count(execution_context,
190 UseCounter::kVRRequestPresentInsecureOrigin); 195 UseCounter::kVRRequestPresentInsecureOrigin);
191 } 196 }
192 197
193 ReportPresentationResult(PresentationResult::kRequested); 198 ReportPresentationResult(PresentationResult::kRequested);
194 199
195 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); 200 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 return promise; 298 return promise;
294 } 299 }
295 300
296 pending_present_resolvers_.push_back(resolver); 301 pending_present_resolvers_.push_back(resolver);
297 submit_frame_client_binding_.Close(); 302 submit_frame_client_binding_.Close();
298 display_->RequestPresent( 303 display_->RequestPresent(
299 secure_context, 304 secure_context,
300 submit_frame_client_binding_.CreateInterfacePtrAndBind(), 305 submit_frame_client_binding_.CreateInterfacePtrAndBind(),
301 ConvertToBaseCallback( 306 ConvertToBaseCallback(
302 WTF::Bind(&VRDisplay::OnPresentComplete, WrapPersistent(this)))); 307 WTF::Bind(&VRDisplay::OnPresentComplete, WrapPersistent(this))));
303 pending_present_request_ = true;
mthiesse 2017/05/10 20:12:38 You should still set the flag here, or you'll do t
tiborg 2017/05/10 20:48:57 I'm just reporting if the page requested present i
304 } else { 308 } else {
305 UpdateLayerBounds(); 309 UpdateLayerBounds();
306 resolver->Resolve(); 310 resolver->Resolve();
307 ReportPresentationResult(PresentationResult::kSuccessAlreadyPresenting); 311 ReportPresentationResult(PresentationResult::kSuccessAlreadyPresenting);
308 } 312 }
309 313
310 return promise; 314 return promise;
311 } 315 }
312 316
313 void VRDisplay::OnPresentComplete(bool success) { 317 void VRDisplay::OnPresentComplete(bool success) {
314 pending_present_request_ = false;
315 if (success) { 318 if (success) {
316 this->BeginPresent(); 319 this->BeginPresent();
317 } else { 320 } else {
318 this->ForceExitPresent(); 321 this->ForceExitPresent();
319 DOMException* exception = DOMException::Create( 322 DOMException* exception = DOMException::Create(
320 kNotAllowedError, "Presentation request was denied."); 323 kNotAllowedError, "Presentation request was denied.");
321 324
322 while (!pending_present_resolvers_.IsEmpty()) { 325 while (!pending_present_resolvers_.IsEmpty()) {
323 ScriptPromiseResolver* resolver = pending_present_resolvers_.TakeFirst(); 326 ScriptPromiseResolver* resolver = pending_present_resolvers_.TakeFirst();
324 resolver->Reject(exception); 327 resolver->Reject(exception);
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 context_gl_ = nullptr; 681 context_gl_ = nullptr;
679 pending_submit_frame_ = false; 682 pending_submit_frame_ = false;
680 pending_previous_frame_render_ = false; 683 pending_previous_frame_render_ = false;
681 } 684 }
682 685
683 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason, 686 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason,
684 const OnActivateCallback& on_handled) { 687 const OnActivateCallback& on_handled) {
685 AutoReset<bool> activating(&in_display_activate_, true); 688 AutoReset<bool> activating(&in_display_activate_, true);
686 navigator_vr_->DispatchVREvent(VRDisplayEvent::Create( 689 navigator_vr_->DispatchVREvent(VRDisplayEvent::Create(
687 EventTypeNames::vrdisplayactivate, true, false, this, reason)); 690 EventTypeNames::vrdisplayactivate, true, false, this, reason));
688 on_handled.Run(pending_present_request_); 691 on_handled.Run(requested_present_in_display_activate_);
mthiesse 2017/05/10 21:16:06 I think we can simply change this to: on_handled.R
tiborg 2017/05/16 15:27:01 Done. And flipped switch as discussed offline.
692 requested_present_in_display_activate_ = false;
689 } 693 }
690 694
691 void VRDisplay::OnDeactivate( 695 void VRDisplay::OnDeactivate(
692 device::mojom::blink::VRDisplayEventReason reason) { 696 device::mojom::blink::VRDisplayEventReason reason) {
693 navigator_vr_->EnqueueVREvent(VRDisplayEvent::Create( 697 navigator_vr_->EnqueueVREvent(VRDisplayEvent::Create(
694 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); 698 EventTypeNames::vrdisplaydeactivate, true, false, this, reason));
695 } 699 }
696 700
697 void VRDisplay::ProcessScheduledWindowAnimations(double timestamp) { 701 void VRDisplay::ProcessScheduledWindowAnimations(double timestamp) {
698 TRACE_EVENT1("gpu", "VRDisplay::window.rAF", "frame", vr_frame_id_); 702 TRACE_EVENT1("gpu", "VRDisplay::window.rAF", "frame", vr_frame_id_);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 visitor->Trace(stage_parameters_); 871 visitor->Trace(stage_parameters_);
868 visitor->Trace(eye_parameters_left_); 872 visitor->Trace(eye_parameters_left_);
869 visitor->Trace(eye_parameters_right_); 873 visitor->Trace(eye_parameters_right_);
870 visitor->Trace(layer_); 874 visitor->Trace(layer_);
871 visitor->Trace(rendering_context_); 875 visitor->Trace(rendering_context_);
872 visitor->Trace(scripted_animation_controller_); 876 visitor->Trace(scripted_animation_controller_);
873 visitor->Trace(pending_present_resolvers_); 877 visitor->Trace(pending_present_resolvers_);
874 } 878 }
875 879
876 } // namespace blink 880 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698