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"
13 already_AddRefed
<CookiePrivateStorage
> CookiePrivateStorage::Create() {
14 RefPtr
<CookiePrivateStorage
> storage
= new CookiePrivateStorage();
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
); },
44 } // namespace mozilla