Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Chromium's DeviceInfoSyncBridge::ExpireOldEntries #12005

Merged
merged 3 commits into from
Feb 11, 2022

Conversation

AlexeyBarabash
Copy link
Contributor

@AlexeyBarabash AlexeyBarabash commented Jan 26, 2022

Resolves brave/brave-browser#20937

This PR disables Chromium's feature of expiring old devices in the sync chain.
Chromium removes the devices from the local sync db which are older than 56 days but these devices are still stored on ser server.
This PR disables DeviceInfoSyncBridge::ExpireOldEntries to prevent expiring of the devices. Also, for the existing browsers with enabled sync it once resets the progress token at DeviceInfoSyncBridge::OnReadAllMetadata to reset.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Test plan

I. Test plan for QA. You will need to have a sync chain where are present devices which were unused for more than 56 days.

  1. Connect to the chain with build which contains this PR. Expected to see old devices.
  2. Restart browser. Expected still to see old devices.
  3. Take the Android phone, install the version containing this PR, connect to the sync chain with expired devices via QR. Expected to see old devices.
  4. Restart browser app on the phone, it's also expected to see the old devices.

II. Test plan when it is possible to make own builds, but still require to have a sync chain with expired devices. Useless for QA team

  1. Disable code at DeviceInfoSyncBridge::OnReadAllMetadata of metadata_batch->ClearProgressToken()
  2. Disable code at #define BRAVE_SKIP_EXPIRE_OLD_ENTRIES return;
  3. Connect to the chain with with old devices
  4. Restart brower, ensure there are no old devices
  5. Enable Brave code at DeviceInfoSyncBridge::OnReadAllMetadata
    Enable Brave code at BRAVE_SKIP_EXPIRE_OLD_ENTRIES
    remove pref of brave_sync_v2.reset_devices_progress_token_time
  6. Run browser again, ensure expired devices appeared again

@AlexeyBarabash AlexeyBarabash added feature/sync CI/skip Do not run CI builds (except noplatform) labels Jan 26, 2022
@AlexeyBarabash AlexeyBarabash self-assigned this Jan 26, 2022
@AlexeyBarabash AlexeyBarabash force-pushed the sync_exp_devices branch 2 times, most recently from 4933d90 to 91d98c6 Compare January 26, 2022 21:34
@AlexeyBarabash AlexeyBarabash marked this pull request as ready for review February 7, 2022 14:41
@AlexeyBarabash AlexeyBarabash requested review from a team as code owners February 7, 2022 14:41
@github-actions github-actions bot added rebase and removed rebase labels Feb 7, 2022
@AlexeyBarabash AlexeyBarabash removed the CI/skip Do not run CI builds (except noplatform) label Feb 7, 2022
EXPECT_FALSE(
batch->GetModelTypeState().progress_marker().has_token());
} else {
ASSERT_EQ(current_call_number, 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this block is tested? RunLoop seems to only wait for the first call and then there is no second run waiting for second callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure this block is executed, because I have been using there LOG() traces while development.
Also there is EXPECT_CALL(*processor(), ModelReadyToSync).Times(2) .

But I will recheck code around your notice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darkdh I re-wrote the test to be more clear and those two cases are split now.
f47ba5a

pref_service_->SetTime(kResetDevicesProgressTokenTime, base::Time::Now());
}

std::string DeviceInfoPrefs::GetResetDevicesProgressTokenTimeName() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like it's used anywhere.
and if it was, the pref name should be accessed directly via const char [].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @goodov, this is a leftover indeed.

Fixed at 1334354

RegisterProfilePrefs_ChromiumImpl(PrefRegistrySimple* registry); \
static void RegisterProfilePrefs

#define GarbageCollectExpiredCacheGuids \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these additions could be done in the same #define RegisterProfilePrefs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is fixed at e747431

#include "src/components/sync_device_info/device_info_sync_bridge.cc"

#undef BRAVE_SKIP_EXPIRE_OLD_ENTRIES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#undef BRAVE_ON_READ_ALL_METADATA_CLEAR_PROGRESS_TOKEN

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed at e747431

@AlexeyBarabash
Copy link
Contributor Author

Squashed commits, rebased on master, fixed wrong copyright year; no other changes.

@AlexeyBarabash
Copy link
Contributor Author

Verified on Android, added test plan for Android.

@AlexeyBarabash AlexeyBarabash merged commit 56808a9 into master Feb 11, 2022
@AlexeyBarabash AlexeyBarabash deleted the sync_exp_devices branch February 11, 2022 11:09
@AlexeyBarabash AlexeyBarabash added this to the 1.37.x - Nightly milestone Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Sync] Disable expiring of devices
3 participants