| 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/history/url_database.h" | 5 #include "chrome/browser/history/url_database.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool URLDatabase::CreateTemporaryURLTable() { | 212 bool URLDatabase::CreateTemporaryURLTable() { |
| 213 return CreateURLTable(true); | 213 return CreateURLTable(true); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool URLDatabase::CommitTemporaryURLTable() { | 216 bool URLDatabase::CommitTemporaryURLTable() { |
| 217 // See the comments in the header file as well as | 217 // See the comments in the header file as well as |
| 218 // HistoryBackend::DeleteAllHistory() for more information on how this works | 218 // HistoryBackend::DeleteAllHistory() for more information on how this works |
| 219 // and why it does what it does. | 219 // and why it does what it does. |
| 220 // | |
| 221 // Note that the main database overrides this to additionally create the | |
| 222 // supplimentary indices that the archived database doesn't need. | |
| 223 | 220 |
| 224 // Swap the url table out and replace it with the temporary one. | 221 // Swap the url table out and replace it with the temporary one. |
| 225 if (!GetDB().Execute("DROP TABLE urls")) { | 222 if (!GetDB().Execute("DROP TABLE urls")) { |
| 226 NOTREACHED() << GetDB().GetErrorMessage(); | 223 NOTREACHED() << GetDB().GetErrorMessage(); |
| 227 return false; | 224 return false; |
| 228 } | 225 } |
| 229 if (!GetDB().Execute("ALTER TABLE temp_urls RENAME TO urls")) { | 226 if (!GetDB().Execute("ALTER TABLE temp_urls RENAME TO urls")) { |
| 230 NOTREACHED() << GetDB().GetErrorMessage(); | 227 NOTREACHED() << GetDB().GetErrorMessage(); |
| 231 return false; | 228 return false; |
| 232 } | 229 } |
| 233 | 230 |
| 234 // Create the index over URLs. This is needed for the main, in-memory, and | 231 // Re-create the index over the now permanent URLs table -- this was not there |
| 235 // archived databases, so we always do it. The supplimentary indices used by | 232 // for the temporary table. |
| 236 // the main database are not created here. When deleting all history, they | |
| 237 // are created by HistoryDatabase::RecreateAllButStarAndURLTables(). | |
| 238 CreateMainURLIndex(); | 233 CreateMainURLIndex(); |
| 239 | 234 |
| 240 return true; | 235 return true; |
| 241 } | 236 } |
| 242 | 237 |
| 243 bool URLDatabase::InitURLEnumeratorForEverything(URLEnumerator* enumerator) { | 238 bool URLDatabase::InitURLEnumeratorForEverything(URLEnumerator* enumerator) { |
| 244 DCHECK(!enumerator->initialized_); | 239 DCHECK(!enumerator->initialized_); |
| 245 std::string sql("SELECT "); | 240 std::string sql("SELECT "); |
| 246 sql.append(kURLRowFields); | 241 sql.append(kURLRowFields); |
| 247 sql.append(" FROM urls"); | 242 sql.append(" FROM urls"); |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 "visit_count INTEGER DEFAULT 0 NOT NULL," | 605 "visit_count INTEGER DEFAULT 0 NOT NULL," |
| 611 "typed_count INTEGER DEFAULT 0 NOT NULL," | 606 "typed_count INTEGER DEFAULT 0 NOT NULL," |
| 612 "last_visit_time INTEGER NOT NULL," | 607 "last_visit_time INTEGER NOT NULL," |
| 613 "hidden INTEGER DEFAULT 0 NOT NULL," | 608 "hidden INTEGER DEFAULT 0 NOT NULL," |
| 614 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. | 609 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. |
| 615 | 610 |
| 616 return GetDB().Execute(sql.c_str()); | 611 return GetDB().Execute(sql.c_str()); |
| 617 } | 612 } |
| 618 | 613 |
| 619 bool URLDatabase::CreateMainURLIndex() { | 614 bool URLDatabase::CreateMainURLIndex() { |
| 620 // Index over URLs so we can quickly look up based on URL. | |
| 621 return GetDB().Execute( | 615 return GetDB().Execute( |
| 622 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); | 616 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
| 623 } | 617 } |
| 624 | 618 |
| 625 } // namespace history | 619 } // namespace history |
| OLD | NEW |