OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/history_database.h" | 5 #include "chrome/browser/history/history_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "app/sql/transaction.h" | 11 #include "app/sql/transaction.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/histogram.h" | 13 #include "base/histogram.h" |
14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
16 | 17 |
17 namespace history { | 18 namespace history { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Current version number. We write databases at the "current" version number, | 22 // Current version number. We write databases at the "current" version number, |
22 // but any previous version that can read the "compatible" one can make do with | 23 // but any previous version that can read the "compatible" one can make do with |
23 // or database without *too* many bad effects. | 24 // or database without *too* many bad effects. |
24 static const int kCurrentVersionNumber = 17; | 25 static const int kCurrentVersionNumber = 17; |
25 static const int kCompatibleVersionNumber = 16; | 26 static const int kCompatibleVersionNumber = 16; |
(...skipping 26 matching lines...) Expand all Loading... |
52 | 53 |
53 HistoryDatabase::HistoryDatabase() | 54 HistoryDatabase::HistoryDatabase() |
54 : needs_version_17_migration_(false) { | 55 : needs_version_17_migration_(false) { |
55 } | 56 } |
56 | 57 |
57 HistoryDatabase::~HistoryDatabase() { | 58 HistoryDatabase::~HistoryDatabase() { |
58 } | 59 } |
59 | 60 |
60 InitStatus HistoryDatabase::Init(const FilePath& history_name, | 61 InitStatus HistoryDatabase::Init(const FilePath& history_name, |
61 const FilePath& bookmarks_path) { | 62 const FilePath& bookmarks_path) { |
| 63 // Set the exceptional sqlite error handler. |
| 64 db_.set_error_delegate(GetErrorHandlerForHistoryDb()); |
| 65 |
62 // Set the database page size to something a little larger to give us | 66 // Set the database page size to something a little larger to give us |
63 // better performance (we're typically seek rather than bandwidth limited). | 67 // better performance (we're typically seek rather than bandwidth limited). |
64 // This only has an effect before any tables have been created, otherwise | 68 // This only has an effect before any tables have been created, otherwise |
65 // this is a NOP. Must be a power of 2 and a max of 8192. | 69 // this is a NOP. Must be a power of 2 and a max of 8192. |
66 db_.set_page_size(4096); | 70 db_.set_page_size(4096); |
67 | 71 |
68 // Increase the cache size. The page size, plus a little extra, times this | 72 // Increase the cache size. The page size, plus a little extra, times this |
69 // value, tells us how much memory the cache will use maximum. | 73 // value, tells us how much memory the cache will use maximum. |
70 // 6000 * 4MB = 24MB | 74 // 6000 * 4MB = 24MB |
71 // TODO(brettw) scale this value to the amount of available memory. | 75 // TODO(brettw) scale this value to the amount of available memory. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); | 289 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); |
286 | 290 |
287 // Erase all the full text index files. These will take a while to update and | 291 // Erase all the full text index files. These will take a while to update and |
288 // are less important, so we just blow them away. Same with the archived | 292 // are less important, so we just blow them away. Same with the archived |
289 // database. | 293 // database. |
290 needs_version_17_migration_ = true; | 294 needs_version_17_migration_ = true; |
291 } | 295 } |
292 #endif | 296 #endif |
293 | 297 |
294 } // namespace history | 298 } // namespace history |
OLD | NEW |