| Index: components/history/core/browser/url_database.cc
|
| diff --git a/components/history/core/browser/url_database.cc b/components/history/core/browser/url_database.cc
|
| index 37d2830b4a9f28e50d7056fedba6c94190764463..525b12f6124ceae7411e4177386d8fe33fa52295 100644
|
| --- a/components/history/core/browser/url_database.cc
|
| +++ b/components/history/core/browser/url_database.cc
|
| @@ -568,26 +568,7 @@ bool URLDatabase::DropStarredIDFromURLs() {
|
| if (!GetDB().DoesColumnExist("urls", "starred_id"))
|
| return true; // urls is already updated, no need to continue.
|
|
|
| - // Create a temporary table to contain the new URLs table.
|
| - if (!CreateTemporaryURLTable()) {
|
| - NOTREACHED();
|
| - return false;
|
| - }
|
| -
|
| - // Copy the contents.
|
| - if (!GetDB().Execute(
|
| - "INSERT INTO temp_urls (id, url, title, visit_count, typed_count, "
|
| - "last_visit_time, hidden, favicon_id) "
|
| - "SELECT id, url, title, visit_count, typed_count, last_visit_time, "
|
| - "hidden, favicon_id FROM urls")) {
|
| - NOTREACHED() << GetDB().GetErrorMessage();
|
| - return false;
|
| - }
|
| -
|
| - // Rename/commit the tmp table.
|
| - CommitTemporaryURLTable();
|
| -
|
| - return true;
|
| + return RecreateURLTableWithAllContents();
|
| }
|
|
|
| bool URLDatabase::CreateURLTable(bool is_temporary) {
|
| @@ -600,15 +581,16 @@ bool URLDatabase::CreateURLTable(bool is_temporary) {
|
| std::string sql;
|
| sql.append("CREATE TABLE ");
|
| sql.append(name);
|
| - sql.append("("
|
| - "id INTEGER PRIMARY KEY,"
|
| + sql.append(
|
| + "("
|
| + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
|
| "url LONGVARCHAR,"
|
| "title LONGVARCHAR,"
|
| "visit_count INTEGER DEFAULT 0 NOT NULL,"
|
| "typed_count INTEGER DEFAULT 0 NOT NULL,"
|
| "last_visit_time INTEGER NOT NULL,"
|
| "hidden INTEGER DEFAULT 0 NOT NULL,"
|
| - "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now.
|
| + "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now.
|
|
|
| return GetDB().Execute(sql.c_str());
|
| }
|
| @@ -618,6 +600,29 @@ bool URLDatabase::CreateMainURLIndex() {
|
| "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
|
| }
|
|
|
| +bool URLDatabase::RecreateURLTableWithAllContents() {
|
| + // Create a temporary table to contain the new URLs table.
|
| + if (!CreateTemporaryURLTable()) {
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + // Copy the contents.
|
| + if (!GetDB().Execute(
|
| + "INSERT INTO temp_urls (id, url, title, visit_count, typed_count, "
|
| + "last_visit_time, hidden, favicon_id) "
|
| + "SELECT id, url, title, visit_count, typed_count, last_visit_time, "
|
| + "hidden, favicon_id FROM urls")) {
|
| + NOTREACHED() << GetDB().GetErrorMessage();
|
| + return false;
|
| + }
|
| +
|
| + // Rename/commit the tmp table.
|
| + CommitTemporaryURLTable();
|
| +
|
| + return true;
|
| +}
|
| +
|
| const int kLowQualityMatchTypedLimit = 1;
|
| const int kLowQualityMatchVisitLimit = 4;
|
| const int kLowQualityMatchAgeLimitInDays = 3;
|
|
|