2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-11-30 18:39:55 +03:00
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-09-12 00:32:33 +04:00
|
|
|
|
2012-08-29 04:24:06 +04:00
|
|
|
#ifndef nsDNSService2_h__
|
|
|
|
#define nsDNSService2_h__
|
|
|
|
|
2005-04-06 05:33:28 +04:00
|
|
|
#include "nsPIDNSService.h"
|
2003-09-12 00:32:33 +04:00
|
|
|
#include "nsIIDNService.h"
|
2013-11-07 09:35:30 +04:00
|
|
|
#include "nsIMemoryReporter.h"
|
2003-09-12 00:32:33 +04:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsHostResolver.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2004-03-09 23:31:54 +03:00
|
|
|
#include "nsString.h"
|
2012-05-11 23:59:19 +04:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2018-02-01 12:20:49 +03:00
|
|
|
#include "TRRService.h"
|
2003-09-12 00:32:33 +04:00
|
|
|
|
2017-09-11 05:13:42 +03:00
|
|
|
class nsAuthSSPI;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDNSService final : public nsPIDNSService,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver,
|
|
|
|
public nsIMemoryReporter {
|
2003-09-12 00:32:33 +04:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2005-04-06 05:33:28 +04:00
|
|
|
NS_DECL_NSPIDNSSERVICE
|
2003-09-12 00:32:33 +04:00
|
|
|
NS_DECL_NSIDNSSERVICE
|
|
|
|
NS_DECL_NSIOBSERVER
|
2013-12-08 10:09:10 +04:00
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-09-12 00:32:33 +04:00
|
|
|
nsDNSService();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-10-17 07:08:42 +03:00
|
|
|
static already_AddRefed<nsIDNSService> GetXPCOMSingleton();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-11-25 03:24:12 +04:00
|
|
|
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-02-18 00:29:00 +03:00
|
|
|
bool GetOffline() const;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-09-11 05:13:42 +03:00
|
|
|
protected:
|
|
|
|
friend class nsAuthSSPI;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-09-11 05:13:42 +03:00
|
|
|
nsresult DeprecatedSyncResolve(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint32_t flags,
|
|
|
|
const mozilla::OriginAttributes& aOriginAttributes,
|
|
|
|
nsIDNSRecord** result);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-09-12 00:32:33 +04:00
|
|
|
private:
|
2014-06-24 20:36:44 +04:00
|
|
|
~nsDNSService();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult ReadPrefs(const char* name);
|
2017-10-17 07:08:42 +03:00
|
|
|
static already_AddRefed<nsDNSService> GetSingleton();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
uint16_t GetAFForLookup(const nsACString& host, uint32_t flags);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult PreprocessHostname(bool aLocalDomain, const nsACString& aInput,
|
|
|
|
nsIIDNService* aIDN, nsACString& aACE);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
nsresult AsyncResolveInternal(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint16_t type, uint32_t flags,
|
|
|
|
nsIDNSListener* aListener, nsIEventTarget* target_,
|
|
|
|
const mozilla::OriginAttributes& aOriginAttributes,
|
|
|
|
nsICancelable** result);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
nsresult CancelAsyncResolveInternal(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
|
|
|
|
nsIDNSListener* aListener, nsresult aReason,
|
|
|
|
const mozilla::OriginAttributes& aOriginAttributes);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult ResolveInternal(const nsACString& aHostname, uint32_t flags,
|
|
|
|
const mozilla::OriginAttributes& aOriginAttributes,
|
|
|
|
nsIDNSRecord** result);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsHostResolver> mResolver;
|
2003-09-12 00:32:33 +04:00
|
|
|
nsCOMPtr<nsIIDNService> mIDN;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-08-29 01:37:12 +03:00
|
|
|
// mLock protects access to mResolver, mLocalDomains and mIPv4OnlyDomains
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
mozilla::Mutex mLock;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2004-03-09 23:31:54 +03:00
|
|
|
// mIPv4OnlyDomains is a comma-separated list of domains for which only
|
|
|
|
// IPv4 DNS lookups are performed. This allows the user to disable IPv6 on
|
|
|
|
// a per-domain basis and work around broken DNS servers. See bug 68796.
|
2017-07-28 04:21:47 +03:00
|
|
|
nsCString mIPv4OnlyDomains;
|
|
|
|
nsCString mForceResolve;
|
2014-04-16 00:13:00 +04:00
|
|
|
bool mDisableIPv6;
|
|
|
|
bool mDisablePrefetch;
|
2015-12-11 22:28:21 +03:00
|
|
|
bool mBlockDotOnion;
|
2014-04-16 00:13:00 +04:00
|
|
|
bool mNotifyResolution;
|
2015-02-25 22:02:38 +03:00
|
|
|
bool mOfflineLocalhost;
|
2017-05-01 20:51:55 +03:00
|
|
|
bool mForceResolveOn;
|
2018-03-21 16:35:53 +03:00
|
|
|
uint32_t mProxyType;
|
2014-04-16 00:13:00 +04:00
|
|
|
nsTHashtable<nsCStringHashKey> mLocalDomains;
|
2018-02-01 12:20:49 +03:00
|
|
|
RefPtr<mozilla::net::TRRService> mTrrService;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-21 16:35:53 +03:00
|
|
|
uint32_t mResCacheEntries;
|
|
|
|
uint32_t mResCacheExpiration;
|
|
|
|
uint32_t mResCacheGrace;
|
|
|
|
bool mResolverPrefsUpdated;
|
2003-09-12 00:32:33 +04:00
|
|
|
};
|
2012-08-29 04:24:06 +04:00
|
|
|
|
|
|
|
#endif // nsDNSService2_h__
|