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

Side by Side Diff: components/precache/core/precache_url_table.cc

Issue 2300703004: Fix precache issue with cancel and resume (Closed)
Patch Set: 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/precache/core/precache_url_table.h" 5 #include "components/precache/core/precache_url_table.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "sql/connection.h" 10 #include "sql/connection.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 while (statement.Step()) { 101 while (statement.Step()) {
102 GURL url(statement.ColumnString(0)); 102 GURL url(statement.ColumnString(0));
103 if (statement.ColumnInt(1)) 103 if (statement.ColumnInt(1))
104 used_urls->push_back(url); 104 used_urls->push_back(url);
105 else 105 else
106 unused_urls->push_back(url); 106 unused_urls->push_back(url);
107 } 107 }
108 } 108 }
109 109
110 void PrecacheURLTable::ClearAllForReferrerHost(int64_t referrer_host_id) { 110 void PrecacheURLTable::ClearAllForReferrerHost(int64_t referrer_host_id) {
111 Statement statement(db_->GetCachedStatement( 111 // Delete the URLs that are not precached.
112 Statement delete_statement(
sclittle 2016/09/02 18:47:56 Should a test be added for this new functionality?
Raj 2016/09/15 17:02:25 Done.
113 db_->GetCachedStatement(SQL_FROM_HERE,
114 "DELETE FROM precache_urls WHERE "
115 "referrer_host_id=? AND is_precached=0"));
116 delete_statement.BindInt64(0, referrer_host_id);
117 delete_statement.Run();
118
119 // Clear was_used for precached URLs.
120 Statement update_statement(db_->GetCachedStatement(
112 SQL_FROM_HERE, 121 SQL_FROM_HERE,
113 "UPDATE precache_urls SET was_used=0 WHERE referrer_host_id=?")); 122 "UPDATE precache_urls SET was_used=0 WHERE referrer_host_id=?"));
114 123 update_statement.BindInt64(0, referrer_host_id);
115 statement.BindInt64(0, referrer_host_id); 124 update_statement.Run();
116 statement.Run();
117 } 125 }
118 126
119 void PrecacheURLTable::DeleteAllPrecachedBefore(const base::Time& delete_end) { 127 void PrecacheURLTable::DeleteAllPrecachedBefore(const base::Time& delete_end) {
120 Statement statement(db_->GetCachedStatement( 128 Statement statement(db_->GetCachedStatement(
121 SQL_FROM_HERE, "DELETE FROM precache_urls WHERE time < ?")); 129 SQL_FROM_HERE, "DELETE FROM precache_urls WHERE time < ?"));
122 130
123 statement.BindInt64(0, delete_end.ToInternalValue()); 131 statement.BindInt64(0, delete_end.ToInternalValue());
124 statement.Run(); 132 statement.Run();
125 } 133 }
126 134
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 return false; 170 return false;
163 if (!db_->DoesColumnExist("precache_urls", "referrer_host_id") && 171 if (!db_->DoesColumnExist("precache_urls", "referrer_host_id") &&
164 !db_->Execute( 172 !db_->Execute(
165 "ALTER TABLE precache_urls ADD COLUMN referrer_host_id INTEGER")) 173 "ALTER TABLE precache_urls ADD COLUMN referrer_host_id INTEGER"))
166 return false; 174 return false;
167 } 175 }
168 return true; 176 return true;
169 } 177 }
170 178
171 } // namespace precache 179 } // namespace precache
OLDNEW
« components/precache/core/precache_fetcher.cc ('K') | « components/precache/core/precache_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698