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

Unified Diff: chrome/browser/history/text_database.cc

Issue 9071014: Database usage adjustment for .../history (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify SQL Created 8 years, 11 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
« no previous file with comments | « chrome/browser/history/starred_url_database.cc ('k') | chrome/browser/history/thumbnail_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/text_database.cc
diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc
index 310f52b2af76374c86a102233bba19143f66c9c0..3f0e176c73a0411da6cf3a71fab09c3170bf4a3e 100644
--- a/chrome/browser/history/text_database.cc
+++ b/chrome/browser/history/text_database.cc
@@ -216,33 +216,22 @@ bool TextDatabase::AddPageData(base::Time time,
// Add to the pages table.
sql::Statement add_to_pages(db_.GetCachedStatement(SQL_FROM_HERE,
"INSERT INTO pages (url, title, body) VALUES (?,?,?)"));
- if (!add_to_pages) {
- NOTREACHED() << db_.GetErrorMessage();
- return false;
- }
add_to_pages.BindString(0, url);
add_to_pages.BindString(1, title);
add_to_pages.BindString(2, contents);
- if (!add_to_pages.Run()) {
- NOTREACHED() << db_.GetErrorMessage();
+ if (!add_to_pages.Run())
return false;
- }
int64 rowid = db_.GetLastInsertRowId();
// Add to the info table with the same rowid.
sql::Statement add_to_info(db_.GetCachedStatement(SQL_FROM_HERE,
"INSERT INTO info (rowid, time) VALUES (?,?)"));
- if (!add_to_info) {
- NOTREACHED() << db_.GetErrorMessage();
- return false;
- }
add_to_info.BindInt64(0, rowid);
add_to_info.BindInt64(1, time.ToInternalValue());
- if (!add_to_info.Run()) {
- NOTREACHED() << db_.GetErrorMessage();
+
+ if (!add_to_info.Run())
return false;
- }
return committer.Commit();
}
@@ -255,10 +244,9 @@ void TextDatabase::DeletePageData(base::Time time, const std::string& url) {
"SELECT info.rowid "
"FROM info JOIN pages ON info.rowid = pages.rowid "
"WHERE info.time=? AND pages.url=?"));
- if (!select_ids)
- return;
select_ids.BindInt64(0, time.ToInternalValue());
select_ids.BindString(1, url);
+
std::set<int64> rows_to_delete;
while (select_ids.Step())
rows_to_delete.insert(select_ids.ColumnInt64(0));
@@ -266,30 +254,24 @@ void TextDatabase::DeletePageData(base::Time time, const std::string& url) {
// Delete from the pages table.
sql::Statement delete_page(db_.GetCachedStatement(SQL_FROM_HERE,
"DELETE FROM pages WHERE rowid=?"));
- if (!delete_page)
- return;
+
for (std::set<int64>::const_iterator i = rows_to_delete.begin();
i != rows_to_delete.end(); ++i) {
delete_page.BindInt64(0, *i);
- if (!delete_page.Run()) {
- NOTREACHED();
+ if (!delete_page.Run())
return;
- }
delete_page.Reset();
}
// Delete from the info table.
sql::Statement delete_info(db_.GetCachedStatement(SQL_FROM_HERE,
"DELETE FROM info WHERE rowid=?"));
- if (!delete_info)
- return;
+
for (std::set<int64>::const_iterator i = rows_to_delete.begin();
i != rows_to_delete.end(); ++i) {
delete_info.BindInt64(0, *i);
- if (!delete_info.Run()) {
- NOTREACHED();
+ if (!delete_info.Run())
return;
- }
delete_info.Reset();
}
}
@@ -297,8 +279,6 @@ void TextDatabase::DeletePageData(base::Time time, const std::string& url) {
void TextDatabase::Optimize() {
sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
"SELECT OPTIMIZE(pages) FROM pages LIMIT 1"));
- if (!statement)
- return;
statement.Run();
}
@@ -316,8 +296,6 @@ void TextDatabase::GetTextMatches(const std::string& query,
sql += options.body_only ? "body " : "pages ";
sql += "MATCH ? AND time >= ? AND time < ? ORDER BY time DESC LIMIT ?";
sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, sql.c_str()));
- if (!statement)
- return;
// When their values indicate "unspecified", saturate the numbers to the max
// or min to get the correct result.
« no previous file with comments | « chrome/browser/history/starred_url_database.cc ('k') | chrome/browser/history/thumbnail_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698