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