From 42c5c3190177eceb6e8cae9d184112a43f6738f1 Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Mon, 19 Aug 2019 12:34:54 -0700 Subject: [PATCH] Do not send meta info until all platforms support necessary chromium sync protocol like "version" and "UniquePosition", ...etc --- .../components/sync/engine_impl/commit.cc | 15 --------------- .../sync/engine_impl/get_updates_processor.cc | 14 -------------- .../brave_sync/brave_profile_sync_service_impl.cc | 6 ------ components/brave_sync/extension/background.js | 6 ++++++ 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/chromium_src/components/sync/engine_impl/commit.cc b/chromium_src/components/sync/engine_impl/commit.cc index 3f67bb572e0a..5c61637db9f2 100644 --- a/chromium_src/components/sync/engine_impl/commit.cc +++ b/chromium_src/components/sync/engine_impl/commit.cc @@ -141,25 +141,10 @@ brave_sync::RecordsListPtr ConvertCommitsToBraveRecords( metaInfo.value = std::to_string(version); bookmark->metaInfo.push_back(metaInfo); - metaInfo.key = "mtime"; - metaInfo.value = std::to_string(entity.mtime()); - bookmark->metaInfo.push_back(metaInfo); - - metaInfo.key = "ctime"; - metaInfo.value = std::to_string(entity.ctime()); - bookmark->metaInfo.push_back(metaInfo); - metaInfo.key = "position_in_parent"; metaInfo.value = std::to_string(entity.position_in_parent()); bookmark->metaInfo.push_back(metaInfo); - if (bm_specifics.has_favicon()) { - std::string icon_base64; - base::Base64Encode(bm_specifics.favicon(), &icon_base64); - metaInfo.key = "icon_data"; - metaInfo.value = icon_base64; - bookmark->metaInfo.push_back(metaInfo); - } record->SetBookmark(std::move(bookmark)); if (!skip_record) record_list->push_back(std::move(record)); diff --git a/chromium_src/components/sync/engine_impl/get_updates_processor.cc b/chromium_src/components/sync/engine_impl/get_updates_processor.cc index 6ff28a51b96f..77d6097e44cf 100644 --- a/chromium_src/components/sync/engine_impl/get_updates_processor.cc +++ b/chromium_src/components/sync/engine_impl/get_updates_processor.cc @@ -99,25 +99,11 @@ void ExtractBookmarkMeta(sync_pb::SyncEntity* entity, sync_pb::MetaInfo* meta_info = bm_specifics->add_meta_info(); meta_info->set_key(metaInfo.key); meta_info->set_value(std::to_string(version)); - } else if (metaInfo.key == "mtime") { - int64_t mtime; - bool result = base::StringToInt64(metaInfo.value, &mtime); - DCHECK(result); - entity->set_mtime(mtime); - } else if (metaInfo.key == "ctime") { - int64_t ctime; - bool result = base::StringToInt64(metaInfo.value, &ctime); - DCHECK(result); - entity->set_ctime(ctime); } else if (metaInfo.key == "position_in_parent") { int64_t position_in_parent; bool result = base::StringToInt64(metaInfo.value, &position_in_parent); DCHECK(result); entity->set_position_in_parent(position_in_parent); - } else if (metaInfo.key == "icon_data") { - std::string icon_data_decoded; - base::Base64Decode(metaInfo.value, &icon_data_decoded); - bm_specifics->set_favicon(icon_data_decoded); } } } diff --git a/components/brave_sync/brave_profile_sync_service_impl.cc b/components/brave_sync/brave_profile_sync_service_impl.cc index 31196ff04be3..b74054202244 100644 --- a/components/brave_sync/brave_profile_sync_service_impl.cc +++ b/components/brave_sync/brave_profile_sync_service_impl.cc @@ -698,10 +698,7 @@ BraveProfileSyncServiceImpl::BookmarkNodeToSyncBookmark( AddSyncEntityInfo(bookmark.get(), node, "originator_cache_guid"); AddSyncEntityInfo(bookmark.get(), node, "originator_client_item_id"); AddSyncEntityInfo(bookmark.get(), node, "version"); - AddSyncEntityInfo(bookmark.get(), node, "mtime"); - AddSyncEntityInfo(bookmark.get(), node, "ctime"); AddSyncEntityInfo(bookmark.get(), node, "position_in_parent"); - AddSyncEntityInfo(bookmark.get(), node, "icon_data"); record->SetBookmark(std::move(bookmark)); @@ -729,10 +726,7 @@ void BraveProfileSyncServiceImpl::LoadSyncEntityInfo( return; AddSyncEntityInfo(bookmark, node, "originator_cache_guid"); AddSyncEntityInfo(bookmark, node, "originator_client_item_id"); - AddSyncEntityInfo(bookmark, node, "mtime"); - AddSyncEntityInfo(bookmark, node, "ctime"); AddSyncEntityInfo(bookmark, node, "position_in_parent"); - AddSyncEntityInfo(bookmark, node, "icon_data"); std::string s_version; // Version needs to be incremented by 1 for legacy sync to emulate // GetUpdateProcessor behavior diff --git a/components/brave_sync/extension/background.js b/components/brave_sync/extension/background.js index 70ee291ff96d..5fabc8824137 100644 --- a/components/brave_sync/extension/background.js +++ b/components/brave_sync/extension/background.js @@ -48,6 +48,12 @@ chrome.braveSync.onSendSyncRecords.addListener(function(category_name, records) // Fixup ids for (var i = 0; i < records.length; ++i) { fixupSyncRecordBrowserToExt(records[i]); + // delete meta info for now until all platforms can support + // "Version" and "UniquePosition" of chromium sync proto + if ('bookmark' in records[i]) { + if ('metaInfo' in records[i].bookmark) + delete records[i].bookmark.metaInfo; + } } console.log(`"send-sync-records" category_name=${JSON.stringify(category_name)} records=${JSON.stringify(records)}`); callbackList["send-sync-records"](null, category_name, records);