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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2878893003: VR: Poll media access flags (Closed)
Patch Set: VR: Poll media access flags 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
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 "chrome/browser/android/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/android/vr_shell/ui_interface.h" 23 #include "chrome/browser/android/vr_shell/ui_interface.h"
24 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" 24 #include "chrome/browser/android/vr_shell/ui_scene_manager.h"
25 #include "chrome/browser/android/vr_shell/vr_compositor.h" 25 #include "chrome/browser/android/vr_shell/vr_compositor.h"
26 #include "chrome/browser/android/vr_shell/vr_controller_model.h" 26 #include "chrome/browser/android/vr_shell/vr_controller_model.h"
27 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" 27 #include "chrome/browser/android/vr_shell/vr_gl_thread.h"
28 #include "chrome/browser/android/vr_shell/vr_input_manager.h" 28 #include "chrome/browser/android/vr_shell/vr_input_manager.h"
29 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" 29 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
30 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" 30 #include "chrome/browser/android/vr_shell/vr_shell_gl.h"
31 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" 31 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h"
32 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" 32 #include "chrome/browser/android/vr_shell/vr_web_contents_observer.h"
33 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
34 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
33 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/navigation_controller.h" 36 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/render_widget_host.h" 38 #include "content/public/browser/render_widget_host.h"
37 #include "content/public/browser/render_widget_host_view.h" 39 #include "content/public/browser/render_widget_host_view.h"
38 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
39 #include "content/public/common/content_features.h" 41 #include "content/public/common/content_features.h"
40 #include "content/public/common/referrer.h" 42 #include "content/public/common/referrer.h"
41 #include "device/vr/android/gvr/gvr_device.h" 43 #include "device/vr/android/gvr/gvr_device.h"
42 #include "device/vr/android/gvr/gvr_device_provider.h" 44 #include "device/vr/android/gvr/gvr_device_provider.h"
(...skipping 10 matching lines...) Expand all
53 #include "ui/gfx/geometry/size.h" 55 #include "ui/gfx/geometry/size.h"
54 #include "ui/gfx/native_widget_types.h" 56 #include "ui/gfx/native_widget_types.h"
55 57
56 using base::android::JavaParamRef; 58 using base::android::JavaParamRef;
57 using base::android::JavaRef; 59 using base::android::JavaRef;
58 60
59 namespace vr_shell { 61 namespace vr_shell {
60 62
61 namespace { 63 namespace {
62 vr_shell::VrShell* g_instance; 64 vr_shell::VrShell* g_instance;
65 float poll_media_access_interval_ = 0.01f;
mthiesse 2017/05/12 22:01:30 Use a constexpr TimeDelta
asimjour1 2017/05/12 22:31:48 Done.
63 66
64 void SetIsInVR(content::WebContents* contents, bool is_in_vr) { 67 void SetIsInVR(content::WebContents* contents, bool is_in_vr) {
65 if (contents && contents->GetRenderWidgetHostView()) 68 if (contents && contents->GetRenderWidgetHostView())
66 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); 69 contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr);
67 } 70 }
68 71
69 void LoadControllerModelTask( 72 void LoadControllerModelTask(
70 base::WeakPtr<VrShell> weak_vr_shell, 73 base::WeakPtr<VrShell> weak_vr_shell,
71 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) { 74 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) {
72 auto controller_model = VrControllerModel::LoadFromComponent(); 75 auto controller_model = VrControllerModel::LoadFromComponent();
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 508
506 void VrShell::OnVRVsyncProviderRequest( 509 void VrShell::OnVRVsyncProviderRequest(
507 device::mojom::VRVSyncProviderRequest request) { 510 device::mojom::VRVSyncProviderRequest request) {
508 PostToGlThreadWhenReady(base::Bind(&VrShellGl::OnRequest, 511 PostToGlThreadWhenReady(base::Bind(&VrShellGl::OnRequest,
509 gl_thread_->GetVrShellGl(), 512 gl_thread_->GetVrShellGl(),
510 base::Passed(&request))); 513 base::Passed(&request)));
511 } 514 }
512 515
513 void VrShell::UpdateVSyncInterval(int64_t timebase_nanos, 516 void VrShell::UpdateVSyncInterval(int64_t timebase_nanos,
514 double interval_seconds) { 517 double interval_seconds) {
518 PollMediaAccessFlag();
515 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateVSyncInterval, 519 PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateVSyncInterval,
516 gl_thread_->GetVrShellGl(), timebase_nanos, 520 gl_thread_->GetVrShellGl(), timebase_nanos,
517 interval_seconds)); 521 interval_seconds));
518 } 522 }
519 523
524 void VrShell::PollMediaAccessFlag() {
525 base::TimeDelta interval;
526 interval = base::TimeDelta::FromSecondsD(poll_media_access_interval_);
527 main_thread_task_runner_->PostDelayedTask(
528 FROM_HERE,
529 base::Bind(&VrShell::PollMediaAccessFlag, weak_ptr_factory_.GetWeakPtr()),
mthiesse 2017/05/12 22:01:30 In order to avoid accidentally starting two loops
asimjour1 2017/05/12 22:31:48 Done.
530 interval);
531
532 scoped_refptr<MediaStreamCaptureIndicator> indicator =
533 MediaCaptureDevicesDispatcher::GetInstance()
534 ->GetMediaStreamCaptureIndicator();
535 bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_);
536 if (is_capturing_audio != is_capturing_audio_)
537 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetAudioCapturingWarning,
538 gl_thread_->GetVrShellGl(),
539 is_capturing_audio));
540 is_capturing_audio_ = is_capturing_audio;
541
542 bool is_capturing_video = indicator->IsCapturingVideo(web_contents_);
543 if (is_capturing_video != is_capturing_video_)
544 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetVideoCapturingWarning,
545 gl_thread_->GetVrShellGl(),
546 is_capturing_video));
547 is_capturing_video_ = is_capturing_video;
548
549 bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_);
550 if (is_capturing_screen != is_capturing_screen_)
551 PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetScreenCapturingWarning,
552 gl_thread_->GetVrShellGl(),
553 is_capturing_screen));
554 is_capturing_screen_ = is_capturing_screen;
555 }
556
520 void VrShell::SetContentCssSize(float width, float height, float dpr) { 557 void VrShell::SetContentCssSize(float width, float height, float dpr) {
521 JNIEnv* env = base::android::AttachCurrentThread(); 558 JNIEnv* env = base::android::AttachCurrentThread();
522 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, 559 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
523 dpr); 560 dpr);
524 } 561 }
525 562
526 void VrShell::ProcessContentGesture( 563 void VrShell::ProcessContentGesture(
527 std::unique_ptr<blink::WebInputEvent> event) { 564 std::unique_ptr<blink::WebInputEvent> event) {
528 if (input_manager_) { 565 if (input_manager_) {
529 input_manager_->ProcessUpdatedGesture(std::move(event)); 566 input_manager_->ProcessUpdatedGesture(std::move(event));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 jboolean for_web_vr, 602 jboolean for_web_vr,
566 jlong gvr_api, 603 jlong gvr_api,
567 jboolean reprojected_rendering) { 604 jboolean reprojected_rendering) {
568 return reinterpret_cast<intptr_t>(new VrShell( 605 return reinterpret_cast<intptr_t>(new VrShell(
569 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 606 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
570 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 607 for_web_vr, VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
571 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 608 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
572 } 609 }
573 610
574 } // namespace vr_shell 611 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698