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 "nsIObserver.h"
14 #include "nsIPrefBranch.h"
15 #include "mozIThirdPartyUtil.h"
16 #include "nsWeakReference.h"
17 #include "nsThreadUtils.h"
19 class nsIEffectiveTLDService
;
28 class CookieServiceChild final
: public PCookieServiceChild
,
29 public nsICookieService
,
31 public nsITimerCallback
,
32 public nsSupportsWeakReference
{
33 friend class PCookieServiceChild
;
37 NS_DECL_NSICOOKIESERVICE
39 NS_DECL_NSITIMERCALLBACK
41 typedef nsTArray
<RefPtr
<Cookie
>> CookiesList
;
42 typedef nsClassHashtable
<CookieKey
, CookiesList
> CookiesMap
;
46 static already_AddRefed
<CookieServiceChild
> GetSingleton();
48 void TrackCookieLoad(nsIChannel
* aChannel
);
51 ~CookieServiceChild();
54 void RecordDocumentCookie(Cookie
* aCookie
, const OriginAttributes
& aAttrs
);
56 uint32_t CountCookiesFromHashTable(const nsACString
& aBaseDomain
,
57 const OriginAttributes
& aOriginAttrs
);
59 void PrefChanged(nsIPrefBranch
* aPrefBranch
);
61 static bool RequireThirdPartyCheck(nsILoadInfo
* aLoadInfo
);
63 mozilla::ipc::IPCResult
RecvTrackCookiesLoad(
64 nsTArray
<CookieStruct
>&& aCookiesList
, const OriginAttributes
& aAttrs
);
66 mozilla::ipc::IPCResult
RecvRemoveAll();
68 mozilla::ipc::IPCResult
RecvRemoveBatchDeletedCookies(
69 nsTArray
<CookieStruct
>&& aCookiesList
,
70 nsTArray
<OriginAttributes
>&& aAttrsList
);
72 mozilla::ipc::IPCResult
RecvRemoveCookie(const CookieStruct
& aCookie
,
73 const OriginAttributes
& aAttrs
);
75 mozilla::ipc::IPCResult
RecvAddCookie(const CookieStruct
& aCookie
,
76 const OriginAttributes
& aAttrs
);
78 CookiesMap mCookiesMap
;
79 nsCOMPtr
<nsITimer
> mCookieTimer
;
80 nsCOMPtr
<mozIThirdPartyUtil
> mThirdPartyUtil
;
81 nsCOMPtr
<nsIEffectiveTLDService
> mTLDService
;
85 } // namespace mozilla
87 #endif // mozilla_net_CookieServiceChild_h__