Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: components/precache/core/precache_referrer_host_table.h

Issue 2229983002: Send the list of used and unused resources for precache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <stdint.h>
9
10 #include <map>
11 #include <string>
12
13 #include "base/macros.h"
14 #include "base/time/time.h"
15
16 namespace sql {
17 class Connection;
18 }
19
20 namespace precache {
21
22 struct PrecacheReferrerHostEntry {
23 static const int64_t kInvalidId;
24
25 PrecacheReferrerHostEntry(int64_t id,
26 const std::string& referrer_host,
27 int64_t manifest_id,
28 const base::Time& time)
29 : id(id),
30 referrer_host(referrer_host),
31 manifest_id(manifest_id),
32 time(time) {}
33
34 // Comparison for testing.
35 bool operator==(const PrecacheReferrerHostEntry& entry) const;
36
37 int64_t id;
38 std::string referrer_host;
39 int64_t manifest_id;
40 base::Time time;
41 };
42
43 class PrecacheReferrerHostTable {
44 public:
45 PrecacheReferrerHostTable();
46 ~PrecacheReferrerHostTable();
47
48 // Initialize the precache referrer host table for use with the specified
49 // database connection. The caller keeps ownership of |db|, and |db| must not
50 // be NULL. Init must be called before any other methods.
51 bool Init(sql::Connection* db);
52
53 // Returns the referrer host information about |referrer_host|.
54 PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host);
55
56 // Updates the referrer host information about |referrer_host|.
57 int64_t UpdateReferrerHost(const std::string& referrer_host,
58 int64_t manifest_id,
59 const base::Time& time);
60
61 // Deletes entries that were created before the time of |delete_end|.
62 void DeleteAllEntriesBefore(const base::Time& delete_end);
63
64 // Delete all entries.
65 void DeleteAll();
66
67 // Used by tests to get the contents of the table.
68 std::map<std::string, PrecacheReferrerHostEntry> GetAllDataForTesting();
69
70 private:
71 bool CreateTableIfNonExistent();
72
73 // Not owned by |this|.
74 sql::Connection* db_;
75
76 DISALLOW_COPY_AND_ASSIGN(PrecacheReferrerHostTable);
77 };
78
79 } // namespace precache
80
81 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698