OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_ | |
6 #define CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
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" | |
17 | |
18 class Task; | |
19 | |
20 namespace base { | |
21 class FilePath; | |
22 class SequencedTaskRunner; | |
23 } // namespace base | |
24 | |
25 namespace net { | |
26 class CanonicalCookie; | |
27 class CookieCryptoDelegate; | |
28 } // namespace net | |
29 | |
30 namespace storage { | |
31 class SpecialStoragePolicy; | |
32 } // namespace storage | |
33 | |
34 namespace content { | |
35 | |
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 { | |
43 public: | |
44 // Wraps the passed-in |cookie_store|. | |
45 QuotaPolicyCookieStore( | |
46 const scoped_refptr<net::SQLitePersistentCookieStore>& cookie_store, | |
47 storage::SpecialStoragePolicy* special_storage_policy); | |
48 | |
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; | |
58 | |
59 private: | |
60 typedef std::map<net::SQLitePersistentCookieStore::CookieOrigin, size_t> | |
61 CookiesPerOriginMap; | |
62 | |
63 ~QuotaPolicyCookieStore() override; | |
64 | |
65 // Called after cookies are loaded from the database. Calls |loaded_callback| | |
66 // when done. | |
67 void OnLoad(const LoadedCallback& loaded_callback, | |
68 const std::vector<net::CanonicalCookie*>& cookies); | |
69 | |
70 // Map of (domain keys(eTLD+1), is secure cookie) to number of cookies in the | |
71 // database. | |
72 CookiesPerOriginMap cookies_per_origin_; | |
73 | |
74 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; | |
75 scoped_refptr<net::SQLitePersistentCookieStore> persistent_store_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(QuotaPolicyCookieStore); | |
78 }; | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_BROWSER_NET_QUOTA_POLICY_COOKIE_STORE_H_ | |
OLD | NEW |