Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: components/history/core/browser/history_database.h

Issue 2721713002: [sync] Add typed url sync metadata to the history db (Closed)
Patch Set: update for comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "sql/meta_table.h"
22 23
23 #if defined(OS_ANDROID) 24 #if defined(OS_ANDROID)
24 #include "components/history/core/browser/android/android_cache_database.h" 25 #include "components/history/core/browser/android/android_cache_database.h"
25 #include "components/history/core/browser/android/android_urls_database.h" 26 #include "components/history/core/browser/android/android_urls_database.h"
(...skipping 12 matching lines...) Expand all
38 // text search) uses for writing and retrieving information. 39 // text search) uses for writing and retrieving information.
39 // 40 //
40 // We try to keep most logic out of the history database; this should be seen 41 // 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 42 // as the storage interface. Logic for manipulating this storage layer should
42 // be in HistoryBackend.cc. 43 // be in HistoryBackend.cc.
43 class HistoryDatabase : public DownloadDatabase, 44 class HistoryDatabase : public DownloadDatabase,
44 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
45 public AndroidURLsDatabase, 46 public AndroidURLsDatabase,
46 public AndroidCacheDatabase, 47 public AndroidCacheDatabase,
47 #endif 48 #endif
49 public TypedURLSyncMetadataDatabase,
48 public URLDatabase, 50 public URLDatabase,
49 public VisitDatabase, 51 public VisitDatabase,
50 public VisitSegmentDatabase { 52 public VisitSegmentDatabase {
51 public: 53 public:
52 // A simple class for scoping a history database transaction. This does not 54 // A simple class for scoping a history database transaction. This does not
53 // support rollback since the history database doesn't, either. 55 // support rollback since the history database doesn't, either.
54 class TransactionScoper { 56 class TransactionScoper {
55 public: 57 public:
56 explicit TransactionScoper(HistoryDatabase* db) : db_(db) { 58 explicit TransactionScoper(HistoryDatabase* db) : db_(db) {
57 db_->BeginTransaction(); 59 db_->BeginTransaction();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 virtual void UpdateEarlyExpirationThreshold(base::Time threshold); 164 virtual void UpdateEarlyExpirationThreshold(base::Time threshold);
163 165
164 private: 166 private:
165 #if defined(OS_ANDROID) 167 #if defined(OS_ANDROID)
166 // AndroidProviderBackend uses the |db_|. 168 // AndroidProviderBackend uses the |db_|.
167 friend class AndroidProviderBackend; 169 friend class AndroidProviderBackend;
168 FRIEND_TEST_ALL_PREFIXES(AndroidURLsMigrationTest, MigrateToVersion22); 170 FRIEND_TEST_ALL_PREFIXES(AndroidURLsMigrationTest, MigrateToVersion22);
169 #endif 171 #endif
170 friend class ::InMemoryURLIndexTest; 172 friend class ::InMemoryURLIndexTest;
171 173
172 // Overridden from URLDatabase: 174 // Overridden from URLDatabase, DownloadDatabase, VisitDatabase,
175 // VisitSegmentDatabase and TypedURLSyncMetadataDatabase.
173 sql::Connection& GetDB() override; 176 sql::Connection& GetDB() override;
174 177
178 // Overridden from TypedURLSyncMetadataDatabase.
179 sql::MetaTable& GetMetaTable() override;
180
175 // Migration ----------------------------------------------------------------- 181 // Migration -----------------------------------------------------------------
176 182
177 // Makes sure the version is up to date, updating if necessary. If the 183 // Makes sure the version is up to date, updating if necessary. If the
178 // database is too old to migrate, the user will be notified. Returns 184 // database is too old to migrate, the user will be notified. Returns
179 // sql::INIT_OK iff the DB is up to date and ready for use. 185 // sql::INIT_OK iff the DB is up to date and ready for use.
180 // 186 //
181 // This assumes it is called from the init function inside a transaction. It 187 // This assumes it is called from the init function inside a transaction. It
182 // may commit the transaction and start a new one if migration requires it. 188 // may commit the transaction and start a new one if migration requires it.
183 sql::InitStatus EnsureCurrentVersion(); 189 sql::InitStatus EnsureCurrentVersion();
184 190
185 #if !defined(OS_WIN) 191 #if !defined(OS_WIN)
186 // Converts the time epoch in the database from being 1970-based to being 192 // 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_. 193 // 1601-based which corresponds to the change in Time.internal_value_.
188 void MigrateTimeEpoch(); 194 void MigrateTimeEpoch();
189 #endif 195 #endif
190 196
191 // --------------------------------------------------------------------------- 197 // ---------------------------------------------------------------------------
192 198
193 sql::Connection db_; 199 sql::Connection db_;
194 sql::MetaTable meta_table_; 200 sql::MetaTable meta_table_;
195 201
196 base::Time cached_early_expiration_threshold_; 202 base::Time cached_early_expiration_threshold_;
197 203
198 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase); 204 DISALLOW_COPY_AND_ASSIGN(HistoryDatabase);
199 }; 205 };
200 206
201 } // namespace history 207 } // namespace history
202 208
203 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_ 209 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DATABASE_H_
OLDNEW
« no previous file with comments | « components/history/core/browser/BUILD.gn ('k') | components/history/core/browser/history_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698