2013-12-11 23:03:51 +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/. */
|
|
|
|
|
|
|
|
#include "mozilla/net/ChildDNSService.h"
|
|
|
|
#include "nsIDNSListener.h"
|
2016-02-18 00:29:00 +03:00
|
|
|
#include "nsIIOService.h"
|
2013-12-11 23:03:51 +04:00
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsIXPConnect.h"
|
|
|
|
#include "nsIPrefService.h"
|
|
|
|
#include "nsIProtocolProxyService.h"
|
2016-02-18 00:29:00 +03:00
|
|
|
#include "nsNetCID.h"
|
2017-10-30 02:02:40 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
2017-03-24 01:33:00 +03:00
|
|
|
#include "mozilla/SystemGroup.h"
|
2013-12-11 23:03:51 +04:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
|
|
|
#include "mozilla/net/DNSListenerProxy.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-12-11 23:03:51 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// ChildDNSService
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2017-10-30 02:02:40 +03:00
|
|
|
static StaticRefPtr<ChildDNSService> gChildDNSService;
|
2013-12-11 23:03:51 +04:00
|
|
|
static const char kPrefNameDisablePrefetch[] = "network.dns.disablePrefetch";
|
|
|
|
|
2017-10-17 07:08:42 +03:00
|
|
|
already_AddRefed<ChildDNSService> ChildDNSService::GetSingleton() {
|
2019-08-05 23:54:01 +03:00
|
|
|
MOZ_ASSERT(XRE_IsContentProcess() || XRE_IsSocketProcess());
|
2013-12-11 23:03:51 +04:00
|
|
|
|
|
|
|
if (!gChildDNSService) {
|
|
|
|
gChildDNSService = new ChildDNSService();
|
2017-10-30 02:02:40 +03:00
|
|
|
ClearOnShutdown(&gChildDNSService);
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
|
2017-10-17 07:08:42 +03:00
|
|
|
return do_AddRef(gChildDNSService);
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ChildDNSService, nsIDNSService, nsPIDNSService, nsIObserver)
|
2013-12-11 23:03:51 +04:00
|
|
|
|
|
|
|
ChildDNSService::ChildDNSService()
|
|
|
|
: mFirstTime(true),
|
2016-01-12 21:16:59 +03:00
|
|
|
mDisablePrefetch(false),
|
2014-08-26 13:09:00 +04:00
|
|
|
mPendingRequestsLock("DNSPendingRequestsLock") {
|
2019-08-05 23:54:01 +03:00
|
|
|
MOZ_ASSERT(XRE_IsContentProcess() || XRE_IsSocketProcess());
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
|
2014-08-26 13:09:00 +04:00
|
|
|
void ChildDNSService::GetDNSRecordHashKey(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHost, uint16_t aType,
|
|
|
|
const OriginAttributes& aOriginAttributes, uint32_t aFlags,
|
|
|
|
nsIDNSListener* aListener, nsACString& aHashKey) {
|
2014-08-26 13:09:00 +04:00
|
|
|
aHashKey.Assign(aHost);
|
2018-09-22 23:54:11 +03:00
|
|
|
aHashKey.AppendInt(aType);
|
2017-02-14 07:25:35 +03:00
|
|
|
|
|
|
|
nsAutoCString originSuffix;
|
|
|
|
aOriginAttributes.CreateSuffix(originSuffix);
|
2018-10-04 03:16:00 +03:00
|
|
|
aHashKey.Append(originSuffix);
|
2017-02-14 07:25:35 +03:00
|
|
|
|
2014-08-26 13:09:00 +04:00
|
|
|
aHashKey.AppendInt(aFlags);
|
|
|
|
aHashKey.AppendPrintf("%p", aListener);
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
nsresult ChildDNSService::AsyncResolveInternal(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& hostname, uint16_t type, uint32_t flags,
|
|
|
|
nsIDNSListener* listener, nsIEventTarget* target_,
|
|
|
|
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
|
2019-08-05 23:54:01 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
|
|
|
NS_ENSURE_TRUE(gNeckoChild != nullptr, NS_ERROR_FAILURE);
|
|
|
|
}
|
2013-12-11 23:03:51 +04:00
|
|
|
|
|
|
|
if (mDisablePrefetch && (flags & RESOLVE_SPECULATE)) {
|
|
|
|
return NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
|
|
|
|
}
|
|
|
|
|
2014-08-26 13:09:00 +04:00
|
|
|
// We need original listener for the pending requests hash.
|
2019-05-01 11:47:10 +03:00
|
|
|
nsIDNSListener* originalListener = listener;
|
2014-08-26 13:09:00 +04:00
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
// make sure JS callers get notification on the main thread
|
|
|
|
nsCOMPtr<nsIEventTarget> target = target_;
|
|
|
|
nsCOMPtr<nsIXPConnectWrappedJS> wrappedListener = do_QueryInterface(listener);
|
|
|
|
if (wrappedListener && !target) {
|
2017-03-24 01:33:00 +03:00
|
|
|
target = SystemGroup::EventTargetFor(TaskCategory::Network);
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
if (target) {
|
|
|
|
// Guarantee listener freed on main thread. Not sure we need this in child
|
|
|
|
// (or in parent in nsDNSService.cpp) but doesn't hurt.
|
|
|
|
listener = new DNSListenerProxy(listener, target);
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DNSRequestChild> childReq = new DNSRequestChild(
|
2017-02-14 07:25:35 +03:00
|
|
|
hostname, type, aOriginAttributes, flags, listener, target);
|
2013-12-11 23:03:51 +04:00
|
|
|
|
2014-08-26 13:09:00 +04:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mPendingRequestsLock);
|
|
|
|
nsCString key;
|
2019-06-28 09:44:03 +03:00
|
|
|
GetDNSRecordHashKey(hostname, type, aOriginAttributes, flags,
|
2015-02-19 08:14:00 +03:00
|
|
|
originalListener, key);
|
2018-09-24 21:41:05 +03:00
|
|
|
auto entry = mPendingRequests.LookupForAdd(key);
|
|
|
|
if (entry) {
|
|
|
|
entry.Data()->AppendElement(childReq);
|
2014-08-26 13:09:00 +04:00
|
|
|
} else {
|
2018-09-24 21:41:05 +03:00
|
|
|
entry.OrInsert([&]() {
|
2019-05-01 11:47:10 +03:00
|
|
|
auto* hashEntry = new nsTArray<RefPtr<DNSRequestChild>>();
|
2018-09-24 21:41:05 +03:00
|
|
|
hashEntry->AppendElement(childReq);
|
|
|
|
return hashEntry;
|
|
|
|
});
|
2014-08-26 13:09:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
childReq->StartRequest();
|
|
|
|
|
|
|
|
childReq.forget(result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
nsresult ChildDNSService::CancelAsyncResolveInternal(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
|
|
|
|
nsIDNSListener* aListener, nsresult aReason,
|
|
|
|
const OriginAttributes& aOriginAttributes) {
|
2018-09-22 23:54:11 +03:00
|
|
|
if (mDisablePrefetch && (aFlags & RESOLVE_SPECULATE)) {
|
|
|
|
return NS_ERROR_DNS_LOOKUP_QUEUE_FULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MutexAutoLock lock(mPendingRequestsLock);
|
2019-05-01 11:47:10 +03:00
|
|
|
nsTArray<RefPtr<DNSRequestChild>>* hashEntry;
|
2018-09-22 23:54:11 +03:00
|
|
|
nsCString key;
|
|
|
|
GetDNSRecordHashKey(aHostname, aType, aOriginAttributes, aFlags, aListener,
|
|
|
|
key);
|
|
|
|
if (mPendingRequests.Get(key, &hashEntry)) {
|
|
|
|
// We cancel just one.
|
|
|
|
hashEntry->ElementAt(0)->Cancel(aReason);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// ChildDNSService::nsIDNSService
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::AsyncResolve(const nsACString& hostname, uint32_t flags,
|
|
|
|
nsIDNSListener* listener, nsIEventTarget* target_,
|
|
|
|
JS::HandleValue aOriginAttributes, JSContext* aCx,
|
|
|
|
uint8_t aArgc, nsICancelable** result) {
|
2018-09-22 23:54:11 +03:00
|
|
|
OriginAttributes attrs;
|
|
|
|
|
|
|
|
if (aArgc == 1) {
|
|
|
|
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return AsyncResolveInternal(hostname, nsIDNSService::RESOLVE_TYPE_DEFAULT,
|
|
|
|
flags, listener, target_, attrs, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::AsyncResolveNative(const nsACString& hostname, uint32_t flags,
|
|
|
|
nsIDNSListener* listener,
|
|
|
|
nsIEventTarget* target_,
|
|
|
|
const OriginAttributes& aOriginAttributes,
|
|
|
|
nsICancelable** result) {
|
2018-09-22 23:54:11 +03:00
|
|
|
return AsyncResolveInternal(hostname, nsIDNSService::RESOLVE_TYPE_DEFAULT,
|
|
|
|
flags, listener, target_, aOriginAttributes,
|
|
|
|
result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::AsyncResolveByType(const nsACString& hostname, uint16_t type,
|
|
|
|
uint32_t flags, nsIDNSListener* listener,
|
|
|
|
nsIEventTarget* target_,
|
2018-09-22 23:54:11 +03:00
|
|
|
JS::HandleValue aOriginAttributes,
|
2019-05-01 11:47:10 +03:00
|
|
|
JSContext* aCx, uint8_t aArgc,
|
|
|
|
nsICancelable** result) {
|
2018-09-22 23:54:11 +03:00
|
|
|
OriginAttributes attrs;
|
|
|
|
|
|
|
|
if (aArgc == 1) {
|
|
|
|
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return AsyncResolveInternal(hostname, type, flags, listener, target_, attrs,
|
|
|
|
result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::AsyncResolveByTypeNative(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& hostname, uint16_t type, uint32_t flags,
|
|
|
|
nsIDNSListener* listener, nsIEventTarget* target_,
|
|
|
|
const OriginAttributes& aOriginAttributes, nsICancelable** result) {
|
2018-09-22 23:54:11 +03:00
|
|
|
return AsyncResolveInternal(hostname, type, flags, listener, target_,
|
|
|
|
aOriginAttributes, result);
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::CancelAsyncResolve(const nsACString& aHostname,
|
|
|
|
uint32_t aFlags, nsIDNSListener* aListener,
|
2017-02-14 07:25:35 +03:00
|
|
|
nsresult aReason,
|
|
|
|
JS::HandleValue aOriginAttributes,
|
2019-05-01 11:47:10 +03:00
|
|
|
JSContext* aCx, uint8_t aArgc) {
|
2017-02-14 07:25:35 +03:00
|
|
|
OriginAttributes attrs;
|
|
|
|
|
|
|
|
if (aArgc == 1) {
|
|
|
|
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
return CancelAsyncResolveInternal(aHostname,
|
|
|
|
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
|
|
|
|
aListener, aReason, attrs);
|
2017-02-14 07:25:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::CancelAsyncResolveNative(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint32_t aFlags, nsIDNSListener* aListener,
|
|
|
|
nsresult aReason, const OriginAttributes& aOriginAttributes) {
|
2018-09-22 23:54:11 +03:00
|
|
|
return CancelAsyncResolveInternal(aHostname,
|
|
|
|
nsIDNSService::RESOLVE_TYPE_DEFAULT, aFlags,
|
|
|
|
aListener, aReason, aOriginAttributes);
|
|
|
|
}
|
2018-09-18 02:08:14 +03:00
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::CancelAsyncResolveByType(const nsACString& aHostname,
|
2018-09-22 23:54:11 +03:00
|
|
|
uint16_t aType, uint32_t aFlags,
|
2019-05-01 11:47:10 +03:00
|
|
|
nsIDNSListener* aListener,
|
2018-09-22 23:54:11 +03:00
|
|
|
nsresult aReason,
|
|
|
|
JS::HandleValue aOriginAttributes,
|
2019-05-01 11:47:10 +03:00
|
|
|
JSContext* aCx, uint8_t aArgc) {
|
2018-09-22 23:54:11 +03:00
|
|
|
OriginAttributes attrs;
|
|
|
|
|
|
|
|
if (aArgc == 1) {
|
|
|
|
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2018-09-21 04:30:10 +03:00
|
|
|
}
|
2018-09-20 23:53:28 +03:00
|
|
|
|
2018-09-22 23:54:11 +03:00
|
|
|
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aListener,
|
|
|
|
aReason, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::CancelAsyncResolveByTypeNative(
|
2019-05-01 11:47:10 +03:00
|
|
|
const nsACString& aHostname, uint16_t aType, uint32_t aFlags,
|
|
|
|
nsIDNSListener* aListener, nsresult aReason,
|
|
|
|
const OriginAttributes& aOriginAttributes) {
|
2018-09-22 23:54:11 +03:00
|
|
|
return CancelAsyncResolveInternal(aHostname, aType, aFlags, aListener,
|
|
|
|
aReason, aOriginAttributes);
|
2013-12-11 23:03:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::Resolve(const nsACString& hostname, uint32_t flags,
|
|
|
|
JS::HandleValue aOriginAttributes, JSContext* aCx,
|
|
|
|
uint8_t aArgc, nsIDNSRecord** result) {
|
2013-12-11 23:03:51 +04:00
|
|
|
// not planning to ever support this, since sync IPDL is evil.
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2017-02-14 07:25:35 +03:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::ResolveNative(const nsACString& hostname, uint32_t flags,
|
|
|
|
const OriginAttributes& aOriginAttributes,
|
|
|
|
nsIDNSRecord** result) {
|
2017-02-14 07:25:35 +03:00
|
|
|
// not planning to ever support this, since sync IPDL is evil.
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::GetDNSCacheEntries(
|
2019-05-01 11:47:10 +03:00
|
|
|
nsTArray<mozilla::net::DNSCacheEntries>* args) {
|
2013-12-11 23:03:51 +04:00
|
|
|
// Only used by networking dashboard, so may not ever need this in child.
|
|
|
|
// (and would provide a way to spy on what hosts other apps are connecting to,
|
|
|
|
// unless we start keeping per-app DNS caches).
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2019-03-21 15:41:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::ClearCache(bool aTrrToo) { return NS_ERROR_NOT_AVAILABLE; }
|
|
|
|
|
2019-08-24 00:17:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::ReloadParentalControlEnabled() {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::GetMyHostName(nsACString& result) {
|
2013-12-11 23:03:51 +04:00
|
|
|
// TODO: get value from parent during PNecko construction?
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
void ChildDNSService::NotifyRequestDone(DNSRequestChild* aDnsRequest) {
|
2014-08-26 13:09:00 +04:00
|
|
|
// We need the original flags and listener for the pending requests hash.
|
|
|
|
uint32_t originalFlags = aDnsRequest->mFlags & ~RESOLVE_OFFLINE;
|
|
|
|
nsCOMPtr<nsIDNSListener> originalListener = aDnsRequest->mListener;
|
|
|
|
nsCOMPtr<nsIDNSListenerProxy> wrapper = do_QueryInterface(originalListener);
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper->GetOriginalListener(getter_AddRefs(originalListener));
|
|
|
|
if (NS_WARN_IF(!originalListener)) {
|
|
|
|
MOZ_ASSERT(originalListener);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MutexAutoLock lock(mPendingRequestsLock);
|
|
|
|
|
|
|
|
nsCString key;
|
2018-09-22 23:54:11 +03:00
|
|
|
GetDNSRecordHashKey(aDnsRequest->mHost, aDnsRequest->mType,
|
|
|
|
aDnsRequest->mOriginAttributes, originalFlags,
|
2018-05-16 23:05:03 +03:00
|
|
|
originalListener, key);
|
2014-08-26 13:09:00 +04:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsTArray<RefPtr<DNSRequestChild>>* hashEntry;
|
2014-08-26 13:09:00 +04:00
|
|
|
|
|
|
|
if (mPendingRequests.Get(key, &hashEntry)) {
|
2019-03-07 01:15:41 +03:00
|
|
|
auto idx = hashEntry->IndexOf(aDnsRequest);
|
|
|
|
if (idx != nsTArray<RefPtr<DNSRequestChild>>::NoIndex) {
|
2014-08-26 13:09:00 +04:00
|
|
|
hashEntry->RemoveElementAt(idx);
|
|
|
|
if (hashEntry->IsEmpty()) {
|
|
|
|
mPendingRequests.Remove(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// ChildDNSService::nsPIDNSService
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult ChildDNSService::Init() {
|
|
|
|
// Disable prefetching either by explicit preference or if a manual proxy
|
|
|
|
// is configured
|
|
|
|
bool disablePrefetch = false;
|
|
|
|
int proxyType = nsIProtocolProxyService::PROXYCONFIG_DIRECT;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
|
|
|
if (prefs) {
|
|
|
|
prefs->GetIntPref("network.proxy.type", &proxyType);
|
|
|
|
prefs->GetBoolPref(kPrefNameDisablePrefetch, &disablePrefetch);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mFirstTime) {
|
|
|
|
mFirstTime = false;
|
|
|
|
if (prefs) {
|
|
|
|
prefs->AddObserver(kPrefNameDisablePrefetch, this, false);
|
|
|
|
|
|
|
|
// Monitor these to see if there is a change in proxy configuration
|
|
|
|
// If a manual proxy is in use, disable prefetch implicitly
|
|
|
|
prefs->AddObserver("network.proxy.type", this, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mDisablePrefetch = disablePrefetch ||
|
|
|
|
(proxyType == nsIProtocolProxyService::PROXYCONFIG_MANUAL);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ChildDNSService::Shutdown() { return NS_OK; }
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::GetPrefetchEnabled(bool* outVal) {
|
2013-12-11 23:03:51 +04:00
|
|
|
*outVal = !mDisablePrefetch;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ChildDNSService::SetPrefetchEnabled(bool inVal) {
|
|
|
|
mDisablePrefetch = !inVal;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// ChildDNSService::nsIObserver
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
ChildDNSService::Observe(nsISupports* subject, const char* topic,
|
|
|
|
const char16_t* data) {
|
2013-12-11 23:03:51 +04:00
|
|
|
// we are only getting called if a preference has changed.
|
|
|
|
NS_ASSERTION(strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
|
|
|
|
"unexpected observe call");
|
|
|
|
|
|
|
|
// Reread prefs
|
|
|
|
Init();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|