2013-12-11 11:03:51 -08: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 02:09:00 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "DNSRequestChild.h"
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2013-12-11 11:03:51 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
class ChildDNSService MOZ_FINAL
|
|
|
|
: 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 02:09:00 -07:00
|
|
|
void NotifyRequestDone(DNSRequestChild *aDnsRequest);
|
2013-12-11 11:03:51 -08:00
|
|
|
private:
|
2014-06-24 09:36:44 -07:00
|
|
|
virtual ~ChildDNSService();
|
|
|
|
|
2014-08-26 02:09:00 -07:00
|
|
|
void MOZ_ALWAYS_INLINE GetDNSRecordHashKey(const nsACString &aHost,
|
|
|
|
uint32_t aFlags,
|
2015-02-08 16:52:00 -08:00
|
|
|
const nsACString &aNetworkInterface,
|
2014-08-26 02:09:00 -07:00
|
|
|
nsIDNSListener* aListener,
|
|
|
|
nsACString &aHashKey);
|
|
|
|
|
2013-12-11 11:03:51 -08:00
|
|
|
bool mFirstTime;
|
|
|
|
bool mOffline;
|
|
|
|
bool mDisablePrefetch;
|
2014-08-26 02:09:00 -07: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 11:03:51 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_net_ChildDNSService_h
|