OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_ | |
6 #define COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
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 struct PrecacheReferrerHostEntry { | |
21 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.
| |
22 | |
23 PrecacheReferrerHostEntry(int64_t id, | |
24 const GURL& referrer_host, | |
25 int64_t manifest_id, | |
26 const base::Time& time) | |
27 : id(id), | |
28 referrer_host(referrer_host), | |
29 manifest_id(manifest_id), | |
30 time(time) {} | |
31 | |
32 const int64_t id; | |
bengr
2016/08/11 18:49:15
#include <stdint.h>
Raj
2016/08/12 19:04:21
Done.
| |
33 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.
| |
34 const int64_t manifest_id; | |
35 const base::Time time; | |
36 }; | |
37 | |
38 class PrecacheReferrerHostTable { | |
39 public: | |
40 PrecacheReferrerHostTable(); | |
41 ~PrecacheReferrerHostTable(); | |
42 | |
43 // Initialize the precache referrer host table for use with the specified | |
44 // database connection. The caller keeps ownership of |db|, and |db| must not | |
45 // be NULL. Init must be called before any other methods. | |
46 bool Init(sql::Connection* db); | |
47 | |
48 // Returns the referrer host information about |referrer_host|. | |
49 PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host); | |
50 | |
51 // Updates the referrer host information about |referrer_host|. | |
52 int64_t UpdateReferrerHost(const std::string& referrer_host, | |
53 int64_t manifest_id, | |
54 const base::Time& time); | |
55 | |
56 // Deletes entries that were created before the time of |delete_end|. | |
57 void DeleteAllEntriesBefore(const base::Time& delete_end); | |
58 | |
59 // Delete all entries. | |
60 void DeleteAll(); | |
61 | |
62 private: | |
63 bool CreateTableIfNonExistent(); | |
64 | |
65 // Not owned by |this|. | |
66 sql::Connection* db_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(PrecacheReferrerHostTable); | |
69 }; | |
70 | |
71 } // namespace precache | |
72 | |
73 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_ | |
OLD | NEW |