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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // | 220 // |
221 // TODO(engedy): The following is not true any longer. Revise this part. | |
221 // Note that the main database overrides this to additionally create the | 222 // Note that the main database overrides this to additionally create the |
222 // supplimentary indices that the archived database doesn't need. | 223 // supplimentary indices that the archived database doesn't need. |
223 | 224 |
224 // Swap the url table out and replace it with the temporary one. | 225 // Swap the url table out and replace it with the temporary one. |
225 if (!GetDB().Execute("DROP TABLE urls")) { | 226 if (!GetDB().Execute("DROP TABLE urls")) { |
226 NOTREACHED() << GetDB().GetErrorMessage(); | 227 NOTREACHED() << GetDB().GetErrorMessage(); |
227 return false; | 228 return false; |
228 } | 229 } |
229 if (!GetDB().Execute("ALTER TABLE temp_urls RENAME TO urls")) { | 230 if (!GetDB().Execute("ALTER TABLE temp_urls RENAME TO urls")) { |
230 NOTREACHED() << GetDB().GetErrorMessage(); | 231 NOTREACHED() << GetDB().GetErrorMessage(); |
231 return false; | 232 return false; |
232 } | 233 } |
233 | 234 |
234 // Create the index over URLs. This is needed for the main, in-memory, and | 235 // Create the index over URLs. This is currently needed for both the main and |
235 // archived databases, so we always do it. The supplimentary indices used by | 236 // the in-memory databases, so we always do it. |
236 // the main database are not created here. When deleting all history, they | |
237 // are created by HistoryDatabase::RecreateAllButStarAndURLTables(). | |
engedy
2014/04/16 18:08:10
Note: Removing this as there is no CreateSupplimen
| |
238 CreateMainURLIndex(); | 237 CreateMainURLIndex(); |
239 | 238 |
240 return true; | 239 return true; |
241 } | 240 } |
242 | 241 |
243 bool URLDatabase::InitURLEnumeratorForEverything(URLEnumerator* enumerator) { | 242 bool URLDatabase::InitURLEnumeratorForEverything(URLEnumerator* enumerator) { |
244 DCHECK(!enumerator->initialized_); | 243 DCHECK(!enumerator->initialized_); |
245 std::string sql("SELECT "); | 244 std::string sql("SELECT "); |
246 sql.append(kURLRowFields); | 245 sql.append(kURLRowFields); |
247 sql.append(" FROM urls"); | 246 sql.append(" FROM urls"); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 return GetDB().Execute(sql.c_str()); | 615 return GetDB().Execute(sql.c_str()); |
617 } | 616 } |
618 | 617 |
619 bool URLDatabase::CreateMainURLIndex() { | 618 bool URLDatabase::CreateMainURLIndex() { |
620 // Index over URLs so we can quickly look up based on URL. | 619 // Index over URLs so we can quickly look up based on URL. |
621 return GetDB().Execute( | 620 return GetDB().Execute( |
622 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); | 621 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
623 } | 622 } |
624 | 623 |
625 } // namespace history | 624 } // namespace history |
OLD | NEW |