1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_
6 #define CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "content/common/content_export.h"
15 #include "net/cookies/cookie_monster.h"
16 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h"
22 class SequencedTaskRunner
;
26 class CanonicalCookie
;
27 class CookieCryptoDelegate
;
31 class SpecialStoragePolicy
;
32 } // namespace storage
36 // Implements a PersistentCookieStore that deletes session cookies on
37 // shutdown. For documentation about the actual member functions consult the
38 // parent class |net::CookieMonster::PersistentCookieStore|. If provided, a
39 // |SpecialStoragePolicy| is consulted when the SQLite database is closed to
40 // decide which cookies to keep.
41 class CONTENT_EXPORT QuotaPolicyCookieStore
42 : public net::CookieMonster::PersistentCookieStore
{
44 // Wraps the passed-in |cookie_store|.
45 QuotaPolicyCookieStore(
46 const scoped_refptr
<net::SQLitePersistentCookieStore
>& cookie_store
,
47 storage::SpecialStoragePolicy
* special_storage_policy
);
49 // net::CookieMonster::PersistentCookieStore:
50 void Load(const LoadedCallback
& loaded_callback
) override
;
51 void LoadCookiesForKey(const std::string
& key
,
52 const LoadedCallback
& callback
) override
;
53 void AddCookie(const net::CanonicalCookie
& cc
) override
;
54 void UpdateCookieAccessTime(const net::CanonicalCookie
& cc
) override
;
55 void DeleteCookie(const net::CanonicalCookie
& cc
) override
;
56 void SetForceKeepSessionState() override
;
57 void Flush(const base::Closure
& callback
) override
;
60 typedef std::map
<net::SQLitePersistentCookieStore::CookieOrigin
, size_t>
63 ~QuotaPolicyCookieStore() override
;
65 // Called after cookies are loaded from the database. Calls |loaded_callback|
67 void OnLoad(const LoadedCallback
& loaded_callback
,
68 const std::vector
<net::CanonicalCookie
*>& cookies
);
70 // Map of (domain keys(eTLD+1), is secure cookie) to number of cookies in the
72 CookiesPerOriginMap cookies_per_origin_
;
74 scoped_refptr
<storage::SpecialStoragePolicy
> special_storage_policy_
;
75 scoped_refptr
<net::SQLitePersistentCookieStore
> persistent_store_
;
77 DISALLOW_COPY_AND_ASSIGN(QuotaPolicyCookieStore
);
80 } // namespace content
82 #endif // CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_