2013-12-11 19:03:51 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_net_ChildDNSService_h
|
|
|
|
#define mozilla_net_ChildDNSService_h
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsPIDNSService.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-08-26 09:09:00 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "DNSRequestChild.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2013-12-11 19:03:51 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class ChildDNSService final
|
2013-12-11 19:03:51 +00:00
|
|
|
: public nsPIDNSService
|
|
|
|
, public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// AsyncResolve (and CancelAsyncResolve) can be called off-main
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSPIDNSSERVICE
|
|
|
|
NS_DECL_NSIDNSSERVICE
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
ChildDNSService();
|
|
|
|
|
|
|
|
static ChildDNSService* GetSingleton();
|
|
|
|
|
2014-08-26 09:09:00 +00:00
|
|
|
void NotifyRequestDone(DNSRequestChild *aDnsRequest);
|
2016-02-17 21:29:00 +00:00
|
|
|
|
|
|
|
bool GetOffline() const;
|
2013-12-11 19:03:51 +00:00
|
|
|
private:
|
2014-06-24 16:36:44 +00:00
|
|
|
virtual ~ChildDNSService();
|
|
|
|
|
2014-08-26 09:09:00 +00:00
|
|
|
void MOZ_ALWAYS_INLINE GetDNSRecordHashKey(const nsACString &aHost,
|
|
|
|
uint32_t aFlags,
|
2015-02-19 05:14:00 +00:00
|
|
|
const nsACString &aNetworkInterface,
|
2014-08-26 09:09:00 +00:00
|
|
|
nsIDNSListener* aListener,
|
|
|
|
nsACString &aHashKey);
|
|
|
|
|
2013-12-11 19:03:51 +00:00
|
|
|
bool mFirstTime;
|
|
|
|
bool mDisablePrefetch;
|
2014-08-26 09:09:00 +00:00
|
|
|
|
|
|
|
// We need to remember pending dns requests to be able to cancel them.
|
2015-10-18 05:24:48 +00:00
|
|
|
nsClassHashtable<nsCStringHashKey, nsTArray<RefPtr<DNSRequestChild>>> mPendingRequests;
|
2014-08-26 09:09:00 +00:00
|
|
|
Mutex mPendingRequestsLock;
|
2013-12-11 19:03:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2015-07-13 15:25:42 +00:00
|
|
|
|
2013-12-11 19:03:51 +00:00
|
|
|
#endif // mozilla_net_ChildDNSService_h
|