OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A sqlite implementation of a cookie monster persistent store. | 5 // A sqlite implementation of a cookie monster persistent store. |
6 | 6 |
7 #ifndef CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ | 7 #ifndef CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
8 #define CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ | 8 #define CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "net/cookies/cookie_monster.h" | 16 #include "net/cookies/cookie_monster.h" |
17 | 17 |
18 class ClearOnExitPolicy; | 18 class ClearOnExitPolicy; |
19 class Task; | 19 class Task; |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class FilePath; | 22 class FilePath; |
23 class SequencedTaskRunner; | |
24 } | 23 } |
25 | 24 |
26 namespace net { | 25 namespace net { |
27 class CanonicalCookie; | 26 class CanonicalCookie; |
28 } | 27 } |
29 | 28 |
30 // Implements the PersistentCookieStore interface in terms of a SQLite database. | 29 // Implements the PersistentCookieStore interface in terms of a SQLite database. |
31 // For documentation about the actual member functions consult the documentation | 30 // For documentation about the actual member functions consult the documentation |
32 // of the parent class |net::CookieMonster::PersistentCookieStore|. | 31 // of the parent class |net::CookieMonster::PersistentCookieStore|. |
33 // If provided, a |ClearOnExitPolicy| is consulted when the SQLite database is | 32 // If provided, a |ClearOnExitPolicy| is consulted when the SQLite database is |
34 // closed to decide which cookies to keep. | 33 // closed to decide which cookies to keep. |
35 class SQLitePersistentCookieStore | 34 class SQLitePersistentCookieStore |
36 : public net::CookieMonster::PersistentCookieStore { | 35 : public net::CookieMonster::PersistentCookieStore { |
37 public: | 36 public: |
38 // If non-NULL, SQLitePersistentCookieStore will keep a scoped_refptr to the | 37 // If non-NULL, SQLitePersistentCookieStore will keep a scoped_refptr to the |
39 // |clear_on_exit_policy| throughout its lifetime. | 38 // |clear_on_exit_policy| throughout its lifetime. |
40 // All blocking database accesses will be performed on | |
41 // |background_task_runner|, while |client_task_runner| is used to invoke | |
42 // callbacks. | |
43 SQLitePersistentCookieStore( | 39 SQLitePersistentCookieStore( |
44 const base::FilePath& path, | 40 const base::FilePath& path, |
45 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | |
46 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | |
47 bool restore_old_session_cookies, | 41 bool restore_old_session_cookies, |
48 ClearOnExitPolicy* clear_on_exit_policy); | 42 ClearOnExitPolicy* clear_on_exit_policy); |
49 | 43 |
50 // net::CookieMonster::PersistentCookieStore: | 44 // net::CookieMonster::PersistentCookieStore: |
51 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; | 45 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; |
52 virtual void LoadCookiesForKey(const std::string& key, | 46 virtual void LoadCookiesForKey(const std::string& key, |
53 const LoadedCallback& callback) OVERRIDE; | 47 const LoadedCallback& callback) OVERRIDE; |
54 virtual void AddCookie(const net::CanonicalCookie& cc) OVERRIDE; | 48 virtual void AddCookie(const net::CanonicalCookie& cc) OVERRIDE; |
55 virtual void UpdateCookieAccessTime(const net::CanonicalCookie& cc) OVERRIDE; | 49 virtual void UpdateCookieAccessTime(const net::CanonicalCookie& cc) OVERRIDE; |
56 virtual void DeleteCookie(const net::CanonicalCookie& cc) OVERRIDE; | 50 virtual void DeleteCookie(const net::CanonicalCookie& cc) OVERRIDE; |
57 virtual void SetForceKeepSessionState() OVERRIDE; | 51 virtual void SetForceKeepSessionState() OVERRIDE; |
58 virtual void Flush(const base::Closure& callback) OVERRIDE; | 52 virtual void Flush(const base::Closure& callback) OVERRIDE; |
59 | 53 |
60 protected: | 54 protected: |
61 virtual ~SQLitePersistentCookieStore(); | 55 virtual ~SQLitePersistentCookieStore(); |
62 | 56 |
63 private: | 57 private: |
64 class Backend; | 58 class Backend; |
65 | 59 |
66 scoped_refptr<Backend> backend_; | 60 scoped_refptr<Backend> backend_; |
67 | 61 |
68 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); | 62 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); |
69 }; | 63 }; |
70 | 64 |
71 #endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ | 65 #endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
OLD | NEW |