Chromium Code Reviews| 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 "chrome/browser/android/vr_shell/vr_usage_monitor.h" | 5 #include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "components/rappor/public/rappor_utils.h" | 10 #include "components/rappor/public/rappor_utils.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 // send the histogram now if we aren't continuable, clearing segment state | 155 // send the histogram now if we aren't continuable, clearing segment state |
| 156 SendAccumulatedSessionTime(); | 156 SendAccumulatedSessionTime(); |
| 157 | 157 |
| 158 // clear out start/stop/accumulated time | 158 // clear out start/stop/accumulated time |
| 159 start_time_ = base::Time(); | 159 start_time_ = base::Time(); |
| 160 stop_time_ = base::Time(); | 160 stop_time_ = base::Time(); |
| 161 accumulated_time_ = base::TimeDelta(); | 161 accumulated_time_ = base::TimeDelta(); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 #ifdef ANDROID | |
| 166 bool VrMetricsUtil::logged_gvr_version_ = false; | |
| 167 | |
| 168 void VrMetricsUtil::LogGvrVersionForVrViewerType( | |
| 169 gvr_context* context, | |
| 170 GvrVersionStatus version_status, | |
| 171 gvr_version version) { | |
| 172 if (!logged_gvr_version_) { | |
|
ddorwin
2017/05/16 00:15:51
Instead, return early. That simplifies the logic b
tiborg
2017/05/23 15:47:25
Done.
| |
| 173 ViewerType vr_viewer_type = | |
| 174 context ? GetVrViewerType(context) : ViewerType::UNKNOWN_TYPE; | |
| 175 std::string histogram_name; | |
| 176 switch (vr_viewer_type) { | |
| 177 case ViewerType::CARDBOARD: | |
| 178 histogram_name = "GVRVersion.Cardboard"; | |
|
ddorwin
2017/05/16 00:15:51
Thinking ahead to supporting other platforms, mayb
tiborg
2017/05/23 15:47:25
Done.
| |
| 179 break; | |
| 180 case ViewerType::DAYDREAM: | |
| 181 histogram_name = "GVRVersion.Daydream"; | |
| 182 break; | |
| 183 default: | |
| 184 histogram_name = "GVRVersion.Unknown"; | |
| 185 break; | |
| 186 } | |
| 187 | |
| 188 uint32_t encoded_gvr_version; | |
| 189 switch (version_status) { | |
| 190 case GvrVersionStatus::PRECISE: | |
| 191 if (version.major < 0 || version.minor < 0 || version.patch < 0) { | |
|
ddorwin
2017/05/16 00:15:51
What are these checks doing? Why would one of them
tiborg
2017/05/23 15:47:25
I just thought you can basically call this functio
| |
| 192 encoded_gvr_version = std::min(version.major, 999) * 1000000 + | |
| 193 std::min(version.minor, 999) * 1000 + | |
| 194 std::min(version.patch, 999); | |
| 195 } else { | |
| 196 encoded_gvr_version = -2; | |
|
ddorwin
2017/05/16 00:15:51
Magic numbers should be constants.
tiborg
2017/05/23 15:47:25
Done.
| |
| 197 } | |
| 198 break; | |
| 199 case GvrVersionStatus::OLDER: | |
| 200 encoded_gvr_version = 0; | |
|
ddorwin
2017/05/16 00:15:51
Using 0 to mean something seems odd. Probably all
tiborg
2017/05/23 15:47:25
Done.
| |
| 201 break; | |
| 202 case GvrVersionStatus::UNKNOWN: | |
| 203 default: | |
| 204 encoded_gvr_version = -1; | |
|
ddorwin
2017/05/16 00:15:51
As noted previously, we could report all the value
tiborg
2017/05/23 15:47:25
Done.
| |
| 205 break; | |
| 206 } | |
| 207 | |
| 208 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name.c_str(), encoded_gvr_version); | |
| 209 | |
| 210 logged_gvr_version_ = true; | |
| 211 } | |
| 212 } | |
| 213 | |
| 214 void VrMetricsUtil::LogVrViewerType(gvr_context* context) { | |
| 215 UMA_HISTOGRAM_ENUMERATION("VRViewerType", | |
| 216 static_cast<int>(GetVrViewerType(context)), | |
| 217 static_cast<int>(ViewerType::VIEWER_TYPE_MAX)); | |
| 218 } | |
| 219 | |
| 220 ViewerType VrMetricsUtil::GetVrViewerType(gvr_context* context) { | |
| 221 auto gvr_api = gvr::GvrApi::WrapNonOwned(context); | |
| 222 switch (gvr_api->GetViewerType()) { | |
| 223 case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM: | |
| 224 return ViewerType::DAYDREAM; | |
| 225 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD: | |
| 226 return ViewerType::CARDBOARD; | |
| 227 default: | |
| 228 NOTREACHED(); | |
| 229 return ViewerType::UNKNOWN_TYPE; | |
| 230 } | |
| 231 } | |
| 232 #endif // ANDROID | |
| 233 | |
| 165 void VrMetricsHelper::UpdateMode() { | 234 void VrMetricsHelper::UpdateMode() { |
| 166 VRMode mode; | 235 VRMode mode; |
| 167 if (!is_vr_enabled_) { | 236 if (!is_vr_enabled_) { |
| 168 mode = VRMode::NO_VR; | 237 mode = VRMode::NO_VR; |
| 169 } else if (is_webvr_) { | 238 } else if (is_webvr_) { |
| 170 mode = VRMode::WEBVR; | 239 mode = VRMode::WEBVR; |
| 171 } else { | 240 } else { |
| 172 mode = is_fullscreen_ ? VRMode::VR_FULLSCREEN : VRMode::VR_BROWSER; | 241 mode = is_fullscreen_ ? VRMode::VR_FULLSCREEN : VRMode::VR_BROWSER; |
| 173 } | 242 } |
| 174 | 243 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 } | 398 } |
| 330 } | 399 } |
| 331 | 400 |
| 332 void VrMetricsHelper::DidToggleFullscreenModeForTab(bool entered_fullscreen, | 401 void VrMetricsHelper::DidToggleFullscreenModeForTab(bool entered_fullscreen, |
| 333 bool will_cause_resize) { | 402 bool will_cause_resize) { |
| 334 is_fullscreen_ = entered_fullscreen; | 403 is_fullscreen_ = entered_fullscreen; |
| 335 UpdateMode(); | 404 UpdateMode(); |
| 336 } | 405 } |
| 337 | 406 |
| 338 } // namespace vr_shell | 407 } // namespace vr_shell |
| OLD | NEW |