diff --git a/browser/brave_browser_process_impl.cc b/browser/brave_browser_process_impl.cc index 285d7264d29a..b1077146683f 100644 --- a/browser/brave_browser_process_impl.cc +++ b/browser/brave_browser_process_impl.cc @@ -28,6 +28,7 @@ #include "brave/components/brave_shields/browser/https_everywhere_service.h" #include "brave/components/brave_shields/browser/referrer_whitelist_service.h" #include "brave/components/brave_shields/browser/tracking_protection_service.h" +#include "brave/components/brave_sync/buildflags/buildflags.h" #include "brave/components/brave_sync/network_time_helper.h" #include "brave/components/ntp_background_images/browser/features.h" #include "brave/components/ntp_background_images/browser/ntp_background_images_service.h" @@ -198,8 +199,10 @@ void BraveBrowserProcessImpl::StartBraveServices() { // Now start the local data files service, which calls all observers. local_data_files_service()->Start(); +#if BUILDFLAG(ENABLE_BRAVE_SYNC) brave_sync::NetworkTimeHelper::GetInstance() ->SetNetworkTimeTracker(g_browser_process->network_time_tracker()); +#endif } brave_shields::AdBlockService* BraveBrowserProcessImpl::ad_block_service() { diff --git a/components/brave_sync/network_time_helper.cc b/components/brave_sync/network_time_helper.cc index ba84b986d903..3f7aba6d90b7 100644 --- a/components/brave_sync/network_time_helper.cc +++ b/components/brave_sync/network_time_helper.cc @@ -43,13 +43,12 @@ void NetworkTimeHelper::SetNetworkTimeForTest(const base::Time& time) { network_time_for_test_ = time; } -void NetworkTimeHelper::GetNetworkTimeOnUIThread( - GetNetworkTimeCallback cb) { +void NetworkTimeHelper::GetNetworkTimeOnUIThread(GetNetworkTimeCallback cb) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(network_time_tracker_); base::Time time; - if (network_time_tracker_->GetNetworkTime(&time, nullptr) != - network_time::NetworkTimeTracker::NETWORK_TIME_AVAILABLE) { + if (!network_time_tracker_ || + network_time_tracker_->GetNetworkTime(&time, nullptr) != + network_time::NetworkTimeTracker::NETWORK_TIME_AVAILABLE) { VLOG(1) << "Network time not available, using local time"; time = base::Time::Now(); }