Index: components/precache/core/precache_referrer_host_table.h |
diff --git a/components/precache/core/precache_referrer_host_table.h b/components/precache/core/precache_referrer_host_table.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c5928da2b1192ff36421512efe27f08b490d5d63 |
--- /dev/null |
+++ b/components/precache/core/precache_referrer_host_table.h |
@@ -0,0 +1,73 @@ |
+// 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_REFERRER_HOST_TABLE_H_ |
+#define COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_ |
+ |
+#include <string> |
+ |
+#include "base/macros.h" |
+#include "base/time/time.h" |
+#include "url/gurl.h" |
+ |
+namespace sql { |
+class Connection; |
+} |
+ |
+namespace precache { |
+ |
+struct PrecacheReferrerHostEntry { |
+ static const int64_t INVALID_ID; |
sclittle
2016/08/11 22:52:36
nit: Name this like a constant, e.g. kInvalidId
Raj
2016/08/12 19:04:21
Done.
|
+ |
+ PrecacheReferrerHostEntry(int64_t id, |
+ const GURL& referrer_host, |
+ int64_t manifest_id, |
+ const base::Time& time) |
+ : id(id), |
+ referrer_host(referrer_host), |
+ manifest_id(manifest_id), |
+ time(time) {} |
+ |
+ const int64_t id; |
bengr
2016/08/11 18:49:15
#include <stdint.h>
Raj
2016/08/12 19:04:21
Done.
|
+ const GURL referrer_host; |
sclittle
2016/08/11 22:52:36
Change all these to be non-const. Just pass around
Raj
2016/08/12 19:04:21
Done.
|
+ const int64_t manifest_id; |
+ const base::Time time; |
+}; |
+ |
+class PrecacheReferrerHostTable { |
+ public: |
+ PrecacheReferrerHostTable(); |
+ ~PrecacheReferrerHostTable(); |
+ |
+ // Initialize the precache referrer host 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); |
+ |
+ // Returns the referrer host information about |referrer_host|. |
+ PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host); |
+ |
+ // Updates the referrer host information about |referrer_host|. |
+ int64_t UpdateReferrerHost(const std::string& referrer_host, |
+ int64_t manifest_id, |
+ const base::Time& time); |
+ |
+ // Deletes entries that were created before the time of |delete_end|. |
+ void DeleteAllEntriesBefore(const base::Time& delete_end); |
+ |
+ // Delete all entries. |
+ void DeleteAll(); |
+ |
+ private: |
+ bool CreateTableIfNonExistent(); |
+ |
+ // Not owned by |this|. |
+ sql::Connection* db_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrecacheReferrerHostTable); |
+}; |
+ |
+} // namespace precache |
+ |
+#endif // COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_ |