OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ |
6 #define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ | 6 #define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ |
7 | 7 |
| 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" |
8 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
9 #include "net/cookies/cookie_monster.h" | |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 class FilePath; | 13 class SequencedTaskRunner; |
| 14 } |
| 15 |
| 16 namespace net { |
| 17 class CookieMonsterDelegate; |
| 18 class CookieStore; |
13 } | 19 } |
14 | 20 |
15 namespace quota { | 21 namespace quota { |
16 class SpecialStoragePolicy; | 22 class SpecialStoragePolicy; |
17 } | 23 } |
18 | 24 |
19 namespace content { | 25 namespace content { |
20 class CookieCryptoDelegate; | 26 class CookieCryptoDelegate; |
21 | 27 |
22 // All blocking database accesses will be performed on |background_task_runner|. | 28 struct CONTENT_EXPORT CookieStoreConfig { |
23 // Callbacks for data load events will be performed on |client_task_runner|. | 29 // Specifies how session cookies are persisted in the backing data store. |
24 CONTENT_EXPORT net::CookieStore* CreatePersistentCookieStore( | 30 // |
25 const base::FilePath& path, | 31 // EPHEMERAL_SESSION_COOKIES specifies session cookies will not be written |
26 bool restore_old_session_cookies, | 32 // out in a manner that allows for restoration. |
27 quota::SpecialStoragePolicy* storage_policy, | 33 // |
28 net::CookieMonster::Delegate* cookie_monster_delegate, | 34 // PERSISTANT_SESSION_COOKIES specifies that session cookies are not restored |
29 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, | 35 // when the cookie store is opened, however they will be written in a manner |
30 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | 36 // that allows for them to be restored if the cookie store is opened again |
31 scoped_ptr<CookieCryptoDelegate> crypto_delegate); | 37 // using RESTORED_SESSION_COOKIES. |
| 38 // |
| 39 // RESTORED_SESSION_COOKIES is the: same as PERSISTANT_SESSION_COOKIES |
| 40 // except when the cookie store is opened, the previously written session |
| 41 // cookies are loaded first. |
| 42 enum SessionCookieMode { |
| 43 EPHEMERAL_SESSION_COOKIES, |
| 44 PERSISTANT_SESSION_COOKIES, |
| 45 RESTORED_SESSION_COOKIES |
| 46 }; |
32 | 47 |
33 // Uses the default client_task_runner and background_task_runner. | 48 // Convenience constructor for an in-memory cookie store with no delegate. |
34 CONTENT_EXPORT net::CookieStore* CreatePersistentCookieStore( | 49 CookieStoreConfig(); |
35 const base::FilePath& path, | |
36 bool restore_old_session_cookies, | |
37 quota::SpecialStoragePolicy* storage_policy, | |
38 net::CookieMonster::Delegate* cookie_monster_delegate, | |
39 scoped_ptr<CookieCryptoDelegate> crypto_delegate); | |
40 | 50 |
41 CONTENT_EXPORT net::CookieStore* CreateInMemoryCookieStore( | 51 // If |path| is empty, then this specifies an in-memory cookie store. |
42 net::CookieMonster::Delegate* cookie_monster_delegate); | 52 // With in-memory cookie stores, |session_cookie_mode| must be |
| 53 // EPHEMERAL_SESSION_COOKIES. |
| 54 // |
| 55 // Note: If |crypto_delegate| is non-NULL, it must outlive any CookieStores |
| 56 // created using this config. |
| 57 CookieStoreConfig(const base::FilePath& path, |
| 58 SessionCookieMode session_cookie_mode, |
| 59 quota::SpecialStoragePolicy* storage_policy, |
| 60 net::CookieMonsterDelegate* cookie_delegate); |
| 61 ~CookieStoreConfig(); |
| 62 |
| 63 const base::FilePath path; |
| 64 const SessionCookieMode session_cookie_mode; |
| 65 const scoped_refptr<quota::SpecialStoragePolicy> storage_policy; |
| 66 const scoped_refptr<net::CookieMonsterDelegate> cookie_delegate; |
| 67 |
| 68 // The following are infrequently used cookie store parameters. |
| 69 // Rather than clutter the constructor API, these are assigned a default |
| 70 // value on CookieStoreConfig construction. Clients should then override |
| 71 // them as necessary. |
| 72 |
| 73 // Used to provide encryption hooks for the cookie store. The |
| 74 // CookieCryptoDelegate must outlive any cookie store created with this |
| 75 // config. |
| 76 content::CookieCryptoDelegate* crypto_delegate; |
| 77 |
| 78 // Callbacks for data load events will be performed on |client_task_runner|. |
| 79 // If NULL, uses the task runner for BrowserThread::IO. |
| 80 // |
| 81 // Only used for persistent cookie stores. |
| 82 scoped_refptr<base::SequencedTaskRunner> client_task_runner; |
| 83 |
| 84 // All blocking database accesses will be performed on |
| 85 // |background_task_runner|. If NULL, uses a SequencedTaskRunner from the |
| 86 // BrowserThread blocking pool. |
| 87 // |
| 88 // Only used for persistent cookie stores. |
| 89 scoped_refptr<base::SequencedTaskRunner> background_task_runner; |
| 90 }; |
| 91 |
| 92 CONTENT_EXPORT net::CookieStore* CreateCookieStore( |
| 93 const CookieStoreConfig& config); |
43 | 94 |
44 } // namespace content | 95 } // namespace content |
45 | 96 |
46 #endif // CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ | 97 #endif // CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_ |
OLD | NEW |