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