| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2013 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 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
|  | 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
|  | 7 | 
|  | 8 #include <map> | 
|  | 9 #include <string> | 
|  | 10 | 
|  | 11 #include "base/time/time.h" | 
|  | 12 #include "url/gurl.h" | 
|  | 13 | 
|  | 14 namespace sql { | 
|  | 15 class Connection; | 
|  | 16 } | 
|  | 17 | 
|  | 18 namespace precache { | 
|  | 19 | 
|  | 20 // Interface for database table that keeps track of the URLs that have been | 
|  | 21 // precached. Manages one table { URL (primary key), precache timestamp }. | 
|  | 22 class PrecacheURLTable { | 
|  | 23  public: | 
|  | 24   PrecacheURLTable(); | 
|  | 25   ~PrecacheURLTable(); | 
|  | 26 | 
|  | 27   // Initialize the precache URL table for use with the specified database | 
|  | 28   // connection. The caller keeps ownership of |db|, and |db| must not be NULL. | 
|  | 29   // Init must be called before any other methods. | 
|  | 30   void Init(sql::Connection* db); | 
|  | 31 | 
|  | 32   // Adds a precached URL to the table, using the current time as the | 
|  | 33   // precache timestamp. Replaces the row if one already exists. | 
|  | 34   void AddURL(const GURL& url, const base::Time& precache_time); | 
|  | 35 | 
|  | 36   // Returns true if this URL exists in the table. | 
|  | 37   bool HasURL(const GURL& url); | 
|  | 38 | 
|  | 39   // Deletes the row from the table that has the given URL, if it exists. | 
|  | 40   void DeleteURL(const GURL& url); | 
|  | 41 | 
|  | 42   // Deletes all records that were precached between the specified timestamps. | 
|  | 43   void DeleteAllPrecachedBetween(const base::Time& delete_begin, | 
|  | 44                                  const base::Time& delete_end); | 
|  | 45 | 
|  | 46   // Used by tests to get the contents of the table. | 
|  | 47   void GetAllData(std::map<GURL, base::Time>* map); | 
|  | 48 | 
|  | 49  private: | 
|  | 50   // Returns the spec of the given URL. | 
|  | 51   static std::string GetKey(const GURL& url); | 
|  | 52 | 
|  | 53   void CreateTableIfNonExistent(); | 
|  | 54 | 
|  | 55   // Non-owned pointer. | 
|  | 56   sql::Connection* db_; | 
|  | 57 | 
|  | 58   DISALLOW_COPY_AND_ASSIGN(PrecacheURLTable); | 
|  | 59 }; | 
|  | 60 | 
|  | 61 }  // namespace precache | 
|  | 62 | 
|  | 63 #endif  // COMPONENTS_PRECACHE_CORE_PRECACHE_URL_TABLE_H_ | 
| OLD | NEW | 
|---|