• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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.
4 
5 // A sqlite implementation of a cookie monster persistent store.
6 
7 #ifndef CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_
8 #define CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 #include "base/memory/ref_counted.h"
15 #include "net/base/cookie_monster.h"
16 
17 class FilePath;
18 
19 // Implements the PersistentCookieStore interface in terms of a SQLite database.
20 // For documentation about the actual member functions consult the documentation
21 // of the parent class |net::CookieMonster::PersistentCookieStore|.
22 class SQLitePersistentCookieStore
23     : public net::CookieMonster::PersistentCookieStore {
24  public:
25   explicit SQLitePersistentCookieStore(const FilePath& path);
26   virtual ~SQLitePersistentCookieStore();
27 
28   virtual bool Load(std::vector<net::CookieMonster::CanonicalCookie*>* cookies);
29 
30   virtual void AddCookie(const net::CookieMonster::CanonicalCookie& cc);
31   virtual void UpdateCookieAccessTime(
32       const net::CookieMonster::CanonicalCookie& cc);
33   virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie& cc);
34 
35   virtual void SetClearLocalStateOnExit(bool clear_local_state);
36 
37   virtual void Flush(Task* completion_task);
38 
39 #if defined(ANDROID)
40   int GetCookieCount();
41 #endif
42 
43  private:
44   class Backend;
45 
46   scoped_refptr<Backend> backend_;
47 
48   DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore);
49 };
50 
51 #endif  // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_
52