| Index: components/precache/core/precache_url_table.h | 
| diff --git a/components/precache/core/precache_url_table.h b/components/precache/core/precache_url_table.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..f0b0249e9243ae691310311b84a57f1f1ad6812c | 
| --- /dev/null | 
| +++ b/components/precache/core/precache_url_table.h | 
| @@ -0,0 +1,63 @@ | 
| +// Copyright 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
| +#define COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
| + | 
| +#include <map> | 
| +#include <string> | 
| + | 
| +#include "base/time/time.h" | 
| +#include "url/gurl.h" | 
| + | 
| +namespace sql { | 
| +class Connection; | 
| +} | 
| + | 
| +namespace precache { | 
| + | 
| +// Interface for database table that keeps track of the URLs that have been | 
| +// precached. Manages one table { URL (primary key), precache timestamp }. | 
| +class PrecacheURLTable { | 
| + public: | 
| +  PrecacheURLTable(); | 
| +  ~PrecacheURLTable(); | 
| + | 
| +  // Initialize the precache URL table for use with the specified database | 
| +  // connection. The caller keeps ownership of |db|, and |db| must not be NULL. | 
| +  // Init must be called before any other methods. | 
| +  void Init(sql::Connection* db); | 
| + | 
| +  // Adds a precached URL to the table, using the current time as the | 
| +  // precache timestamp. Replaces the row if one already exists. | 
| +  void AddURL(const GURL& url, const base::Time& precache_time); | 
| + | 
| +  // Returns true if this URL exists in the table. | 
| +  bool HasURL(const GURL& url); | 
| + | 
| +  // Deletes the row from the table that has the given URL, if it exists. | 
| +  void DeleteURL(const GURL& url); | 
| + | 
| +  // Deletes all records that were precached between the specified timestamps. | 
| +  void DeleteAllPrecachedBetween(const base::Time& delete_begin, | 
| +                                 const base::Time& delete_end); | 
| + | 
| +  // Used by tests to get the contents of the table. | 
| +  void GetAllData(std::map<GURL, base::Time>* map); | 
| + | 
| + private: | 
| +  // Returns the spec of the given URL. | 
| +  static std::string GetKey(const GURL& url); | 
| + | 
| +  void CreateTableIfNonExistent(); | 
| + | 
| +  // Non-owned pointer. | 
| +  sql::Connection* db_; | 
| + | 
| +  DISALLOW_COPY_AND_ASSIGN(PrecacheURLTable); | 
| +}; | 
| + | 
| +}  // namespace precache | 
| + | 
| +#endif  // COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
|  |