Commit 05eb9e7c authored by Rushan Suleymanov's avatar Rushan Suleymanov Committed by Commit Bot

[Sync] Reduce sharing message sync latency.

Add switch to fallback to default latency value.

Bug: 1034928
Change-Id: I5b4bf1bb5e3d80ab854b1c6b9758c4c06c26152f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2022765Reviewed-by: default avatarvitaliii <vitaliii@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#735387}
parent d971f4fc
......@@ -17,6 +17,12 @@ const base::Feature kSyncForceDisableScryptForCustomPassphrase{
const base::Feature kSyncE2ELatencyMeasurement = {
"SyncE2ELatencyMeasurement", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSyncCustomSharingMessageNudgeDelay = {
"SyncCustomSharingMessageNudgeDelay", base::FEATURE_ENABLED_BY_DEFAULT};
const base::FeatureParam<int> kSyncSharingMessageNudgeDelayMilliseconds{
&kSyncCustomSharingMessageNudgeDelay,
"SyncSharingMessageNudgeDelayMilliseconds", 50};
const base::Feature kDoNotSyncFaviconDataTypes{
"DoNotSyncFaviconDataTypes", base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -6,11 +6,14 @@
#define COMPONENTS_SYNC_BASE_SYNC_BASE_SWITCHES_H_
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
namespace switches {
extern const base::Feature kSyncForceDisableScryptForCustomPassphrase;
extern const base::Feature kSyncE2ELatencyMeasurement;
extern const base::Feature kSyncCustomSharingMessageNudgeDelay;
extern const base::FeatureParam<int> kSyncSharingMessageNudgeDelayMilliseconds;
extern const base::Feature kDoNotSyncFaviconDataTypes;
} // namespace switches
......
......@@ -7,6 +7,7 @@
#include <algorithm>
#include <utility>
#include "components/sync/base/sync_base_switches.h"
#include "components/sync/engine/polling_constants.h"
namespace syncer {
......@@ -19,6 +20,16 @@ const int kSlowNudgeDelayMilliseconds = 2000;
const int kSyncRefreshDelayMilliseconds = 500;
const int kSyncSchedulerDelayMilliseconds = 250;
base::TimeDelta GetSharingMessageDelay(base::TimeDelta default_delay) {
if (!base::FeatureList::IsEnabled(
switches::kSyncCustomSharingMessageNudgeDelay)) {
return default_delay;
}
return base::TimeDelta::FromMilliseconds(
switches::kSyncSharingMessageNudgeDelayMilliseconds.Get());
}
base::TimeDelta GetDefaultDelayForType(ModelType model_type,
base::TimeDelta minimum_delay) {
switch (model_type) {
......@@ -35,6 +46,8 @@ base::TimeDelta GetDefaultDelayForType(ModelType model_type,
// Types with sometimes automatic changes get longer delays to allow more
// coalescing.
return base::TimeDelta::FromMilliseconds(kSlowNudgeDelayMilliseconds);
case SHARING_MESSAGE:
return GetSharingMessageDelay(minimum_delay);
default:
return minimum_delay;
}
......
......@@ -870,6 +870,9 @@ TEST_F(NudgeTrackerTest, NoTypesShorterThanDefault) {
std::map<ModelType, base::TimeDelta> delay_map;
ModelTypeSet protocol_types = ProtocolTypes();
// Add exception for low-latency data type.
protocol_types.Remove(syncer::SHARING_MESSAGE);
for (ModelType type : protocol_types) {
delay_map[type] = base::TimeDelta();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment