Chromium Code Reviews| Index: content/browser/geolocation/geolocation_dispatcher_host.cc |
| diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc |
| index edb2692f36f232894ace3e678a8a17d9ec4c43d8..e9a24f10223805f545cd947c617ebfd40197e6cc 100644 |
| --- a/content/browser/geolocation/geolocation_dispatcher_host.cc |
| +++ b/content/browser/geolocation/geolocation_dispatcher_host.cc |
| @@ -21,6 +21,51 @@ |
| namespace content { |
| namespace { |
| +// Geoposition error codes for reporting in UMA. |
| +enum GeopositionErrorCode { |
| + // NOTE: Do not renumber these as that would confuse interpretation of |
| + // previously logged data. When making changes, also update the enum list |
| + // in tools/metrics/histograms/histograms.xml to keep it in sync. |
| + |
| + // There was no error. |
| + GEOPOSITION_ERROR_CODE_NONE = 0, |
| + |
| + // User denied use of geolocation. |
| + GEOPOSITION_ERROR_CODE_PERMISSION_DENIED = 1, |
| + |
| + // Geoposition could not be determined |
|
timvolodine
2014/04/08 12:35:57
nit: period at the eol.
Michael van Ouwerkerk
2014/04/08 13:01:40
Done.
|
| + GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE = 2, |
| + |
| + // Timeout. |
| + GEOPOSITION_ERROR_CODE_TIMEOUT = 3, |
| + |
| + // NOTE: Add entries only immediately above this line. |
| + GEOPOSITION_ERROR_CODE_COUNT = 4 |
| +}; |
| + |
| +void RecordGeopositionErrorCode(Geoposition::ErrorCode error_code) { |
| + GeopositionErrorCode code = GEOPOSITION_ERROR_CODE_NONE; |
| + switch (error_code) { |
| + case Geoposition::ERROR_CODE_NONE: |
| + code = GEOPOSITION_ERROR_CODE_NONE; |
| + break; |
| + case Geoposition::ERROR_CODE_PERMISSION_DENIED: |
| + code = GEOPOSITION_ERROR_CODE_PERMISSION_DENIED; |
| + break; |
| + case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: |
| + code = GEOPOSITION_ERROR_CODE_POSITION_UNAVAILABLE; |
| + break; |
| + case Geoposition::ERROR_CODE_TIMEOUT: |
| + code = GEOPOSITION_ERROR_CODE_TIMEOUT; |
| + break; |
| + default: |
| + NOTREACHED(); |
|
Ilya Sherman
2014/04/07 23:54:12
Please remove the default case, so that the compil
Michael van Ouwerkerk
2014/04/08 13:01:40
Done.
|
| + } |
| + UMA_HISTOGRAM_ENUMERATION("Geolocation.LocationUpdate.ErrorCode", |
| + code, |
| + GEOPOSITION_ERROR_CODE_COUNT); |
| +} |
| + |
| void NotifyGeolocationProviderPermissionGranted() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| GeolocationProviderImpl::GetInstance()->UserDidOptIntoLocationServices(); |
| @@ -148,6 +193,7 @@ bool GeolocationDispatcherHostImpl::OnMessageReceived( |
| void GeolocationDispatcherHostImpl::OnLocationUpdate( |
| const Geoposition& geoposition) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + RecordGeopositionErrorCode(geoposition.error_code); |
| for (std::map<int, RendererGeolocationOptions>::iterator it = |
| geolocation_renderers_.begin(); |
| it != geolocation_renderers_.end(); ++it) { |