Complete SyncMessageFilter initialization after SyncChannel initialization
[chromium-blink-merge.git] / net / extras / sqlite / sqlite_persistent_cookie_store.h
blobc55ef6deec045817712eaf92d76ecf7a509f2d33
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 #ifndef NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_COOKIE_STORE_H_
6 #define NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_COOKIE_STORE_H_
8 #include <list>
9 #include <string>
10 #include <utility>
11 #include <vector>
13 #include "base/callback_forward.h"
14 #include "base/memory/ref_counted.h"
15 #include "net/cookies/cookie_monster.h"
17 class Task;
19 namespace base {
20 class FilePath;
21 class SequencedTaskRunner;
22 } // namespace base
24 namespace net {
25 class CanonicalCookie;
26 class CookieCryptoDelegate;
28 // Implements the PersistentCookieStore interface in terms of a SQLite database.
29 // For documentation about the actual member functions consult the documentation
30 // of the parent class |CookieMonster::PersistentCookieStore|.
31 class SQLitePersistentCookieStore
32 : public CookieMonster::PersistentCookieStore {
33 public:
34 // Contains the origin and a bool indicating whether or not the
35 // origin is secure.
36 typedef std::pair<std::string, bool> CookieOrigin;
38 // All blocking database accesses will be performed on
39 // |background_task_runner|, while |client_task_runner| is used to invoke
40 // callbacks.
41 SQLitePersistentCookieStore(
42 const base::FilePath& path,
43 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
44 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
45 bool restore_old_session_cookies,
46 CookieCryptoDelegate* crypto_delegate);
48 // Deletes the cookies whose origins match those given in |cookies|.
49 void DeleteAllInList(const std::list<CookieOrigin>& cookies);
51 // Closes the database backend and fires |callback| on the worker
52 // thread. After Close() is called, further calls to the
53 // PersistentCookieStore methods will do nothing, with Load() and
54 // LoadCookiesForKey() additionally calling their callback methods
55 // with an empty vector of CanonicalCookies.
56 void Close(const base::Closure& callback);
58 // CookieMonster::PersistentCookieStore:
59 void Load(const LoadedCallback& loaded_callback) override;
60 void LoadCookiesForKey(const std::string& key,
61 const LoadedCallback& callback) override;
62 void AddCookie(const CanonicalCookie& cc) override;
63 void UpdateCookieAccessTime(const CanonicalCookie& cc) override;
64 void DeleteCookie(const CanonicalCookie& cc) override;
65 void SetForceKeepSessionState() override;
66 void Flush(const base::Closure& callback) override;
68 private:
69 ~SQLitePersistentCookieStore() override;
71 class Backend;
73 scoped_refptr<Backend> backend_;
75 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore);
78 } // namespace net
80 #endif // NET_EXTRAS_SQLITE_SQLITE_PERSISTENT_COOKIE_STORE_H_