OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/network_action_predictor_database.h" | 5 #include "chrome/browser/autocomplete/network_action_predictor_database.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 sql::Statement statement(db_.GetUniqueStatement(base::StringPrintf( | 198 sql::Statement statement(db_.GetUniqueStatement(base::StringPrintf( |
199 "DELETE FROM %s WHERE id=?", | 199 "DELETE FROM %s WHERE id=?", |
200 kNetworkActionPredictorTableName).c_str())); | 200 kNetworkActionPredictorTableName).c_str())); |
201 | 201 |
202 db_.BeginTransaction(); | 202 db_.BeginTransaction(); |
203 for (std::vector<Row::Id>::const_iterator it = id_list.begin(); | 203 for (std::vector<Row::Id>::const_iterator it = id_list.begin(); |
204 it != id_list.end(); ++it) { | 204 it != id_list.end(); ++it) { |
205 statement.BindString(0, *it); | 205 statement.BindString(0, *it); |
206 statement.Run(); | 206 statement.Run(); |
207 statement.Reset(); | 207 statement.Reset(true); |
208 } | 208 } |
209 db_.CommitTransaction(); | 209 db_.CommitTransaction(); |
210 } | 210 } |
211 | 211 |
212 void NetworkActionPredictorDatabase::DeleteAllRows() { | 212 void NetworkActionPredictorDatabase::DeleteAllRows() { |
213 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); | 213 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); |
214 | 214 |
215 if (canceled_.IsSet()) | 215 if (canceled_.IsSet()) |
216 return; | 216 return; |
217 | 217 |
(...skipping 30 matching lines...) Expand all Loading... |
248 bool success = db_.Execute(base::StringPrintf( | 248 bool success = db_.Execute(base::StringPrintf( |
249 "CREATE TABLE %s ( " | 249 "CREATE TABLE %s ( " |
250 "id TEXT PRIMARY KEY, " | 250 "id TEXT PRIMARY KEY, " |
251 "user_text TEXT, " | 251 "user_text TEXT, " |
252 "url TEXT, " | 252 "url TEXT, " |
253 "number_of_hits INTEGER, " | 253 "number_of_hits INTEGER, " |
254 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); | 254 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); |
255 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName | 255 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName |
256 << " table."; | 256 << " table."; |
257 } | 257 } |
OLD | NEW |