Chromium Code Reviews| Index: components/precache/core/precache_session_table.h |
| diff --git a/components/precache/core/precache_session_table.h b/components/precache/core/precache_session_table.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1701089ab42843b1b87b4ddf0f18b716584ef72f |
| --- /dev/null |
| +++ b/components/precache/core/precache_session_table.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2016 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_SESSION_TABLE_H_ |
| +#define COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ |
| + |
| +#include <list> |
| +#include <map> |
| +#include <memory> |
| + |
| +#include "base/macros.h" |
| +#include "base/time/time.h" |
| +#include "url/gurl.h" |
| + |
| +namespace base { |
| +class TimeTicks; |
| +} |
| + |
| +namespace sql { |
| +class Connection; |
| +} |
| + |
| +namespace precache { |
| + |
| +class PrecacheUnfinishedWork; |
| + |
| +// Denotes the type of session information being stored. |
| +enum SessionDataType { |
| + // Unfinished work to do sometime later. |
| + UNFINISHED_WORK = 0, |
| +}; |
| + |
| +class PrecacheSessionTable { |
|
sclittle
2016/05/19 01:59:46
Maybe consider cutting out this class and just put
bengr
2016/05/19 23:19:32
Nah. I like the separation. Makes it easier to rea
|
| + public: |
| + PrecacheSessionTable(); |
| + virtual ~PrecacheSessionTable(); |
| + |
| + // Initialize the precache task 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. |
| + bool Init(sql::Connection* db); |
| + |
| + // Store unfinished work. |
| + bool SaveUnfinishedWork( |
| + std::unique_ptr<PrecacheUnfinishedWork> unfinished_work); |
| + |
| + // Retrieve unfinished work. |
| + std::unique_ptr<PrecacheUnfinishedWork> GetUnfinishedWork(); |
| + |
| + // Remove all precache session information from the database. |
| + void ClearSessionInformation(); |
| + |
| + private: |
| + bool CreateTableIfNonExistent(); |
| + |
| + // Non-owned pointer. |
| + sql::Connection* db_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrecacheSessionTable); |
| +}; |
| + |
| +} // namespace precache |
| +#endif // COMPONENTS_PRECACHE_CORE_PRECACHE_SESSION_TABLE_H_ |