1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 class nsIGeolocationUpdate
;
12 class nsIGeolocationProvider
;
15 This class wraps the NetworkGeolocationProvider in a delayed startup.
16 It is for providing a fallback to MLS when:
17 1) using another provider as the primary provider, and
18 2) that primary provider may fail to return a result (i.e. the error returned
19 is indeterminate, or no error callback occurs)
21 The intent is that the primary provider is started, then MLSFallback
22 is started with sufficient delay that the primary provider will respond first
23 if successful (in the majority of cases).
25 MLS has an average response of 3s, so with the 2s default delay, a response can
28 Telemetry is recommended to monitor that the primary provider is responding
29 first when expected to do so.
31 class MLSFallback
: public nsITimerCallback
, public nsINamed
{
34 NS_DECL_NSITIMERCALLBACK
37 explicit MLSFallback(uint32_t delayMs
= 2000);
38 nsresult
Startup(nsIGeolocationUpdate
* aWatcher
);
42 nsresult
CreateMLSFallbackProvider();
43 virtual ~MLSFallback();
44 nsCOMPtr
<nsITimer
> mHandoffTimer
;
45 nsCOMPtr
<nsIGeolocationProvider
> mMLSFallbackProvider
;
46 nsCOMPtr
<nsIGeolocationUpdate
> mUpdateWatcher
;
47 const uint32_t mDelayMs
;