2013-12-11 23:03:51 +04: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 13:09:00 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "DNSRequestChild.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2013-12-11 23:03:51 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ChildDNSService final
|
2013-12-11 23:03:51 +04: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 13:09:00 +04:00
|
|
|
void NotifyRequestDone(DNSRequestChild *aDnsRequest);
|
2013-12-11 23:03:51 +04:00
|
|
|
private:
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~ChildDNSService();
|
|
|
|
|
2014-08-26 13:09:00 +04:00
|
|
|
void MOZ_ALWAYS_INLINE GetDNSRecordHashKey(const nsACString &aHost,
|
|
|
|
uint32_t aFlags,
|
2015-02-19 08:14:00 +03:00
|
|
|
const nsACString &aNetworkInterface,
|
2014-08-26 13:09:00 +04:00
|
|
|
nsIDNSListener* aListener,
|
|
|
|
nsACString &aHashKey);
|
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
bool mFirstTime;
|
|
|
|
bool mOffline;
|
|
|
|
bool mDisablePrefetch;
|
2014-08-26 13:09:00 +04:00
|
|
|
|
|
|
|
// We need to remember pending dns requests to be able to cancel them.
|
|
|
|
nsClassHashtable<nsCStringHashKey, nsTArray<nsRefPtr<DNSRequestChild>>> mPendingRequests;
|
|
|
|
Mutex mPendingRequestsLock;
|
2013-12-11 23:03:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2015-07-13 18:25:42 +03:00
|
|
|
|
2013-12-11 23:03:51 +04:00
|
|
|
#endif // mozilla_net_ChildDNSService_h
|