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