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" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "components/history/core/browser/download_database.h" | 14 #include "components/history/core/browser/download_database.h" |
15 #include "components/history/core/browser/history_types.h" | 15 #include "components/history/core/browser/history_types.h" |
16 #include "components/history/core/browser/typed_url_sync_metadata_database.h" | |
16 #include "components/history/core/browser/url_database.h" | 17 #include "components/history/core/browser/url_database.h" |
17 #include "components/history/core/browser/visit_database.h" | 18 #include "components/history/core/browser/visit_database.h" |
18 #include "components/history/core/browser/visitsegment_database.h" | 19 #include "components/history/core/browser/visitsegment_database.h" |
19 #include "sql/connection.h" | 20 #include "sql/connection.h" |
20 #include "sql/init_status.h" | 21 #include "sql/init_status.h" |
21 #include "sql/meta_table.h" | |
22 | 22 |
23 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
24 #include "components/history/core/browser/android/android_cache_database.h" | 24 #include "components/history/core/browser/android/android_cache_database.h" |
25 #include "components/history/core/browser/android/android_urls_database.h" | 25 #include "components/history/core/browser/android/android_urls_database.h" |
26 #endif | 26 #endif |
27 | 27 |
28 namespace base { | 28 namespace base { |
29 class FilePath; | 29 class FilePath; |
30 } | 30 } |
31 | 31 |
32 class InMemoryURLIndexTest; | 32 class InMemoryURLIndexTest; |
33 | 33 |
34 namespace history { | 34 namespace history { |
35 | 35 |
36 // Encapsulates the SQL connection for the history database. This class holds | 36 // Encapsulates the SQL connection for the history database. This class holds |
37 // the database connection and has methods the history system (including full | 37 // the database connection and has methods the history system (including full |
38 // text search) uses for writing and retrieving information. | 38 // text search) uses for writing and retrieving information. |
39 // | 39 // |
40 // We try to keep most logic out of the history database; this should be seen | 40 // We try to keep most logic out of the history database; this should be seen |
41 // as the storage interface. Logic for manipulating this storage layer should | 41 // as the storage interface. Logic for manipulating this storage layer should |
42 // be in HistoryBackend.cc. | 42 // be in HistoryBackend.cc. |
43 class HistoryDatabase : public DownloadDatabase, | 43 class HistoryDatabase : public DownloadDatabase, |
44 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
45 public AndroidURLsDatabase, | 45 public AndroidURLsDatabase, |
46 public AndroidCacheDatabase, | 46 public AndroidCacheDatabase, |
47 #endif | 47 #endif |
48 public TypedURLSyncMetadataDatabase, | |
48 public URLDatabase, | 49 public URLDatabase, |
49 public VisitDatabase, | 50 public VisitDatabase, |
50 public VisitSegmentDatabase { | 51 public VisitSegmentDatabase { |
51 public: | 52 public: |
52 // A simple class for scoping a history database transaction. This does not | 53 // A simple class for scoping a history database transaction. This does not |
53 // support rollback since the history database doesn't, either. | 54 // support rollback since the history database doesn't, either. |
54 class TransactionScoper { | 55 class TransactionScoper { |
55 public: | 56 public: |
56 explicit TransactionScoper(HistoryDatabase* db) : db_(db) { | 57 explicit TransactionScoper(HistoryDatabase* db) : db_(db) { |
57 db_->BeginTransaction(); | 58 db_->BeginTransaction(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 185 |
185 #if !defined(OS_WIN) | 186 #if !defined(OS_WIN) |
186 // Converts the time epoch in the database from being 1970-based to being | 187 // 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_. | 188 // 1601-based which corresponds to the change in Time.internal_value_. |
188 void MigrateTimeEpoch(); | 189 void MigrateTimeEpoch(); |
189 #endif | 190 #endif |
190 | 191 |
191 // --------------------------------------------------------------------------- | 192 // --------------------------------------------------------------------------- |
192 | 193 |
193 sql::Connection db_; | 194 sql::Connection db_; |
194 sql::MetaTable meta_table_; | |
brettw
2017/03/20 17:27:06
Conceptually, the meta table should live at this l
Gang Wu
2017/03/20 21:34:47
I copied idea from db_ and GetDB(), in base class
| |
195 | 195 |
196 base::Time cached_early_expiration_threshold_; | 196 base::Time cached_early_expiration_threshold_; |
197 | 197 |
198 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); | 198 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); |
199 }; | 199 }; |
200 | 200 |
201 } // namespace history | 201 } // namespace history |
202 | 202 |
203 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ | 203 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ |
OLD | NEW |