From c5aff33c8daa8f7f6d2acfec636676dcf13ef1e0 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 11 Nov 2022 15:36:02 +0100 Subject: FIXUP: Adapt favicon and history component for WebEngine Change-Id: Ie65432f4a700c003eff533d4c2df522d8bcc50b0 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/442876 Reviewed-by: Allan Sandfeld Jensen --- chromium/components/history/core/browser/BUILD.gn | 25 ++++++++++++++++++++-- .../history/core/browser/history_backend.cc | 4 ++-- .../history/core/browser/history_backend.h | 2 +- .../history/core/browser/history_database.cc | 24 ++++++++++++++++----- .../history/core/browser/history_database.h | 4 ++++ .../history/core/browser/history_service.cc | 2 +- .../history/core/browser/history_service.h | 2 +- 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/chromium/components/history/core/browser/BUILD.gn b/chromium/components/history/core/browser/BUILD.gn index f9bf5464940..299ae3dde17 100644 --- a/chromium/components/history/core/browser/BUILD.gn +++ b/chromium/components/history/core/browser/BUILD.gn @@ -142,14 +142,32 @@ static_library("browser") { "browsing_history_service.h", "sync/delete_directive_handler.cc", "sync/delete_directive_handler.h", + "sync/history_backend_for_sync.h", "sync/history_delete_directives_model_type_controller.cc", "sync/history_delete_directives_model_type_controller.h", - "sync/typed_url_model_type_controller.cc", - "sync/typed_url_model_type_controller.h", + "sync/history_model_type_controller.cc", + "sync/history_model_type_controller.h", + "sync/history_model_type_controller_helper.cc", + "sync/history_model_type_controller_helper.h", + "sync/history_sync_bridge.cc", + "sync/history_sync_bridge.h", + "sync/history_sync_metadata_database.cc", + "sync/history_sync_metadata_database.h", "sync/typed_url_sync_bridge.cc", "sync/typed_url_sync_bridge.h", "sync/typed_url_sync_metadata_database.cc", "sync/typed_url_sync_metadata_database.h", + "sync/visit_id_remapper.cc", + "sync/visit_id_remapper.h", + "top_sites.cc", + "top_sites.h", + "top_sites_backend.cc", + "top_sites_backend.h", + "top_sites_database.cc", + "top_sites_database.h", + "top_sites_impl.cc", + "top_sites_impl.h", + "top_sites_observer.h", ] public_deps -= [ @@ -157,6 +175,9 @@ static_library("browser") { ] deps -= [ + "//components/google/core/common", + "//components/search_engines", + "//components/signin/public/identity_manager", "//components/sync", ] } diff --git a/chromium/components/history/core/browser/history_backend.cc b/chromium/components/history/core/browser/history_backend.cc index 217700a788a..fe2fd0c9074 100644 --- a/chromium/components/history/core/browser/history_backend.cc +++ b/chromium/components/history/core/browser/history_backend.cc @@ -331,7 +331,6 @@ void HistoryBackend::Init( std::make_unique( syncer::TYPED_URLS, /*dump_stack=*/base::RepeatingClosure())); typed_url_sync_bridge_->Init(); -#endif // !defined(TOOLKIT_QT) if (base::FeatureList::IsEnabled(syncer::kSyncEnableHistoryDataType)) { // TODO(crbug.com/1318028): Plumb in syncer::ReportUnrecoverableError as the @@ -341,6 +340,7 @@ void HistoryBackend::Init( std::make_unique( syncer::HISTORY, /*dump_stack=*/base::RepeatingClosure())); } +#endif // !defined(TOOLKIT_QT) memory_pressure_listener_ = std::make_unique( FROM_HERE, base::BindRepeating(&HistoryBackend::OnMemoryPressure, @@ -1500,13 +1500,13 @@ HistoryBackend::GetTypedURLSyncControllerDelegate() { DCHECK(typed_url_sync_bridge_); return typed_url_sync_bridge_->change_processor()->GetControllerDelegate(); } -#endif // !defined(TOOLKIT_QT) base::WeakPtr HistoryBackend::GetHistorySyncControllerDelegate() { DCHECK(history_sync_bridge_); return history_sync_bridge_->change_processor()->GetControllerDelegate(); } +#endif // !defined(TOOLKIT_QT) // Statistics ------------------------------------------------------------------ diff --git a/chromium/components/history/core/browser/history_backend.h b/chromium/components/history/core/browser/history_backend.h index a4d2d696a08..1fd37f0dcb8 100644 --- a/chromium/components/history/core/browser/history_backend.h +++ b/chromium/components/history/core/browser/history_backend.h @@ -591,12 +591,12 @@ class HistoryBackend : public base::RefCountedThreadSafe, // delegate is owned by `this` object. base::WeakPtr GetTypedURLSyncControllerDelegate(); -#endif // !defined(TOOLKIT_QT) // Returns the sync controller delegate for syncing history. The returned // delegate is owned by `this` object. base::WeakPtr GetHistorySyncControllerDelegate(); +#endif // !defined(TOOLKIT_QT) // Deleting ------------------------------------------------------------------ diff --git a/chromium/components/history/core/browser/history_database.cc b/chromium/components/history/core/browser/history_database.cc index 7e47f39fe0c..d65d0b8b90d 100644 --- a/chromium/components/history/core/browser/history_database.cc +++ b/chromium/components/history/core/browser/history_database.cc @@ -20,7 +20,9 @@ #include "base/rand_util.h" #include "base/time/time.h" #include "build/build_config.h" +#if !defined(TOOLKIT_QT) #include "components/sync/base/features.h" +#endif #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "sql/database.h" #include "sql/meta_table.h" @@ -79,7 +81,7 @@ HistoryDatabase::HistoryDatabase( DownloadInterruptReason download_interrupt_reason_crash) : DownloadDatabase(download_interrupt_reason_none, download_interrupt_reason_crash), - db_(sql::DatabaseOptions( + db_(sql::DatabaseOptions{ // Note that we don't set exclusive locking here. That's done by // BeginExclusiveMode below which is called later (we have to be in // shared mode to start out for the in-memory backend to read the @@ -93,9 +95,12 @@ HistoryDatabase::HistoryDatabase( // Set the cache size. The page size, plus a little extra, times this // value, tells us how much memory the cache will use maximum. // 1000 * 4kB = 4MB - /*.cache_size =*/ 1000}), - typed_url_metadata_db_(&db_, &meta_table_), - history_metadata_db_(&db_, &meta_table_) {} + /*.cache_size =*/ 1000}) +#if !defined(TOOLKIT_QT) + , typed_url_metadata_db_(&db_, &meta_table_) + , history_metadata_db_(&db_, &meta_table_) +#endif +{} HistoryDatabase::~HistoryDatabase() = default; @@ -125,14 +130,19 @@ sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) { return LogInitFailure(InitStep::META_TABLE_INIT); if (!CreateURLTable(false) || !InitVisitTable() || !InitKeywordSearchTermsTable() || !InitDownloadTable() || - !InitSegmentTables() || !typed_url_metadata_db_.Init() || + !InitSegmentTables() || +#if !defined(TOOLKIT_QT) + !typed_url_metadata_db_.Init() || +#endif !InitVisitAnnotationsTables()) { return LogInitFailure(InitStep::CREATE_TABLES); } +#if !defined(TOOLKIT_QT) if (base::FeatureList::IsEnabled(syncer::kSyncEnableHistoryDataType) && !history_metadata_db_.Init()) { return LogInitFailure(InitStep::CREATE_TABLES); } +#endif CreateMainURLIndex(); // TODO(benjhayden) Remove at some point. @@ -173,6 +183,7 @@ void HistoryDatabase::ComputeDatabaseMetrics( UMA_HISTOGRAM_TIMES("History.DatabaseBasicMetricsTime", base::TimeTicks::Now() - start_time); +#if !defined(TOOLKIT_QT) if (base::FeatureList::IsEnabled(syncer::kSyncEnableHistoryDataType)) { // Compute metrics about foreign visits (i.e. visits coming from other // devices) in the DB. @@ -251,6 +262,7 @@ void HistoryDatabase::ComputeDatabaseMetrics( base::UmaHistogramTimes("History.DatabaseForeignVisitMetricsTime", base::TimeTicks::Now() - start_time); } +#endif // !defined(TOOLKIT_QT) // Compute the advanced metrics even less often, pending timing data showing // that's not necessary. @@ -462,6 +474,7 @@ void HistoryDatabase::UpdateEarlyExpirationThreshold(base::Time threshold) { cached_early_expiration_threshold_ = threshold; } +#if !defined(TOOLKIT_QT) TypedURLSyncMetadataDatabase* HistoryDatabase::GetTypedURLMetadataDB() { return &typed_url_metadata_db_; } @@ -469,6 +482,7 @@ TypedURLSyncMetadataDatabase* HistoryDatabase::GetTypedURLMetadataDB() { HistorySyncMetadataDatabase* HistoryDatabase::GetHistoryMetadataDB() { return &history_metadata_db_; } +#endif // !defined(TOOLKIT_QT) sql::Database& HistoryDatabase::GetDB() { return db_; diff --git a/chromium/components/history/core/browser/history_database.h b/chromium/components/history/core/browser/history_database.h index 35d53c3f8cf..228a79c3eac 100644 --- a/chromium/components/history/core/browser/history_database.h +++ b/chromium/components/history/core/browser/history_database.h @@ -163,11 +163,13 @@ class HistoryDatabase : public DownloadDatabase, // Sync metadata storage ---------------------------------------------------- +#if !defined(TOOLKIT_QT) // Returns the sub-database used for storing Sync metadata for Typed URLs. TypedURLSyncMetadataDatabase* GetTypedURLMetadataDB(); // Returns the sub-database used for storing Sync metadata for History. HistorySyncMetadataDatabase* GetHistoryMetadataDB(); +#endif // !defined(TOOLKIT_QT) private: #if BUILDFLAG(IS_ANDROID) @@ -202,12 +204,14 @@ class HistoryDatabase : public DownloadDatabase, sql::Database db_; sql::MetaTable meta_table_; +#if !defined(TOOLKIT_QT) // Most of the sub-DBs (URLDatabase etc.) are integrated into HistoryDatabase // via inheritance. However, that can lead to "diamond inheritance" issues // when multiple of these base classes define the same methods. Therefore the // Sync metadata DBs are integrated via composition instead. TypedURLSyncMetadataDatabase typed_url_metadata_db_; HistorySyncMetadataDatabase history_metadata_db_; +#endif // !defined(TOOLKIT_QT) base::Time cached_early_expiration_threshold_; }; diff --git a/chromium/components/history/core/browser/history_service.cc b/chromium/components/history/core/browser/history_service.cc index 4df5cc3ab7f..68e2437fa4d 100644 --- a/chromium/components/history/core/browser/history_service.cc +++ b/chromium/components/history/core/browser/history_service.cc @@ -1194,7 +1194,6 @@ HistoryService::GetTypedURLSyncControllerDelegate() { base::BindRepeating(&HistoryBackend::GetTypedURLSyncControllerDelegate, base::Unretained(history_backend_.get()))); } -#endif // !defined(TOOLKIT_QT) std::unique_ptr HistoryService::GetHistorySyncControllerDelegate() { @@ -1207,6 +1206,7 @@ HistoryService::GetHistorySyncControllerDelegate() { base::BindRepeating(&HistoryBackend::GetHistorySyncControllerDelegate, base::Unretained(history_backend_.get()))); } +#endif // !defined(TOOLKIT_QT) void HistoryService::ProcessLocalDeleteDirective( const sync_pb::HistoryDeleteDirectiveSpecifics& delete_directive) { diff --git a/chromium/components/history/core/browser/history_service.h b/chromium/components/history/core/browser/history_service.h index 3b1ac0cc95a..4fe9358840a 100644 --- a/chromium/components/history/core/browser/history_service.h +++ b/chromium/components/history/core/browser/history_service.h @@ -646,12 +646,12 @@ class HistoryService : public KeyedService { // TypedURLSyncBridge. Must be called from the UI thread. std::unique_ptr GetTypedURLSyncControllerDelegate(); -#endif // !defined(TOOLKIT_QT) // For sync codebase only: instantiates a controller delegate to interact with // HistorySyncBridge. Must be called from the UI thread. std::unique_ptr GetHistorySyncControllerDelegate(); +#endif // !defined(TOOLKIT_QT) // Override `backend_task_runner_` for testing; needs to be called before // Init. -- cgit v1.2.1