1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_net_CookieServiceChild_h__
7 #define mozilla_net_CookieServiceChild_h__
10 #include "mozilla/net/PCookieServiceChild.h"
11 #include "nsClassHashtable.h"
12 #include "nsICookieService.h"
13 #include "mozIThirdPartyUtil.h"
14 #include "nsWeakReference.h"
15 #include "nsThreadUtils.h"
17 class nsIEffectiveTLDService
;
26 class CookieServiceChild final
: public PCookieServiceChild
,
27 public nsICookieService
,
28 public nsSupportsWeakReference
{
29 friend class PCookieServiceChild
;
33 NS_DECL_NSICOOKIESERVICE
35 typedef nsTArray
<RefPtr
<Cookie
>> CookiesList
;
36 typedef nsClassHashtable
<CookieKey
, CookiesList
> CookiesMap
;
42 static already_AddRefed
<CookieServiceChild
> GetSingleton();
44 RefPtr
<GenericPromise
> TrackCookieLoad(nsIChannel
* aChannel
);
47 ~CookieServiceChild();
49 void RecordDocumentCookie(Cookie
* aCookie
, const OriginAttributes
& aAttrs
);
51 uint32_t CountCookiesFromHashTable(const nsACString
& aBaseDomain
,
52 const OriginAttributes
& aOriginAttrs
);
54 static bool RequireThirdPartyCheck(nsILoadInfo
* aLoadInfo
);
56 mozilla::ipc::IPCResult
RecvTrackCookiesLoad(
57 nsTArray
<CookieStructTable
>&& aCookiesListTable
);
59 mozilla::ipc::IPCResult
RecvRemoveAll();
61 mozilla::ipc::IPCResult
RecvRemoveBatchDeletedCookies(
62 nsTArray
<CookieStruct
>&& aCookiesList
,
63 nsTArray
<OriginAttributes
>&& aAttrsList
);
65 mozilla::ipc::IPCResult
RecvRemoveCookie(const CookieStruct
& aCookie
,
66 const OriginAttributes
& aAttrs
);
68 mozilla::ipc::IPCResult
RecvAddCookie(const CookieStruct
& aCookie
,
69 const OriginAttributes
& aAttrs
);
71 void RemoveSingleCookie(const CookieStruct
& aCookie
,
72 const OriginAttributes
& aAttrs
);
74 CookiesMap mCookiesMap
;
75 nsCOMPtr
<mozIThirdPartyUtil
> mThirdPartyUtil
;
76 nsCOMPtr
<nsIEffectiveTLDService
> mTLDService
;
80 } // namespace mozilla
82 #endif // mozilla_net_CookieServiceChild_h__