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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
6 #define CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_
8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h"
13 class SequencedTaskRunner
;
17 class CookieMonsterDelegate
;
22 class SpecialStoragePolicy
;
26 class CookieCryptoDelegate
;
28 struct CONTENT_EXPORT CookieStoreConfig
{
29 // Specifies how session cookies are persisted in the backing data store.
31 // EPHEMERAL_SESSION_COOKIES specifies session cookies will not be written
32 // out in a manner that allows for restoration.
34 // PERSISTANT_SESSION_COOKIES specifies that session cookies are not restored
35 // when the cookie store is opened, however they will be written in a manner
36 // that allows for them to be restored if the cookie store is opened again
37 // using RESTORED_SESSION_COOKIES.
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
48 // Convenience constructor for an in-memory cookie store with no delegate.
51 // If |path| is empty, then this specifies an in-memory cookie store.
52 // With in-memory cookie stores, |session_cookie_mode| must be
53 // EPHEMERAL_SESSION_COOKIES.
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 storage::SpecialStoragePolicy
* storage_policy
,
60 net::CookieMonsterDelegate
* cookie_delegate
);
63 const base::FilePath path
;
64 const SessionCookieMode session_cookie_mode
;
65 const scoped_refptr
<storage::SpecialStoragePolicy
> storage_policy
;
66 const scoped_refptr
<net::CookieMonsterDelegate
> cookie_delegate
;
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
73 // Used to provide encryption hooks for the cookie store. The
74 // CookieCryptoDelegate must outlive any cookie store created with this
76 content::CookieCryptoDelegate
* crypto_delegate
;
78 // Callbacks for data load events will be performed on |client_task_runner|.
79 // If NULL, uses the task runner for BrowserThread::IO.
81 // Only used for persistent cookie stores.
82 scoped_refptr
<base::SequencedTaskRunner
> client_task_runner
;
84 // All blocking database accesses will be performed on
85 // |background_task_runner|. If NULL, uses a SequencedTaskRunner from the
86 // BrowserThread blocking pool.
88 // Only used for persistent cookie stores.
89 scoped_refptr
<base::SequencedTaskRunner
> background_task_runner
;
92 CONTENT_EXPORT
net::CookieStore
* CreateCookieStore(
93 const CookieStoreConfig
& config
);
95 } // namespace content
97 #endif // CONTENT_PUBLIC_BROWSER_COOKIE_STORE_FACTORY_H_