| 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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ |
| 6 #define CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Must call Init() to complete construction. Although it can be created on | 60 // Must call Init() to complete construction. Although it can be created on |
| 61 // any thread, it must be destructed on the history thread for proper | 61 // any thread, it must be destructed on the history thread for proper |
| 62 // database cleanup. | 62 // database cleanup. |
| 63 HistoryDatabase(); | 63 HistoryDatabase(); |
| 64 | 64 |
| 65 virtual ~HistoryDatabase(); | 65 virtual ~HistoryDatabase(); |
| 66 | 66 |
| 67 // Must call this function to complete initialization. Will return true on | 67 // Must call this function to complete initialization. Will return true on |
| 68 // success. On false, no other function should be called. You may want to call | 68 // success. On false, no other function should be called. You may want to call |
| 69 // BeginExclusiveMode after this when you are ready. | 69 // BeginExclusiveMode after this when you are ready. |
| 70 sql::InitStatus Init(const FilePath& history_name, | 70 sql::InitStatus Init(const FilePath& history_name); |
| 71 const FilePath& tmp_bookmarks_path); | |
| 72 | 71 |
| 73 // Call to set the mode on the database to exclusive. The default locking mode | 72 // Call to set the mode on the database to exclusive. The default locking mode |
| 74 // is "normal" but we want to run in exclusive mode for slightly better | 73 // is "normal" but we want to run in exclusive mode for slightly better |
| 75 // performance since we know nobody else is using the database. This is | 74 // performance since we know nobody else is using the database. This is |
| 76 // separate from Init() since the in-memory database attaches to slurp the | 75 // separate from Init() since the in-memory database attaches to slurp the |
| 77 // data out, and this can't happen in exclusive mode. | 76 // data out, and this can't happen in exclusive mode. |
| 78 void BeginExclusiveMode(); | 77 void BeginExclusiveMode(); |
| 79 | 78 |
| 80 // Returns the current version that we will generate history databases with. | 79 // Returns the current version that we will generate history databases with. |
| 81 static int GetCurrentVersion(); | 80 static int GetCurrentVersion(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 165 |
| 167 // Migration ----------------------------------------------------------------- | 166 // Migration ----------------------------------------------------------------- |
| 168 | 167 |
| 169 // Makes sure the version is up-to-date, updating if necessary. If the | 168 // Makes sure the version is up-to-date, updating if necessary. If the |
| 170 // database is too old to migrate, the user will be notified. In this case, or | 169 // database is too old to migrate, the user will be notified. In this case, or |
| 171 // for other errors, false will be returned. True means it is up-to-date and | 170 // for other errors, false will be returned. True means it is up-to-date and |
| 172 // ready for use. | 171 // ready for use. |
| 173 // | 172 // |
| 174 // This assumes it is called from the init function inside a transaction. It | 173 // This assumes it is called from the init function inside a transaction. It |
| 175 // may commit the transaction and start a new one if migration requires it. | 174 // may commit the transaction and start a new one if migration requires it. |
| 176 sql::InitStatus EnsureCurrentVersion(const FilePath& tmp_bookmarks_path); | 175 sql::InitStatus EnsureCurrentVersion(); |
| 177 | 176 |
| 178 #if !defined(OS_WIN) | 177 #if !defined(OS_WIN) |
| 179 // Converts the time epoch in the database from being 1970-based to being | 178 // Converts the time epoch in the database from being 1970-based to being |
| 180 // 1601-based which corresponds to the change in Time.internal_value_. | 179 // 1601-based which corresponds to the change in Time.internal_value_. |
| 181 void MigrateTimeEpoch(); | 180 void MigrateTimeEpoch(); |
| 182 #endif | 181 #endif |
| 183 | 182 |
| 184 // --------------------------------------------------------------------------- | 183 // --------------------------------------------------------------------------- |
| 185 | 184 |
| 186 sql::Connection db_; | 185 sql::Connection db_; |
| 187 sql::MetaTable meta_table_; | 186 sql::MetaTable meta_table_; |
| 188 | 187 |
| 189 base::Time cached_early_expiration_threshold_; | 188 base::Time cached_early_expiration_threshold_; |
| 190 | 189 |
| 191 // See the getters above. | 190 // See the getters above. |
| 192 bool needs_version_17_migration_; | 191 bool needs_version_17_migration_; |
| 193 | 192 |
| 194 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); | 193 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); |
| 195 }; | 194 }; |
| 196 | 195 |
| 197 } // namespace history | 196 } // namespace history |
| 198 | 197 |
| 199 #endif // CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ | 198 #endif // CHROME_BROWSER_HISTORY_HISTORY_DATABASE_H_ |
| OLD | NEW |