sqlite_persistent_cookie_store.h revision 2de9a1a363201c0c9ef3e9a00ba660848aede7eb
1// Copyright (c) 2010 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 "app/sql/meta_table.h" 15#include "base/file_path.h" 16#include "base/ref_counted.h" 17#include "net/base/cookie_monster.h" 18 19namespace sql { 20class Connection; 21} 22 23class FilePath; 24 25class SQLitePersistentCookieStore 26 : public net::CookieMonster::PersistentCookieStore { 27 public: 28 explicit SQLitePersistentCookieStore(const FilePath& path); 29 ~SQLitePersistentCookieStore(); 30 31 virtual bool Load(std::vector<net::CookieMonster::CanonicalCookie*>*); 32 33 virtual void AddCookie(const net::CookieMonster::CanonicalCookie&); 34 virtual void UpdateCookieAccessTime( 35 const net::CookieMonster::CanonicalCookie&); 36 virtual void DeleteCookie(const net::CookieMonster::CanonicalCookie&); 37 38#if defined(ANDROID) 39 virtual void Flush(Task* completion_task); 40#endif 41 42 static void ClearLocalState(const FilePath& path); 43 44 private: 45 class Backend; 46 47 // Database upgrade statements. 48 bool EnsureDatabaseVersion(sql::Connection* db); 49 50 FilePath path_; 51 scoped_refptr<Backend> backend_; 52 53 sql::MetaTable meta_table_; 54 55 DISALLOW_COPY_AND_ASSIGN(SQLitePersistentCookieStore); 56}; 57 58#endif // CHROME_BROWSER_NET_SQLITE_PERSISTENT_COOKIE_STORE_H_ 59