| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ | 5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ |
| 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ | 6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace precache { | 24 namespace precache { |
| 25 | 25 |
| 26 class PrecacheUnfinishedWork; | 26 class PrecacheUnfinishedWork; |
| 27 | 27 |
| 28 // Denotes the type of session information being stored. | 28 // Denotes the type of session information being stored. |
| 29 enum SessionDataType { | 29 enum SessionDataType { |
| 30 // Unfinished work to do sometime later. | 30 // Unfinished work to do sometime later. |
| 31 UNFINISHED_WORK = 0, | 31 UNFINISHED_WORK = 0, |
| 32 // Timestamp of the last precache. |
| 33 LAST_PRECACHE_TIMESTAMP = 1, |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 class PrecacheSessionTable { | 36 class PrecacheSessionTable { |
| 35 public: | 37 public: |
| 36 PrecacheSessionTable(); | 38 PrecacheSessionTable(); |
| 37 virtual ~PrecacheSessionTable(); | 39 virtual ~PrecacheSessionTable(); |
| 38 | 40 |
| 39 // Initializes the precache task URL table for use with the specified database | 41 // Initializes the precache task URL table for use with the specified database |
| 40 // connection. The caller keeps ownership of |db|, and |db| must not be null. | 42 // connection. The caller keeps ownership of |db|, and |db| must not be null. |
| 41 // Init must be called before any other methods. | 43 // Init must be called before any other methods. |
| 42 bool Init(sql::Connection* db); | 44 bool Init(sql::Connection* db); |
| 43 | 45 |
| 46 // -- Time since last precache -- |
| 47 void SetLastPrecacheTimestamp(const base::Time& time); |
| 48 base::Time GetLastPrecacheTimestamp(); |
| 49 void DeleteLastPrecacheTimestamp(); |
| 50 |
| 51 // -- Unfinished work -- |
| 52 |
| 44 // Stores unfinished work. | 53 // Stores unfinished work. |
| 45 void SaveUnfinishedWork( | 54 void SaveUnfinishedWork( |
| 46 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); | 55 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); |
| 47 | 56 |
| 48 // Retrieves unfinished work. | 57 // Retrieves unfinished work. |
| 49 std::unique_ptr<PrecacheUnfinishedWork> GetUnfinishedWork(); | 58 std::unique_ptr<PrecacheUnfinishedWork> GetUnfinishedWork(); |
| 50 | 59 |
| 51 // Removes all unfinished work from the database. | 60 // Removes all unfinished work from the database. |
| 52 void DeleteUnfinishedWork(); | 61 void DeleteUnfinishedWork(); |
| 53 | 62 |
| 54 private: | 63 private: |
| 55 bool CreateTableIfNonExistent(); | 64 bool CreateTableIfNonExistent(); |
| 56 | 65 |
| 57 // Non-owned pointer. | 66 // Non-owned pointer. |
| 58 sql::Connection* db_; | 67 sql::Connection* db_; |
| 59 | 68 |
| 60 DISALLOW_COPY_AND_ASSIGN(PrecacheSessionTable); | 69 DISALLOW_COPY_AND_ASSIGN(PrecacheSessionTable); |
| 61 }; | 70 }; |
| 62 | 71 |
| 63 } // namespace precache | 72 } // namespace precache |
| 64 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ | 73 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ |
| OLD | NEW |