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 <limits> | 5 #include <limits> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "chrome/browser/history/text_database.h" | 9 #include "chrome/browser/history/text_database.h" |
10 | 10 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 // Delete from the pages table. | 254 // Delete from the pages table. |
255 sql::Statement delete_page(db_.GetCachedStatement(SQL_FROM_HERE, | 255 sql::Statement delete_page(db_.GetCachedStatement(SQL_FROM_HERE, |
256 "DELETE FROM pages WHERE rowid=?")); | 256 "DELETE FROM pages WHERE rowid=?")); |
257 | 257 |
258 for (std::set<int64>::const_iterator i = rows_to_delete.begin(); | 258 for (std::set<int64>::const_iterator i = rows_to_delete.begin(); |
259 i != rows_to_delete.end(); ++i) { | 259 i != rows_to_delete.end(); ++i) { |
260 delete_page.BindInt64(0, *i); | 260 delete_page.BindInt64(0, *i); |
261 if (!delete_page.Run()) | 261 if (!delete_page.Run()) |
262 return; | 262 return; |
263 delete_page.Reset(); | 263 delete_page.Reset(true); |
264 } | 264 } |
265 | 265 |
266 // Delete from the info table. | 266 // Delete from the info table. |
267 sql::Statement delete_info(db_.GetCachedStatement(SQL_FROM_HERE, | 267 sql::Statement delete_info(db_.GetCachedStatement(SQL_FROM_HERE, |
268 "DELETE FROM info WHERE rowid=?")); | 268 "DELETE FROM info WHERE rowid=?")); |
269 | 269 |
270 for (std::set<int64>::const_iterator i = rows_to_delete.begin(); | 270 for (std::set<int64>::const_iterator i = rows_to_delete.begin(); |
271 i != rows_to_delete.end(); ++i) { | 271 i != rows_to_delete.end(); ++i) { |
272 delete_info.BindInt64(0, *i); | 272 delete_info.BindInt64(0, *i); |
273 if (!delete_info.Run()) | 273 if (!delete_info.Run()) |
274 return; | 274 return; |
275 delete_info.Reset(); | 275 delete_info.Reset(true); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 void TextDatabase::Optimize() { | 279 void TextDatabase::Optimize() { |
280 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, | 280 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, |
281 "SELECT OPTIMIZE(pages) FROM pages LIMIT 1")); | 281 "SELECT OPTIMIZE(pages) FROM pages LIMIT 1")); |
282 statement.Run(); | 282 statement.Run(); |
283 } | 283 } |
284 | 284 |
285 void TextDatabase::GetTextMatches(const std::string& query, | 285 void TextDatabase::GetTextMatches(const std::string& query, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (results->empty() || | 352 if (results->empty() || |
353 options.max_count == 0 || // Special case for wanting all the results. | 353 options.max_count == 0 || // Special case for wanting all the results. |
354 static_cast<int>(results->size()) < options.max_count) { | 354 static_cast<int>(results->size()) < options.max_count) { |
355 *first_time_searched = options.begin_time; | 355 *first_time_searched = options.begin_time; |
356 } else { | 356 } else { |
357 // Since we got the results in order, we know the last item is the last | 357 // Since we got the results in order, we know the last item is the last |
358 // time we considered. | 358 // time we considered. |
359 *first_time_searched = results->back().time; | 359 *first_time_searched = results->back().time; |
360 } | 360 } |
361 | 361 |
362 statement.Reset(); | 362 statement.Reset(true); |
363 } | 363 } |
364 | 364 |
365 } // namespace history | 365 } // namespace history |
OLD | NEW |