diff --git a/components/brave_sync/brave_sync_service_impl.cc b/components/brave_sync/brave_sync_service_impl.cc index 98d37dfa7c7a..1117ea656ed1 100644 --- a/components/brave_sync/brave_sync_service_impl.cc +++ b/components/brave_sync/brave_sync_service_impl.cc @@ -90,7 +90,7 @@ BraveSyncServiceImpl::BraveSyncServiceImpl(Profile* profile) : sync_client_.get(), sync_prefs_.get())), timer_(std::make_unique()), - unsynced_send_interval_(base::TimeDelta::FromMinutes(10)) { + unsynced_send_interval_(base::TimeDelta::FromMinutes(60)) { // Moniter syncs prefs required in GetSettingsAndDevices profile_pref_change_registrar_.Init(profile->GetPrefs()); profile_pref_change_registrar_.Add( diff --git a/components/brave_sync/client/bookmark_change_processor.cc b/components/brave_sync/client/bookmark_change_processor.cc index 2298d43d5f83..88a4ee211852 100644 --- a/components/brave_sync/client/bookmark_change_processor.cc +++ b/components/brave_sync/client/bookmark_change_processor.cc @@ -193,11 +193,6 @@ void UpdateNode(bookmarks::BookmarkModel* model, model->SetNodeMetaInfo(node, "object_id", record->objectId); model->SetNodeMetaInfo(node, "order", bookmark.order); - // updating the sync_timestamp marks this record as synced - model->SetNodeMetaInfo(node, - "sync_timestamp", - std::to_string(record->syncTimestamp.ToJsTime())); - if (pending_node_root && node->parent() == pending_node_root) { model->SetNodeMetaInfo(node, "parent_object_id", bookmark.parentFolderObjectId); @@ -782,6 +777,10 @@ void BookmarkChangeProcessor::GetAllSyncData( auto* node = FindByObjectId(bookmark_model_, record->objectId); if (node) { resolved_record->second = BookmarkNodeToSyncBookmark(node); + // Update "sync_timestamp" + bookmark_model_->SetNodeMetaInfo(node, + "sync_timestamp", + std::to_string(record->syncTimestamp.ToJsTime())); } records_and_existing_objects->push_back(std::move(resolved_record)); diff --git a/components/brave_sync/client/bookmark_change_processor_unittest.cc b/components/brave_sync/client/bookmark_change_processor_unittest.cc index a9cde2c9572c..14580a10b180 100644 --- a/components/brave_sync/client/bookmark_change_processor_unittest.cc +++ b/components/brave_sync/client/bookmark_change_processor_unittest.cc @@ -1403,3 +1403,66 @@ TEST_F(BraveBookmarkChangeProcessorTest, ApplyOrder) { node_a->GetMetaInfo("order", &order); EXPECT_EQ(order, new_order); } + +namespace { + +const bookmarks::BookmarkNode* GetSingleNodeByUrl( + bookmarks::BookmarkModel* model, const std::string& url) { + std::vector nodes; + model->GetNodesByURL(GURL(url), &nodes); + size_t nodes_size = nodes.size(); + CHECK_EQ(nodes_size, 1u); + const bookmarks::BookmarkNode* node = nodes.at(0); + return node; +} + +} // namespace + +TEST_F(BraveBookmarkChangeProcessorTest, SyncTimestampMetaUpdateWay) { + // Should update "sync_timestamp": + // "get-existing-objects" => model => "resolve-sync-records" + // (GetAllSyncData) + // + // Should not update "sync_timestamp": + // "resolved-sync-records" => model + // (ApplyChangesFromSyncModel) + + change_processor()->Start(); + + RecordsList records; + const char* record_b_object_id = + "222, 222, 37, 61, 199, 11, 166, 234, " + "214, 197, 45, 215, 241, 206, 219, 130"; + records.push_back(SimpleBookmarkSyncRecord( + SyncRecord::Action::A_CREATE, + record_b_object_id, + "https://b.com/", + "B.com - title", + "1.1.1.2", "")); + + change_processor()->ApplyChangesFromSyncModel(records); + + std::string node_b_sync_timestamp; + GetSingleNodeByUrl(model(), "https://b.com/")->GetMetaInfo( + "sync_timestamp", &node_b_sync_timestamp); + EXPECT_EQ(node_b_sync_timestamp, ""); + + RecordsList records_to_resolve; + records_to_resolve.push_back(SimpleBookmarkSyncRecord( + SyncRecord::Action::A_UPDATE, + record_b_object_id, + "https://b.com/", + "B.com - title - modified", + "1.1.1.2", "")); + auto timestamp_resolve = base::Time::Now(); + records_to_resolve.at(0)->syncTimestamp = timestamp_resolve; + + brave_sync::SyncRecordAndExistingList records_and_existing_objects; + change_processor()->GetAllSyncData(records_to_resolve, + &records_and_existing_objects); + GetSingleNodeByUrl(model(), "https://b.com/")->GetMetaInfo( + "sync_timestamp", &node_b_sync_timestamp); + + EXPECT_EQ(node_b_sync_timestamp, + std::to_string(timestamp_resolve.ToJsTime())); +}