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
3 // found in the LICENSE file.
5 // A sqlite implementation of a cookie monster persistent store.
7 #ifndef CONTENT_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_
8 #define CONTENT_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_
13 #include "base/callback_forward.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/ref_counted.h"
16 #include "content/common/content_export.h"
17 #include "net/cookies/cookie_monster.h"
23 class SequencedTaskRunner
;
27 class CanonicalCookie
;
28 class CookieCryptoDelegate
;
32 class SpecialStoragePolicy
;
37 // Implements the PersistentCookieStore interface in terms of a SQLite database.
38 // For documentation about the actual member functions consult the documentation
39 // of the parent class |net::CookieMonster::PersistentCookieStore|.
40 // If provided, a |SpecialStoragePolicy| is consulted when the SQLite database
41 // is closed to decide which cookies to keep.
42 class CONTENT_EXPORT SQLitePersistentCookieStore
43 : public net::CookieMonster::PersistentCookieStore
{
45 // All blocking database accesses will be performed on
46 // |background_task_runner|, while |client_task_runner| is used to invoke
48 SQLitePersistentCookieStore(
49 const base::FilePath
& path
,
50 const scoped_refptr
<base::SequencedTaskRunner
>& client_task_runner
,
51 const scoped_refptr
<base::SequencedTaskRunner
>& background_task_runner
,
52 bool restore_old_session_cookies
,
53 storage::SpecialStoragePolicy
* special_storage_policy
,
54 net::CookieCryptoDelegate
* crypto_delegate
);
56 // net::CookieMonster::PersistentCookieStore:
57 void Load(const LoadedCallback
& loaded_callback
) override
;
58 void LoadCookiesForKey(const std::string
& key
,
59 const LoadedCallback
& callback
) override
;
60 void AddCookie(const net::CanonicalCookie
& cc
) override
;
61 void UpdateCookieAccessTime(const net::CanonicalCookie
& cc
) override
;
62 void DeleteCookie(const net::CanonicalCookie
& cc
) override
;
63 void SetForceKeepSessionState() override
;
64 void Flush(const base::Closure
& callback
) override
;
67 ~SQLitePersistentCookieStore() override
;
72 scoped_refptr
<Backend
> backend_
;
74 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore
);
77 } // namespace content
79 #endif // CONTENT_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_