OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/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 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
17 #include "chrome/browser/history/history_field_trial.h" | |
18 #include "chrome/browser/history/starred_url_database.h" | 17 #include "chrome/browser/history/starred_url_database.h" |
19 #include "sql/transaction.h" | 18 #include "sql/transaction.h" |
20 | 19 |
21 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
22 #include "base/mac/mac_util.h" | 21 #include "base/mac/mac_util.h" |
23 #endif | 22 #endif |
24 | 23 |
25 namespace history { | 24 namespace history { |
26 | 25 |
27 namespace { | 26 namespace { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const FilePath& bookmarks_path) { | 72 const FilePath& bookmarks_path) { |
74 // Set the exceptional sqlite error handler. | 73 // Set the exceptional sqlite error handler. |
75 db_.set_error_delegate(GetErrorHandlerForHistoryDb()); | 74 db_.set_error_delegate(GetErrorHandlerForHistoryDb()); |
76 | 75 |
77 // Set the database page size to something a little larger to give us | 76 // Set the database page size to something a little larger to give us |
78 // better performance (we're typically seek rather than bandwidth limited). | 77 // better performance (we're typically seek rather than bandwidth limited). |
79 // This only has an effect before any tables have been created, otherwise | 78 // This only has an effect before any tables have been created, otherwise |
80 // this is a NOP. Must be a power of 2 and a max of 8192. | 79 // this is a NOP. Must be a power of 2 and a max of 8192. |
81 db_.set_page_size(4096); | 80 db_.set_page_size(4096); |
82 | 81 |
83 if (HistoryFieldTrial::IsLowMemFieldTrial()) { | 82 // Increase the cache size. The page size, plus a little extra, times this |
84 db_.set_cache_size(500); | 83 // value, tells us how much memory the cache will use maximum. |
85 } else { | 84 // 6000 * 4MB = 24MB |
86 // Increase the cache size. The page size, plus a little extra, times this | 85 // TODO(brettw) scale this value to the amount of available memory. |
87 // value, tells us how much memory the cache will use maximum. | 86 db_.set_cache_size(6000); |
88 // 6000 * 4MB = 24MB | |
89 // TODO(brettw) scale this value to the amount of available memory. | |
90 db_.set_cache_size(6000); | |
91 } | |
92 | 87 |
93 // Note that we don't set exclusive locking here. That's done by | 88 // Note that we don't set exclusive locking here. That's done by |
94 // BeginExclusiveMode below which is called later (we have to be in shared | 89 // BeginExclusiveMode below which is called later (we have to be in shared |
95 // mode to start out for the in-memory backend to read the data). | 90 // mode to start out for the in-memory backend to read the data). |
96 | 91 |
97 if (!db_.Open(history_name)) | 92 if (!db_.Open(history_name)) |
98 return sql::INIT_FAILURE; | 93 return sql::INIT_FAILURE; |
99 | 94 |
100 // Wrap the rest of init in a tranaction. This will prevent the database from | 95 // Wrap the rest of init in a tranaction. This will prevent the database from |
101 // getting corrupted if we crash in the middle of initialization or migration. | 96 // getting corrupted if we crash in the middle of initialization or migration. |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); | 337 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"); |
343 | 338 |
344 // Erase all the full text index files. These will take a while to update and | 339 // Erase all the full text index files. These will take a while to update and |
345 // are less important, so we just blow them away. Same with the archived | 340 // are less important, so we just blow them away. Same with the archived |
346 // database. | 341 // database. |
347 needs_version_17_migration_ = true; | 342 needs_version_17_migration_ = true; |
348 } | 343 } |
349 #endif | 344 #endif |
350 | 345 |
351 } // namespace history | 346 } // namespace history |
OLD | NEW |