| 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 COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // database cleanup. | 68 // database cleanup. |
| 69 HistoryDatabase(DownloadInterruptReason download_interrupt_reason_none, | 69 HistoryDatabase(DownloadInterruptReason download_interrupt_reason_none, |
| 70 DownloadInterruptReason download_interrupt_reason_crash); | 70 DownloadInterruptReason download_interrupt_reason_crash); |
| 71 | 71 |
| 72 ~HistoryDatabase() override; | 72 ~HistoryDatabase() override; |
| 73 | 73 |
| 74 // Call before Init() to set the error callback to be used for the | 74 // Call before Init() to set the error callback to be used for the |
| 75 // underlying database connection. | 75 // underlying database connection. |
| 76 void set_error_callback( | 76 void set_error_callback( |
| 77 const sql::Connection::ErrorCallback& error_callback) { | 77 const sql::Connection::ErrorCallback& error_callback) { |
| 78 error_callback_ = error_callback; | 78 db_.set_error_callback(error_callback); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Must call this function to complete initialization. Will return | 81 // Must call this function to complete initialization. Will return |
| 82 // sql::INIT_OK on success. Otherwise, no other function should be called. You | 82 // sql::INIT_OK on success. Otherwise, no other function should be called. You |
| 83 // may want to call BeginExclusiveMode after this when you are ready. | 83 // may want to call BeginExclusiveMode after this when you are ready. |
| 84 sql::InitStatus Init(const base::FilePath& history_name); | 84 sql::InitStatus Init(const base::FilePath& history_name); |
| 85 | 85 |
| 86 // Computes and records various metrics for the database. Should only be | 86 // Computes and records various metrics for the database. Should only be |
| 87 // called once and only upon successful Init. | 87 // called once and only upon successful Init. |
| 88 void ComputeDatabaseMetrics(const base::FilePath& filename); | 88 void ComputeDatabaseMetrics(const base::FilePath& filename); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // unused space in the file. It can be VERY SLOW. | 138 // unused space in the file. It can be VERY SLOW. |
| 139 void Vacuum(); | 139 void Vacuum(); |
| 140 | 140 |
| 141 // Try to trim the cache memory used by the database. If |aggressively| is | 141 // Try to trim the cache memory used by the database. If |aggressively| is |
| 142 // true try to trim all unused cache, otherwise trim by half. | 142 // true try to trim all unused cache, otherwise trim by half. |
| 143 void TrimMemory(bool aggressively); | 143 void TrimMemory(bool aggressively); |
| 144 | 144 |
| 145 // Razes the database. Returns true if successful. | 145 // Razes the database. Returns true if successful. |
| 146 bool Raze(); | 146 bool Raze(); |
| 147 | 147 |
| 148 std::string GetDiagnosticInfo(int extended_error, sql::Statement* statement); |
| 149 |
| 148 // Visit table functions ---------------------------------------------------- | 150 // Visit table functions ---------------------------------------------------- |
| 149 | 151 |
| 150 // Update the segment id of a visit. Return true on success. | 152 // Update the segment id of a visit. Return true on success. |
| 151 bool SetSegmentID(VisitID visit_id, SegmentID segment_id); | 153 bool SetSegmentID(VisitID visit_id, SegmentID segment_id); |
| 152 | 154 |
| 153 // Query the segment ID for the provided visit. Return 0 on failure or if the | 155 // Query the segment ID for the provided visit. Return 0 on failure or if the |
| 154 // visit id wasn't found. | 156 // visit id wasn't found. |
| 155 SegmentID GetSegmentID(VisitID visit_id); | 157 SegmentID GetSegmentID(VisitID visit_id); |
| 156 | 158 |
| 157 // Retrieves/Updates early expiration threshold, which specifies the earliest | 159 // Retrieves/Updates early expiration threshold, which specifies the earliest |
| (...skipping 25 matching lines...) Expand all Loading... |
| 183 sql::InitStatus EnsureCurrentVersion(); | 185 sql::InitStatus EnsureCurrentVersion(); |
| 184 | 186 |
| 185 #if !defined(OS_WIN) | 187 #if !defined(OS_WIN) |
| 186 // Converts the time epoch in the database from being 1970-based to being | 188 // Converts the time epoch in the database from being 1970-based to being |
| 187 // 1601-based which corresponds to the change in Time.internal_value_. | 189 // 1601-based which corresponds to the change in Time.internal_value_. |
| 188 void MigrateTimeEpoch(); | 190 void MigrateTimeEpoch(); |
| 189 #endif | 191 #endif |
| 190 | 192 |
| 191 // --------------------------------------------------------------------------- | 193 // --------------------------------------------------------------------------- |
| 192 | 194 |
| 193 sql::Connection::ErrorCallback error_callback_; | |
| 194 sql::Connection db_; | 195 sql::Connection db_; |
| 195 sql::MetaTable meta_table_; | 196 sql::MetaTable meta_table_; |
| 196 | 197 |
| 197 base::Time cached_early_expiration_threshold_; | 198 base::Time cached_early_expiration_threshold_; |
| 198 | 199 |
| 199 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); | 200 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); |
| 200 }; | 201 }; |
| 201 | 202 |
| 202 } // namespace history | 203 } // namespace history |
| 203 | 204 |
| 204 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ | 205 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ |
| OLD | NEW |