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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "content/public/browser/navigation_handle.h" | 12 #include "content/public/browser/navigation_handle.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr.h" | |
billorr
2017/05/05 17:48:41
We should try to keep gvr-related code limited to
tiborg
2017/05/05 19:03:34
Good point. What about putting an #ifdef ANDROID a
billorr
2017/05/05 20:10:21
#ifdef could work, or the histograms could be move
tiborg
2017/05/10 20:39:52
I put an #ifdef guard around it.
Also, moved the
| |
16 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" | |
15 | 17 |
16 namespace vr_shell { | 18 namespace vr_shell { |
17 | 19 |
18 enum class VRMode { | 20 enum class VRMode { |
19 NO_VR = 0, | 21 NO_VR = 0, |
20 VR_BROWSER = 1, // VR Shell. | 22 VR_BROWSER = 1, // VR Shell. |
21 VR_FULLSCREEN = 2, // Cinema mode. | 23 VR_FULLSCREEN = 2, // Cinema mode. |
22 WEBVR = 3, | 24 WEBVR = 3, |
23 }; | 25 }; |
24 | 26 |
(...skipping 21 matching lines...) Expand all Loading... | |
46 // config members: | 48 // config members: |
47 // time between stop and start to count as same session | 49 // time between stop and start to count as same session |
48 base::TimeDelta maximum_session_gap_time_; | 50 base::TimeDelta maximum_session_gap_time_; |
49 | 51 |
50 // minimum time between start and stop to add to duration | 52 // minimum time between start and stop to add to duration |
51 base::TimeDelta minimum_duration_; | 53 base::TimeDelta minimum_duration_; |
52 | 54 |
53 DISALLOW_COPY_AND_ASSIGN(SessionTimer); | 55 DISALLOW_COPY_AND_ASSIGN(SessionTimer); |
54 }; | 56 }; |
55 | 57 |
58 enum class ViewerType { | |
59 UNKNOWN_TYPE = 0, | |
60 CARDBOARD = 1, | |
61 DAYDREAM = 2, | |
62 VIEWER_TYPE_MAX, | |
63 }; | |
64 | |
65 enum class GVRVersionCrossedVRViewerType { | |
66 | |
67 GVR_OLDER_AND_UNKNOWN_TYPE = 0, | |
ddorwin
2017/05/05 20:29:59
Does unknown == not selected? Do we need the GVR u
tiborg
2017/05/10 20:39:52
It's gone. See comment below.
| |
68 GVR_1_10_AND_UNKNOWN_TYPE = 1, | |
69 GVR_1_20_AND_UNKNOWN_TYPE = 2, | |
70 GVR_1_30_AND_UNKNOWN_TYPE = 3, | |
71 GVR_1_40_AND_UNKNOWN_TYPE = 4, | |
72 GVR_NEWER_AND_UNKNOWN_TYPE = 5, | |
73 GVR_OTHER_AND_UNKNOWN_TYPE = 6, | |
74 | |
75 GVR_OLDER_AND_CARDBOARD = 7, | |
76 GVR_1_10_AND_CARDBOARD = 8, | |
77 GVR_1_20_AND_CARDBOARD = 9, | |
78 GVR_1_30_AND_CARDBOARD = 10, | |
79 GVR_1_40_AND_CARDBOARD = 11, | |
80 GVR_NEWER_AND_CARDBOARD = 12, | |
billorr
2017/05/05 17:48:41
what is the plan when newer versions come out? do
tiborg
2017/05/05 19:03:35
Putting the GVR version in the metadata is probabl
billorr
2017/05/05 20:10:21
indeed.
One minor thing we could do to make it ea
ddorwin
2017/05/05 20:29:59
We should definitely be able to report versions be
tiborg
2017/05/10 20:39:52
Ok, these are good points. As discussed offline, c
| |
81 GVR_OTHER_AND_CARDBOARD = 13, | |
82 | |
83 GVR_OLDER_AND_DAYDREAM = 14, | |
84 GVR_1_10_AND_DAYDREAM = 15, | |
85 GVR_1_20_AND_DAYDREAM = 16, | |
86 GVR_1_30_AND_DAYDREAM = 17, | |
87 GVR_1_40_AND_DAYDREAM = 18, | |
88 GVR_NEWER_AND_DAYDREAM = 19, | |
89 GVR_OTHER_AND_DAYDREAM = 20, | |
90 | |
91 GVR_NONE = 21, | |
92 | |
93 GVR_VERSION_CROSSED_VR_VIEWER_TYPE_MAX, | |
94 }; | |
95 | |
56 // This class is not threadsafe and must only be used from the main thread. | 96 // This class is not threadsafe and must only be used from the main thread. |
57 class VrMetricsHelper : public content::WebContentsObserver { | 97 class VrMetricsHelper : public content::WebContentsObserver { |
58 public: | 98 public: |
59 explicit VrMetricsHelper(content::WebContents*); | 99 explicit VrMetricsHelper(content::WebContents*); |
60 ~VrMetricsHelper() override; | 100 ~VrMetricsHelper() override; |
61 void SetWebVREnabled(bool is_webvr_presenting); | 101 void SetWebVREnabled(bool is_webvr_presenting); |
62 void SetVRActive(bool is_vr_enabled); | 102 void SetVRActive(bool is_vr_enabled); |
63 | 103 |
104 static void LogGvrVersionAndVrViewerType(gvr_context* context, | |
105 gvr_version version); | |
106 static void LogVrViewerType(gvr_context* context); | |
107 | |
64 private: | 108 private: |
65 // WebContentObserver | 109 // WebContentObserver |
66 void MediaStartedPlaying(const MediaPlayerInfo& media_info, | 110 void MediaStartedPlaying(const MediaPlayerInfo& media_info, |
67 const MediaPlayerId&) override; | 111 const MediaPlayerId&) override; |
68 void MediaStoppedPlaying(const MediaPlayerInfo& media_info, | 112 void MediaStoppedPlaying(const MediaPlayerInfo& media_info, |
69 const MediaPlayerId&) override; | 113 const MediaPlayerId&) override; |
70 void DidFinishNavigation(content::NavigationHandle*) override; | 114 void DidFinishNavigation(content::NavigationHandle*) override; |
71 void DidToggleFullscreenModeForTab(bool entered_fullscreen, | 115 void DidToggleFullscreenModeForTab(bool entered_fullscreen, |
72 bool will_cause_resize) override; | 116 bool will_cause_resize) override; |
73 | 117 |
74 void SetVrMode(VRMode mode); | 118 void SetVrMode(VRMode mode); |
75 void UpdateMode(); | 119 void UpdateMode(); |
76 | 120 |
121 static ViewerType GetVrViewerType(gvr_context* context); | |
122 | |
77 std::unique_ptr<SessionTimer> mode_video_timer_; | 123 std::unique_ptr<SessionTimer> mode_video_timer_; |
78 std::unique_ptr<SessionTimer> session_video_timer_; | 124 std::unique_ptr<SessionTimer> session_video_timer_; |
79 std::unique_ptr<SessionTimer> mode_timer_; | 125 std::unique_ptr<SessionTimer> mode_timer_; |
80 std::unique_ptr<SessionTimer> session_timer_; | 126 std::unique_ptr<SessionTimer> session_timer_; |
81 | 127 |
82 VRMode mode_ = VRMode::NO_VR; | 128 VRMode mode_ = VRMode::NO_VR; |
83 | 129 |
84 // state that gets translated into vr_mode: | 130 // state that gets translated into vr_mode: |
85 bool is_fullscreen_ = false; | 131 bool is_fullscreen_ = false; |
86 bool is_webvr_ = false; | 132 bool is_webvr_ = false; |
87 bool is_vr_enabled_ = false; | 133 bool is_vr_enabled_ = false; |
88 | 134 |
89 int num_videos_playing_ = 0; | 135 int num_videos_playing_ = 0; |
90 int num_session_navigation_ = 0; | 136 int num_session_navigation_ = 0; |
91 int num_session_video_playback_ = 0; | 137 int num_session_video_playback_ = 0; |
92 | 138 |
139 static bool logged_gvr_version_; | |
140 | |
93 GURL origin_; | 141 GURL origin_; |
94 }; | 142 }; |
95 | 143 |
96 } // namespace vr_shell | 144 } // namespace vr_shell |
97 | 145 |
98 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ | 146 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_USAGE_MONITOR_H_ |
OLD | NEW |