Bug 1851322 [wpt PR 41781] - HTML: "gopher" is no longer a special scheme, a=testonly
[gecko.git] / netwerk / cookie / CookiePrivateStorage.cpp
blobe6d8fd67d29269c545b9361aac9854778c34d9af
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 #include "CookiePrivateStorage.h"
7 #include "Cookie.h"
9 namespace mozilla {
10 namespace net {
12 // static
13 already_AddRefed<CookiePrivateStorage> CookiePrivateStorage::Create() {
14 RefPtr<CookiePrivateStorage> storage = new CookiePrivateStorage();
15 storage->Init();
17 return storage.forget();
20 void CookiePrivateStorage::StaleCookies(const nsTArray<Cookie*>& aCookieList,
21 int64_t aCurrentTimeInUsec) {
22 int32_t count = aCookieList.Length();
23 for (int32_t i = 0; i < count; ++i) {
24 Cookie* cookie = aCookieList.ElementAt(i);
26 if (cookie->IsStale()) {
27 cookie->SetLastAccessed(aCurrentTimeInUsec);
32 // purges expired and old cookies in a batch operation.
33 already_AddRefed<nsIArray> CookiePrivateStorage::PurgeCookies(
34 int64_t aCurrentTimeInUsec, uint16_t aMaxNumberOfCookies,
35 int64_t aCookiePurgeAge) {
36 RefPtr<CookiePrivateStorage> self = this;
37 return PurgeCookiesWithCallbacks(
38 aCurrentTimeInUsec, aMaxNumberOfCookies, aCookiePurgeAge,
39 [self](const CookieListIter& iter) { self->RemoveCookieFromList(iter); },
40 nullptr);
43 } // namespace net
44 } // namespace mozilla