Commit 69cdc4e9 authored by zea@chromium.org's avatar zea@chromium.org

[Sync] Add support for server-controlled favicon sync limit

This allows us to adjust the number of favicons clients will maintain
as we determine how well we handle them.

BUG=154886

Review URL: https://chromiumcodereview.appspot.com/14117004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195074 0039d316-1c4b-4281-b951-d872f2087c98
parent 33c8f35c
......@@ -225,6 +225,7 @@ FaviconCache::FaviconCache(Profile* profile, int max_sync_favicon_limit)
notification_registrar_.Add(this,
chrome::NOTIFICATION_HISTORY_URLS_DELETED,
content::Source<Profile>(profile_));
DVLOG(1) << "Setting favicon limit to " << max_sync_favicon_limit;
}
FaviconCache::~FaviconCache() {}
......
......@@ -103,7 +103,8 @@ SessionModelAssociator::SessionModelAssociator(
ALLOW_THIS_IN_INITIALIZER_LIST(test_weak_factory_(this)),
profile_(sync_service->profile()),
error_handler_(error_handler),
favicon_cache_(profile_, kMaxSyncFavicons) {
favicon_cache_(profile_,
sync_service->current_experiments().favicon_sync_limit) {
DCHECK(CalledOnValidThread());
DCHECK(sync_service_);
DCHECK(profile_);
......
......@@ -22,13 +22,15 @@ struct Experiments {
Experiments() : keystore_encryption(false),
autofill_culling(false),
full_history_sync(false),
favicon_sync(false) {}
favicon_sync(false),
favicon_sync_limit(200) {}
bool Matches(const Experiments& rhs) {
return (keystore_encryption == rhs.keystore_encryption &&
autofill_culling == rhs.autofill_culling &&
full_history_sync == rhs.full_history_sync &&
favicon_sync == rhs.favicon_sync);
favicon_sync == rhs.favicon_sync &&
favicon_sync_limit == rhs.favicon_sync_limit);
}
// Enable keystore encryption logic and the new encryption UI.
......@@ -42,6 +44,9 @@ struct Experiments {
// Enable the favicons sync datatypes (favicon images and favicon tracking).
bool favicon_sync;
// The number of favicons that a client is permitted to sync.
int favicon_sync_limit;
};
} // namespace syncer
......
......@@ -1379,9 +1379,12 @@ bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) {
ReadNode favicon_sync_node(&trans);
if (favicon_sync_node.InitByClientTagLookup(
syncer::EXPERIMENTS,
syncer::kFaviconSyncTag) == BaseNode::INIT_OK &&
favicon_sync_node.GetExperimentsSpecifics().favicon_sync().enabled()) {
experiments->favicon_sync = true;
syncer::kFaviconSyncTag) == BaseNode::INIT_OK) {
experiments->favicon_sync = favicon_sync_node.GetExperimentsSpecifics().
favicon_sync().enabled();
experiments->favicon_sync_limit =
favicon_sync_node.GetExperimentsSpecifics().favicon_sync().
favicon_sync_limit();
found_experiment = true;
}
......
......@@ -27,9 +27,11 @@ message AutofillCullingFlags {
optional bool enabled = 1;
}
// Whether the favicon sync datatypes are enabled.
// Whether the favicon sync datatypes are enabled, and what parameters
// they should operate under.
message FaviconSyncFlags {
optional bool enabled = 1;
optional int32 favicon_sync_limit = 2 [default = 200];
}
// Contains one flag or set of related flags. Each node of the experiments type
......
......@@ -332,13 +332,26 @@ base::DictionaryValue* DictionarySpecificsToValue(
return value;
}
namespace {
DictionaryValue* FaviconSyncFlagsToValue(
const sync_pb::FaviconSyncFlags& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET_BOOL(enabled);
SET_INT32(favicon_sync_limit);
return value;
}
}
base::DictionaryValue* ExperimentsSpecificsToValue(
const sync_pb::ExperimentsSpecifics& proto) {
base::DictionaryValue* value = new base::DictionaryValue();
SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption);
SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives);
SET_EXPERIMENT_ENABLED_FIELD(autofill_culling);
SET_EXPERIMENT_ENABLED_FIELD(favicon_sync);
if (proto.has_favicon_sync())
SET(favicon_sync, FaviconSyncFlagsToValue);
return value;
}
......
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