diff options
Diffstat (limited to 'chromium/components/history/core/browser/history_backend.cc')
-rw-r--r-- | chromium/components/history/core/browser/history_backend.cc | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/chromium/components/history/core/browser/history_backend.cc b/chromium/components/history/core/browser/history_backend.cc index 697351d37c9..f9d56d6e003 100644 --- a/chromium/components/history/core/browser/history_backend.cc +++ b/chromium/components/history/core/browser/history_backend.cc @@ -58,7 +58,7 @@ #include "url/gurl.h" #include "url/url_constants.h" -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) #include "base/ios/scoped_critical_action.h" #endif @@ -287,6 +287,15 @@ HistoryBackend::~HistoryBackend() { // Release stashed embedder object before cleaning up the databases. supports_user_data_helper_.reset(); + // Clear the error callback. The error callback that is installed does not + // process an error immediately, rather it uses a PostTask() with `this`. As + // `this` is being deleted, scheduling a PostTask() with `this` would be + // fatal (use-after-free). Additionally, as we're in shutdown, there isn't + // much point in trying to handle the error. If the error is really fatal, + // we'll cleanup the next time the backend is created. + if (db_) + db_->reset_error_callback(); + // First close the databases before optionally running the "destroy" task. CloseAllDatabases(); @@ -349,7 +358,7 @@ void HistoryBackend::Closing() { CancelScheduledCommit(); } -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) void HistoryBackend::PersistState() { TRACE_EVENT0("browser", "HistoryBackend::PersistState"); Commit(); @@ -474,10 +483,10 @@ void HistoryBackend::UpdateWithPageEndTime(ContextID context_id, UpdateVisitDuration(visit_id, end_ts); } -void HistoryBackend::SetFlocAllowed(ContextID context_id, - int nav_entry_id, - const GURL& url) { - TRACE_EVENT0("browser", "HistoryBackend::SetFlocAllowed"); +void HistoryBackend::SetBrowsingTopicsAllowed(ContextID context_id, + int nav_entry_id, + const GURL& url) { + TRACE_EVENT0("browser", "HistoryBackend::SetBrowsingTopicsAllowed"); if (!db_) return; @@ -491,11 +500,11 @@ void HistoryBackend::SetFlocAllowed(ContextID context_id, VisitContentAnnotations annotations; if (db_->GetContentAnnotationsForVisit(visit_id, &annotations)) { annotations.annotation_flags |= - VisitContentAnnotationFlag::kFlocEligibleRelaxed; + VisitContentAnnotationFlag::kBrowsingTopicsEligible; db_->UpdateContentAnnotationsForVisit(visit_id, annotations); } else { annotations.annotation_flags |= - VisitContentAnnotationFlag::kFlocEligibleRelaxed; + VisitContentAnnotationFlag::kBrowsingTopicsEligible; db_->AddContentAnnotationsForVisit(visit_id, annotations); } ScheduleCommit(); @@ -522,6 +531,11 @@ void HistoryBackend::AddContentModelAnnotationsForVisit( annotations.model_annotations = model_annotations; db_->AddContentAnnotationsForVisit(visit_id, annotations); } + URLRow url_row; + if (db_->GetURLRow(visit_row.url_id, &url_row)) { + delegate_->NotifyContentModelAnnotationModified(url_row, + model_annotations); + } ScheduleCommit(); } } @@ -550,6 +564,33 @@ void HistoryBackend::AddRelatedSearchesForVisit( } } +void HistoryBackend::AddSearchMetadataForVisit( + VisitID visit_id, + const GURL& search_normalized_url, + const std::u16string& search_terms) { + TRACE_EVENT0("browser", "HistoryBackend::AddSearchMetadataForVisit"); + + if (!db_) + return; + + // Only add to the annotations table if the visit_id exists in the visits + // table. + VisitRow visit_row; + if (db_->GetRowForVisit(visit_id, &visit_row)) { + VisitContentAnnotations annotations; + if (db_->GetContentAnnotationsForVisit(visit_id, &annotations)) { + annotations.search_normalized_url = search_normalized_url; + annotations.search_terms = search_terms; + db_->UpdateContentAnnotationsForVisit(visit_id, annotations); + } else { + annotations.search_normalized_url = search_normalized_url; + annotations.search_terms = search_terms; + db_->AddContentAnnotationsForVisit(visit_id, annotations); + } + ScheduleCommit(); + } +} + void HistoryBackend::UpdateVisitDuration(VisitID visit_id, const Time end_ts) { if (!db_) return; @@ -888,7 +929,7 @@ void HistoryBackend::InitImpl( // The frequency of this UMA will indicate how often history // initialization fails. UMA_HISTOGRAM_BOOLEAN("History.AttemptedToFixProfileError", kill_db); - FALLTHROUGH; + [[fallthrough]]; } case sql::INIT_TOO_NEW: { db_diagnostics_ += sql::GetCorruptFileDiagnosticsInfo(history_name); @@ -1325,7 +1366,7 @@ DomainDiversityResults HistoryBackend::GetDomainDiversity( std::min(number_of_days_to_report, kDomainDiversityMaxBacktrackedDays); base::Time current_midnight = report_time.LocalMidnight(); - SCOPED_UMA_HISTOGRAM_TIMER("History.DomainCountQueryTime"); + SCOPED_UMA_HISTOGRAM_TIMER("History.DomainCountQueryTime_V2"); for (int days_back = 0; days_back < number_of_days_to_report; ++days_back) { DomainMetricSet single_metric_set; @@ -1720,7 +1761,7 @@ bool HistoryBackend::CreateDownload(const DownloadRow& history_info) { if (!db_) return false; bool success = db_->CreateDownload(history_info); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // On android, browser process can get easily killed. Download will no longer // be able to resume and the temporary file will linger forever if the // download is not committed before that. Do the commit right away to avoid @@ -2251,7 +2292,7 @@ void HistoryBackend::Commit() { if (!db_) return; -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) // Attempts to get the application running long enough to commit the database // transaction if it is currently being backgrounded. base::ios::ScopedCriticalAction scoped_critical_action( @@ -2673,7 +2714,7 @@ bool HistoryBackend::ClearAllFaviconHistory( if (!favicon_backend_->ClearAllExcept(kept_urls)) return false; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // TODO(michaelbai): Add the unit test once AndroidProviderBackend is // available in HistoryBackend. db_->ClearAndroidURLRows(); |