Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef NetworkConnectivityService_h_
6
#define NetworkConnectivityService_h_
7
8
#include "nsINetworkConnectivityService.h"
9
#include "nsIObserver.h"
10
#include "nsIDNSListener.h"
11
#include "nsIStreamListener.h"
12
13
namespace mozilla {
14
namespace net {
15
16
class NetworkConnectivityService : public nsINetworkConnectivityService,
17
public nsIObserver,
18
public nsIDNSListener,
19
public nsIStreamListener {
20
public:
21
NS_DECL_ISUPPORTS
22
NS_DECL_NSINETWORKCONNECTIVITYSERVICE
23
NS_DECL_NSIOBSERVER
24
NS_DECL_NSIDNSLISTENER
25
NS_DECL_NSISTREAMLISTENER
26
NS_DECL_NSIREQUESTOBSERVER
27
28
nsresult Init();
29
static already_AddRefed<NetworkConnectivityService> GetSingleton();
30
31
private:
32
NetworkConnectivityService() = default;
33
virtual ~NetworkConnectivityService() = default;
34
35
// Calls all the check methods
36
void PerformChecks();
37
38
// Will be set to OK if the DNS request returned in IP of this type,
39
// NOT_AVAILABLE if that type of resolution is not available
40
// UNKNOWN if the check wasn't performed
41
ConnectivityState mDNSv4 = nsINetworkConnectivityService::UNKNOWN;
42
ConnectivityState mDNSv6 = nsINetworkConnectivityService::UNKNOWN;
43
44
ConnectivityState mIPv4 = nsINetworkConnectivityService::UNKNOWN;
45
ConnectivityState mIPv6 = nsINetworkConnectivityService::UNKNOWN;
46
47
nsCOMPtr<nsICancelable> mDNSv4Request;
48
nsCOMPtr<nsICancelable> mDNSv6Request;
49
50
nsCOMPtr<nsIChannel> mIPv4Channel;
51
nsCOMPtr<nsIChannel> mIPv6Channel;
52
};
53
54
} // namespace net
55
} // namespace mozilla
56
57
#endif // NetworkConnectivityService_h_