mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1230209 - Add more telemetry for Geolocation usage f=bsmedberg r=tanvi,rbarnes,jdm
This commit is contained in:
parent
99880da7d0
commit
84dd2b9f82
@ -90,6 +90,7 @@ class nsGeolocationRequest final
|
||||
const GeoPositionCallback& aCallback,
|
||||
const GeoPositionErrorCallback& aErrorCallback,
|
||||
PositionOptions* aOptions,
|
||||
uint8_t aProtocolType,
|
||||
bool aWatchPositionRequest = false,
|
||||
int32_t aWatchId = 0);
|
||||
void Shutdown();
|
||||
@ -120,6 +121,7 @@ class nsGeolocationRequest final
|
||||
int32_t mWatchId;
|
||||
bool mShutdown;
|
||||
nsCOMPtr<nsIContentPermissionRequester> mRequester;
|
||||
uint8_t mProtocolType;
|
||||
};
|
||||
|
||||
static PositionOptions*
|
||||
@ -354,6 +356,7 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
|
||||
const GeoPositionCallback& aCallback,
|
||||
const GeoPositionErrorCallback& aErrorCallback,
|
||||
PositionOptions* aOptions,
|
||||
uint8_t aProtocolType,
|
||||
bool aWatchPositionRequest,
|
||||
int32_t aWatchId)
|
||||
: mIsWatchPositionRequest(aWatchPositionRequest),
|
||||
@ -362,7 +365,8 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
|
||||
mOptions(aOptions),
|
||||
mLocator(aLocator),
|
||||
mWatchId(aWatchId),
|
||||
mShutdown(false)
|
||||
mShutdown(false),
|
||||
mProtocolType(aProtocolType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> win = do_QueryReferent(mLocator->GetOwner());
|
||||
if (win) {
|
||||
@ -453,6 +457,13 @@ nsGeolocationRequest::GetElement(nsIDOMElement * *aRequestingElement)
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequest::Cancel()
|
||||
{
|
||||
if (mRequester) {
|
||||
// Record the number of denied requests for regular web content.
|
||||
// This method is only called when the user explicitly denies the request,
|
||||
// and is not called when the page is simply unloaded, or similar.
|
||||
Telemetry::Accumulate(Telemetry::GEOLOCATION_REQUEST_GRANTED, mProtocolType);
|
||||
}
|
||||
|
||||
if (mLocator->ClearPendingRequest(this)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -466,6 +477,11 @@ nsGeolocationRequest::Allow(JS::HandleValue aChoices)
|
||||
{
|
||||
MOZ_ASSERT(aChoices.isUndefined());
|
||||
|
||||
if (mRequester) {
|
||||
// Record the number of granted requests for regular web content.
|
||||
Telemetry::Accumulate(Telemetry::GEOLOCATION_REQUEST_GRANTED, mProtocolType + 10);
|
||||
}
|
||||
|
||||
if (mLocator->ClearPendingRequest(this)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1193,7 +1209,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Geolocation,
|
||||
mPendingRequests)
|
||||
|
||||
Geolocation::Geolocation()
|
||||
: mLastWatchId(0)
|
||||
: mProtocolType(ProtocolType::OTHER)
|
||||
, mLastWatchId(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1234,6 +1251,24 @@ Geolocation::Init(nsIDOMWindow* aContentDom)
|
||||
/* wants untrusted */ false);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = mPrincipal->GetURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isHttp;
|
||||
rv = uri->SchemeIs("http", &isHttp);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isHttps;
|
||||
rv = uri->SchemeIs("https", &isHttps);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Store the protocol to send via telemetry later.
|
||||
if (isHttp) {
|
||||
mProtocolType = ProtocolType::HTTP;
|
||||
} else if (isHttps) {
|
||||
mProtocolType = ProtocolType::HTTPS;
|
||||
}
|
||||
}
|
||||
|
||||
// If no aContentDom was passed into us, we are being used
|
||||
@ -1494,11 +1529,13 @@ Geolocation::GetCurrentPosition(GeoPositionCallback& callback,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
RefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
|
||||
callback,
|
||||
errorCallback,
|
||||
options,
|
||||
false);
|
||||
// Count the number of requests per protocol/scheme.
|
||||
Telemetry::Accumulate(Telemetry::GEOLOCATION_GETCURRENTPOSITION_SECURE_ORIGIN,
|
||||
static_cast<uint8_t>(mProtocolType));
|
||||
|
||||
RefPtr<nsGeolocationRequest> request =
|
||||
new nsGeolocationRequest(this, callback, errorCallback, options,
|
||||
static_cast<uint8_t>(mProtocolType), false);
|
||||
|
||||
if (!sGeoEnabled) {
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);
|
||||
@ -1583,15 +1620,16 @@ Geolocation::WatchPosition(GeoPositionCallback& aCallback,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Count the number of requests per protocol/scheme.
|
||||
Telemetry::Accumulate(Telemetry::GEOLOCATION_WATCHPOSITION_SECURE_ORIGIN,
|
||||
static_cast<uint8_t>(mProtocolType));
|
||||
|
||||
// The watch ID:
|
||||
*aRv = mLastWatchId++;
|
||||
|
||||
RefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this,
|
||||
aCallback,
|
||||
aErrorCallback,
|
||||
aOptions,
|
||||
true,
|
||||
*aRv);
|
||||
RefPtr<nsGeolocationRequest> request =
|
||||
new nsGeolocationRequest(this, aCallback, aErrorCallback, aOptions,
|
||||
static_cast<uint8_t>(mProtocolType), true, *aRv);
|
||||
|
||||
if (!sGeoEnabled) {
|
||||
GPSLOG("request allow event");
|
||||
|
@ -218,6 +218,12 @@ private:
|
||||
// where the content was loaded from
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
|
||||
// the protocols we want to measure
|
||||
enum class ProtocolType: uint8_t { OTHER, HTTP, HTTPS };
|
||||
|
||||
// the protocol used to load the content
|
||||
ProtocolType mProtocolType;
|
||||
|
||||
// owning back pointer.
|
||||
RefPtr<nsGeolocationService> mService;
|
||||
|
||||
|
@ -444,6 +444,27 @@
|
||||
"kind": "flag",
|
||||
"description": "Has seen location error"
|
||||
},
|
||||
"GEOLOCATION_GETCURRENTPOSITION_SECURE_ORIGIN" : {
|
||||
"expires_in_version" : "55",
|
||||
"kind": "enumerated",
|
||||
"n_values": 10,
|
||||
"bug_numbers": [1230209],
|
||||
"description" : "Number of navigator.geolocation.getCurrentPosition() calls (0=other, 1=http, 2=https)"
|
||||
},
|
||||
"GEOLOCATION_REQUEST_GRANTED": {
|
||||
"expires_in_version": "55",
|
||||
"kind": "enumerated",
|
||||
"n_values": 20,
|
||||
"bug_numbers": [1230209],
|
||||
"description": "Geolocation requests either granted or denied (0=denied/other, 1=denied/http, 2=denied/https, ..., 10=granted/other, 11=granted/http, 12=granted/https)"
|
||||
},
|
||||
"GEOLOCATION_WATCHPOSITION_SECURE_ORIGIN" : {
|
||||
"expires_in_version" : "55",
|
||||
"kind": "enumerated",
|
||||
"n_values": 10,
|
||||
"bug_numbers": [1230209],
|
||||
"description" : "Number of navigator.geolocation.watchPosition() calls (0=other, 1=http, 2=https)"
|
||||
},
|
||||
"GEOLOCATION_WIN8_SOURCE_IS_MLS": {
|
||||
"expires_in_version": "default",
|
||||
"kind": "boolean",
|
||||
|
Loading…
Reference in New Issue
Block a user