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; |
| 20 |
| 21 namespace base { |
19 class FilePath; | 22 class FilePath; |
20 class Task; | 23 } |
21 | 24 |
22 namespace net { | 25 namespace net { |
23 class CanonicalCookie; | 26 class CanonicalCookie; |
24 } | 27 } |
25 | 28 |
26 // Implements the PersistentCookieStore interface in terms of a SQLite database. | 29 // Implements the PersistentCookieStore interface in terms of a SQLite database. |
27 // For documentation about the actual member functions consult the documentation | 30 // For documentation about the actual member functions consult the documentation |
28 // of the parent class |net::CookieMonster::PersistentCookieStore|. | 31 // of the parent class |net::CookieMonster::PersistentCookieStore|. |
29 // If provided, a |ClearOnExitPolicy| is consulted when the SQLite database is | 32 // If provided, a |ClearOnExitPolicy| is consulted when the SQLite database is |
30 // closed to decide which cookies to keep. | 33 // closed to decide which cookies to keep. |
31 class SQLitePersistentCookieStore | 34 class SQLitePersistentCookieStore |
32 : public net::CookieMonster::PersistentCookieStore { | 35 : public net::CookieMonster::PersistentCookieStore { |
33 public: | 36 public: |
34 // If non-NULL, SQLitePersistentCookieStore will keep a scoped_refptr to the | 37 // If non-NULL, SQLitePersistentCookieStore will keep a scoped_refptr to the |
35 // |clear_on_exit_policy| throughout its lifetime. | 38 // |clear_on_exit_policy| throughout its lifetime. |
36 SQLitePersistentCookieStore( | 39 SQLitePersistentCookieStore( |
37 const FilePath& path, | 40 const base::FilePath& path, |
38 bool restore_old_session_cookies, | 41 bool restore_old_session_cookies, |
39 ClearOnExitPolicy* clear_on_exit_policy); | 42 ClearOnExitPolicy* clear_on_exit_policy); |
40 | 43 |
41 // net::CookieMonster::PersistentCookieStore: | 44 // net::CookieMonster::PersistentCookieStore: |
42 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; | 45 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; |
43 virtual void LoadCookiesForKey(const std::string& key, | 46 virtual void LoadCookiesForKey(const std::string& key, |
44 const LoadedCallback& callback) OVERRIDE; | 47 const LoadedCallback& callback) OVERRIDE; |
45 virtual void AddCookie(const net::CanonicalCookie& cc) OVERRIDE; | 48 virtual void AddCookie(const net::CanonicalCookie& cc) OVERRIDE; |
46 virtual void UpdateCookieAccessTime(const net::CanonicalCookie& cc) OVERRIDE; | 49 virtual void UpdateCookieAccessTime(const net::CanonicalCookie& cc) OVERRIDE; |
47 virtual void DeleteCookie(const net::CanonicalCookie& cc) OVERRIDE; | 50 virtual void DeleteCookie(const net::CanonicalCookie& cc) OVERRIDE; |
48 virtual void SetForceKeepSessionState() OVERRIDE; | 51 virtual void SetForceKeepSessionState() OVERRIDE; |
49 virtual void Flush(const base::Closure& callback) OVERRIDE; | 52 virtual void Flush(const base::Closure& callback) OVERRIDE; |
50 | 53 |
51 protected: | 54 protected: |
52 virtual ~SQLitePersistentCookieStore(); | 55 virtual ~SQLitePersistentCookieStore(); |
53 | 56 |
54 private: | 57 private: |
55 class Backend; | 58 class Backend; |
56 | 59 |
57 scoped_refptr<Backend> backend_; | 60 scoped_refptr<Backend> backend_; |
58 | 61 |
59 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); | 62 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); |
60 }; | 63 }; |
61 | 64 |
62 #endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ | 65 #endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
OLD | NEW |