Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / netwerk / cookie / CookieServiceParent.h
blob9859879b05be45d6fc6a6f0c53cfc45df776bb9d
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_CookieServiceParent_h
7 #define mozilla_net_CookieServiceParent_h
9 #include "mozilla/net/PCookieServiceParent.h"
10 #include "mozilla/net/CookieKey.h"
12 class nsIArray;
13 class nsICookie;
14 namespace mozilla {
15 class OriginAttributes;
18 class nsIEffectiveTLDService;
20 namespace mozilla {
21 namespace net {
23 class Cookie;
24 class CookieService;
26 class CookieServiceParent : public PCookieServiceParent {
27 friend class PCookieServiceParent;
29 public:
30 CookieServiceParent();
31 virtual ~CookieServiceParent() = default;
33 void TrackCookieLoad(nsIChannel* aChannel);
35 void RemoveBatchDeletedCookies(nsIArray* aCookieList);
37 void RemoveAll();
39 void RemoveCookie(const Cookie& aCookie);
41 void AddCookie(const Cookie& aCookie);
43 // This will return true if the CookieServiceParent is currently processing
44 // an update from the content process. This is used in ContentParent to make
45 // sure that we are only forwarding those cookie updates to other content
46 // processes, not the one they originated from.
47 bool ProcessingCookie() { return mProcessingCookie; }
49 bool ContentProcessHasCookie(const Cookie& cookie);
50 bool InsecureCookieOrSecureOrigin(const Cookie& cookie);
51 void UpdateCookieInContentList(nsIURI* aHostURI,
52 const OriginAttributes& aOriginAttrs);
54 mozilla::ipc::IPCResult SetCookies(
55 const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
56 nsIURI* aHost, bool aFromHttp, const nsTArray<CookieStruct>& aCookies,
57 dom::BrowsingContext* aBrowsingContext = nullptr);
59 protected:
60 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
62 mozilla::ipc::IPCResult RecvSetCookies(
63 const nsCString& aBaseDomain, const OriginAttributes& aOriginAttributes,
64 nsIURI* aHost, bool aFromHttp, const nsTArray<CookieStruct>& aCookies);
66 mozilla::ipc::IPCResult RecvGetCookieList(
67 nsIURI* aHost, const bool& aIsForeign,
68 const bool& aIsThirdPartyTrackingResource,
69 const bool& aIsThirdPartySocialTrackingResource,
70 const bool& aStorageAccessPermissionGranted,
71 const uint32_t& aRejectedReason, const bool& aIsSafeTopLevelNav,
72 const bool& aIsSameSiteForeign, const bool& aHadCrossSiteRedirects,
73 nsTArray<OriginAttributes>&& aAttrsList,
74 GetCookieListResolver&& aResolve);
76 static void SerializeCookieListTable(
77 const nsTArray<Cookie*>& aFoundCookieList,
78 nsTArray<CookieStructTable>& aCookiesListTable, nsIURI* aHostURI);
80 nsCOMPtr<nsIEffectiveTLDService> mTLDService;
81 RefPtr<CookieService> mCookieService;
82 bool mProcessingCookie;
83 nsTHashMap<CookieKey, bool> mCookieKeysInContent;
86 } // namespace net
87 } // namespace mozilla
89 #endif // mozilla_net_CookieServiceParent_h