OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COMMON_NET_COOKIE_MONSTER_SQLITE_H__ | 7 #ifndef CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
8 #define CHROME_COMMON_NET_COOKIE_MONSTER_SQLITE_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 "app/sql/connection.h" |
| 14 #include "app/sql/meta_table.h" |
| 15 #include "base/file_path.h" |
13 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
14 #include "chrome/browser/meta_table_helper.h" | |
15 #include "net/base/cookie_monster.h" | 17 #include "net/base/cookie_monster.h" |
16 | 18 |
17 struct sqlite3; | 19 class FilePath; |
18 | |
19 class MessageLoop; | 20 class MessageLoop; |
20 | 21 |
21 class SQLitePersistentCookieStore | 22 class SQLitePersistentCookieStore |
22 : public net::CookieMonster::PersistentCookieStore { | 23 : public net::CookieMonster::PersistentCookieStore { |
23 public: | 24 public: |
24 SQLitePersistentCookieStore(const std::wstring& path, | 25 SQLitePersistentCookieStore(const FilePath& path, |
25 MessageLoop* background_loop); | 26 MessageLoop* background_loop); |
26 ~SQLitePersistentCookieStore(); | 27 ~SQLitePersistentCookieStore(); |
27 | 28 |
28 virtual bool Load(std::vector<net::CookieMonster::KeyedCanonicalCookie>*); | 29 virtual bool Load(std::vector<net::CookieMonster::KeyedCanonicalCookie>*); |
29 | 30 |
30 virtual void AddCookie(const std::string&, | 31 virtual void AddCookie(const std::string&, |
31 const net::CookieMonster::CanonicalCookie&); | 32 const net::CookieMonster::CanonicalCookie&); |
32 virtual void UpdateCookieAccessTime( | 33 virtual void UpdateCookieAccessTime( |
33 const net::CookieMonster::CanonicalCookie&); | 34 const net::CookieMonster::CanonicalCookie&); |
34 virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie&); | 35 virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie&); |
35 | 36 |
36 private: | 37 private: |
37 class Backend; | 38 class Backend; |
38 | 39 |
39 // Database upgrade statements. | 40 // Database upgrade statements. |
40 bool EnsureDatabaseVersion(sqlite3* db); | 41 bool EnsureDatabaseVersion(sql::Connection* db); |
41 | 42 |
42 std::wstring path_; | 43 FilePath path_; |
43 scoped_refptr<Backend> backend_; | 44 scoped_refptr<Backend> backend_; |
44 | 45 |
45 // Background MessageLoop on which to access the backend_; | 46 // Background MessageLoop on which to access the backend_; |
46 MessageLoop* background_loop_; | 47 MessageLoop* background_loop_; |
47 | 48 |
48 MetaTableHelper meta_table_; | 49 sql::MetaTable meta_table_; |
49 | 50 |
50 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); | 51 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); |
51 }; | 52 }; |
52 | 53 |
53 #endif // CHROME_COMMON_NET_COOKIE_MONSTER_SQLITE_H__ | 54 #endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ |
OLD | NEW |