Bug 1828523 [wpt PR 39579] - Only restore dialog focus if focus is in the dialog...
[gecko.git] / dom / geolocation / MLSFallback.h
blobf0e7f75519c010725d4e0a0755a235f9c5ce5164
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/. */
7 #include "nsCOMPtr.h"
8 #include "nsITimer.h"
9 #include "nsINamed.h"
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
26 be expected in 5s.
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 {
32 public:
33 NS_DECL_ISUPPORTS
34 NS_DECL_NSITIMERCALLBACK
35 NS_DECL_NSINAMED
37 explicit MLSFallback(uint32_t delayMs = 2000);
38 nsresult Startup(nsIGeolocationUpdate* aWatcher);
39 nsresult Shutdown();
41 private:
42 nsresult CreateMLSFallbackProvider();
43 virtual ~MLSFallback();
44 nsCOMPtr<nsITimer> mHandoffTimer;
45 nsCOMPtr<nsIGeolocationProvider> mMLSFallbackProvider;
46 nsCOMPtr<nsIGeolocationUpdate> mUpdateWatcher;
47 const uint32_t mDelayMs;