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

Unified Diff: components/precache/core/precache_url_table.cc

Issue 2364873004: Add Precache.CacheStatus.NonPrefetch.FromPrecache. (Closed)
Patch Set: Add const. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/precache/core/precache_url_table.cc
diff --git a/components/precache/core/precache_url_table.cc b/components/precache/core/precache_url_table.cc
index 2fd5f42e5bb17fe14fb25b76aede5f860df0d83c..830ef892af927bcbf56df86d37c10375d44827d0 100644
--- a/components/precache/core/precache_url_table.cc
+++ b/components/precache/core/precache_url_table.cc
@@ -23,6 +23,11 @@ std::string GetKey(const GURL& url) {
namespace precache {
+bool PrecacheURLInfo::operator==(const PrecacheURLInfo& other) const {
+ return was_precached == other.was_precached &&
+ is_precached == other.is_precached && was_used == other.was_used;
+}
+
PrecacheURLTable::PrecacheURLTable() : db_(NULL) {}
PrecacheURLTable::~PrecacheURLTable() {}
@@ -51,23 +56,18 @@ void PrecacheURLTable::AddURL(const GURL& url,
statement.Run();
}
-bool PrecacheURLTable::IsURLPrecached(const GURL& url) {
+PrecacheURLInfo PrecacheURLTable::GetURLInfo(const GURL& url) {
Statement statement(db_->GetCachedStatement(
SQL_FROM_HERE,
- "SELECT time FROM precache_urls WHERE url=? and is_precached=1"));
-
+ "SELECT is_precached, was_used FROM precache_urls WHERE url=?"));
statement.BindString(0, GetKey(url));
- return statement.Step();
-}
-bool PrecacheURLTable::IsURLPrecachedAndUnused(const GURL& url) {
- Statement statement(db_->GetCachedStatement(SQL_FROM_HERE,
- "SELECT time FROM precache_urls "
- "WHERE url=? and is_precached=1 "
- "and was_used=0"));
-
- statement.BindString(0, GetKey(url));
- return statement.Step();
+ if (statement.Step()) {
+ return {/*present=*/true, /*is_precached=*/statement.ColumnBool(0),
+ /*was_used==*/statement.ColumnBool(1)};
+ } else {
+ return {/*present=*/false, /*is_precached=*/false, /*was_used=*/false};
+ }
}
void PrecacheURLTable::SetPrecachedURLAsUsed(const GURL& url) {
« no previous file with comments | « components/precache/core/precache_url_table.h ('k') | components/precache/core/precache_url_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698