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

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 nits Created 4 years, 3 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() : id(kInvalidId) {}
26 PrecacheReferrerHostEntry(int64_t id,
27 const std::string& referrer_host,
28 int64_t manifest_id,
29 const base::Time& time)
30 : id(id),
31 referrer_host(referrer_host),
32 manifest_id(manifest_id),
33 time(time) {}
34
35 // Comparison for testing.
36 bool operator==(const PrecacheReferrerHostEntry& entry) const;
37
38 int64_t id;
39 std::string referrer_host;
40 int64_t manifest_id;
41 base::Time time;
42 };
43
44 class PrecacheReferrerHostTable {
45 public:
46 PrecacheReferrerHostTable();
47 ~PrecacheReferrerHostTable();
48
49 // Initialize the precache referrer host table for use with the specified
50 // database connection. The caller keeps ownership of |db|, and |db| must not
51 // be NULL. Init must be called before any other methods.
52 bool Init(sql::Connection* db);
53
54 // Returns the referrer host information about |referrer_host|.
55 PrecacheReferrerHostEntry GetReferrerHost(const std::string& referrer_host);
56
57 // Updates the referrer host information about |referrer_host|.
58 int64_t UpdateReferrerHost(const std::string& referrer_host,
59 int64_t manifest_id,
60 const base::Time& time);
61
62 // Deletes entries that were created before the time of |delete_end|.
63 void DeleteAllEntriesBefore(const base::Time& delete_end);
64
65 // Delete all entries.
66 void DeleteAll();
67
68 // Used by tests to get the contents of the table.
69 std::map<std::string, PrecacheReferrerHostEntry> GetAllDataForTesting();
70
71 private:
72 bool CreateTableIfNonExistent();
73
74 // Not owned by |this|.
75 sql::Connection* db_;
76
77 DISALLOW_COPY_AND_ASSIGN(PrecacheReferrerHostTable);
78 };
79
80 } // namespace precache
81
82 #endif // COMPONENTS_PRECACHE_CORE_PRECACHE_REFERRER_HOST_TABLE_H_
OLDNEW
« no previous file with comments | « components/precache/core/precache_fetcher_unittest.cc ('k') | components/precache/core/precache_referrer_host_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698