1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// found in the LICENSE file. 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/enhanced_bookmarks/image_store.h" 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "base/files/file_path.h" 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "sql/connection.h" 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "sql/init_status.h" 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// The PersistentImageStore is an implementation of ImageStore that persists its 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// data on disk. 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)class PersistentImageStore : public ImageStore { 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) public: 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Creates a PersistentImageStore in the directory at the given path. 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) explicit PersistentImageStore(const base::FilePath& path); 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual bool HasKey(const GURL& page_url) OVERRIDE; 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Insert(const GURL& page_url, 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const GURL& image_url, 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const gfx::Image& image) OVERRIDE; 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void Erase(const GURL& page_url) OVERRIDE; 25cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual std::pair<gfx::Image, GURL> Get(const GURL& page_url) OVERRIDE; 26cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetSize(const GURL& page_url) OVERRIDE; 27cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void GetAllPageUrls(std::set<GURL>* urls) OVERRIDE; 28cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual void ClearAll() OVERRIDE; 2946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual int64 GetStoreSizeInBytes() OVERRIDE; 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) protected: 32cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual ~PersistentImageStore(); 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) private: 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) sql::InitStatus OpenDatabase(); 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const base::FilePath path_; 38cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) sql::Connection db_; 39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(PersistentImageStore); 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}; 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif // COMPONENTS_ENHANCED_BOOKMARKS_PERSISTENT_IMAGE_STORE_H_ 44