summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/engine/apply_updates_command.cc28
-rw-r--r--chrome/browser/sync/engine/store_timestamps_command.cc11
-rw-r--r--chrome/browser/sync/engine/sync_scheduler.cc13
-rw-r--r--chrome/browser/sync/engine/sync_scheduler_unittest.cc38
-rw-r--r--chrome/browser/sync/engine/syncer_unittest.cc4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc14
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h2
-rw-r--r--chrome/browser/sync/internal_api/sync_manager.cc40
-rw-r--r--chrome/browser/sync/internal_api/sync_manager.h4
-rw-r--r--chrome/browser/sync/profile_sync_service.cc12
-rw-r--r--chrome/browser/sync/sync_prefs.cc28
-rw-r--r--chrome/browser/sync/syncable/model_type.cc62
-rw-r--r--chrome/browser/sync/syncable/model_type.h19
-rw-r--r--chrome/browser/sync/syncable/model_type_unittest.cc27
-rw-r--r--chrome/browser/sync/syncable/syncable.cc20
-rw-r--r--chrome/browser/sync/syncable/syncable.h4
-rw-r--r--chrome/browser/sync/syncable/syncable_unittest.cc4
17 files changed, 113 insertions, 217 deletions
diff --git a/chrome/browser/sync/engine/apply_updates_command.cc b/chrome/browser/sync/engine/apply_updates_command.cc
index a95f75f..2acd63b 100644
--- a/chrome/browser/sync/engine/apply_updates_command.cc
+++ b/chrome/browser/sync/engine/apply_updates_command.cc
@@ -25,7 +25,7 @@ std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange(
const sessions::SyncSession& session) const {
std::set<ModelSafeGroup> groups_with_unapplied_updates;
- syncable::ModelTypeBitSet server_types_with_unapplied_updates;
+ syncable::FullModelEnumSet server_types_with_unapplied_updates;
{
syncable::ScopedDirLookup dir(session.context()->directory_manager(),
session.context()->account_name());
@@ -39,12 +39,10 @@ std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange(
dir->GetServerTypesWithUnappliedUpdates(&trans);
}
- for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
- const syncable::ModelType type = syncable::ModelTypeFromInt(i);
- if (server_types_with_unapplied_updates.test(type)) {
- groups_with_unapplied_updates.insert(
- GetGroupForModelType(type, session.routing_info()));
- }
+ for (syncable::FullModelEnumSet::Iterator it =
+ server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
+ groups_with_unapplied_updates.insert(
+ GetGroupForModelType(it.Get(), session.routing_info()));
}
return groups_with_unapplied_updates;
@@ -62,16 +60,14 @@ void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) {
// Compute server types with unapplied updates that fall under our
// group restriction.
- const syncable::ModelTypeBitSet server_types_with_unapplied_updates =
+ const syncable::FullModelEnumSet server_types_with_unapplied_updates =
dir->GetServerTypesWithUnappliedUpdates(&trans);
- syncable::ModelTypeBitSet server_type_restriction;
- for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) {
- const syncable::ModelType server_type = syncable::ModelTypeFromInt(i);
- if (server_types_with_unapplied_updates.test(server_type)) {
- if (GetGroupForModelType(server_type, session->routing_info()) ==
- session->status_controller().group_restriction()) {
- server_type_restriction.set(server_type);
- }
+ syncable::FullModelEnumSet server_type_restriction;
+ for (syncable::FullModelEnumSet::Iterator it =
+ server_types_with_unapplied_updates.First(); it.Good(); it.Inc()) {
+ if (GetGroupForModelType(it.Get(), session->routing_info()) ==
+ session->status_controller().group_restriction()) {
+ server_type_restriction.Put(it.Get());
}
}
diff --git a/chrome/browser/sync/engine/store_timestamps_command.cc b/chrome/browser/sync/engine/store_timestamps_command.cc
index 1fe0ebf..345f039 100644
--- a/chrome/browser/sync/engine/store_timestamps_command.cc
+++ b/chrome/browser/sync/engine/store_timestamps_command.cc
@@ -32,7 +32,7 @@ void StoreTimestampsCommand::ExecuteImpl(sessions::SyncSession* session) {
// Update the progress marker tokens from the server result. If a marker
// was omitted for any one type, that indicates no change from the previous
// state.
- syncable::ModelTypeBitSet forward_progress_types;
+ syncable::ModelEnumSet forward_progress_types;
for (int i = 0; i < updates.new_progress_marker_size(); ++i) {
syncable::ModelType model =
syncable::GetModelTypeFromExtensionFieldNumber(
@@ -41,15 +41,16 @@ void StoreTimestampsCommand::ExecuteImpl(sessions::SyncSession* session) {
NOTREACHED() << "Unintelligible server response.";
continue;
}
- forward_progress_types[model] = true;
+ forward_progress_types.Put(model);
dir->SetDownloadProgress(model, updates.new_progress_marker(i));
}
- DCHECK(forward_progress_types.any() ||
+ DCHECK(!forward_progress_types.Empty() ||
updates.changes_remaining() == 0);
if (VLOG_IS_ON(1)) {
- DVLOG_IF(1, forward_progress_types.any())
+ DVLOG_IF(1, !forward_progress_types.Empty())
<< "Get Updates got new progress marker for types: "
- << forward_progress_types.to_string() << " out of possible: "
+ << syncable::ModelEnumSetToString(forward_progress_types)
+ << " out of possible: "
<< syncable::ModelEnumSetToString(status->updates_request_types());
}
if (updates.has_changes_remaining()) {
diff --git a/chrome/browser/sync/engine/sync_scheduler.cc b/chrome/browser/sync/engine/sync_scheduler.cc
index 138abb8..2af0ba3 100644
--- a/chrome/browser/sync/engine/sync_scheduler.cc
+++ b/chrome/browser/sync/engine/sync_scheduler.cc
@@ -26,8 +26,9 @@ namespace browser_sync {
using sessions::SyncSession;
using sessions::SyncSessionSnapshot;
using sessions::SyncSourceInfo;
+using syncable::ModelEnumSet;
+using syncable::ModelEnumSetToString;
using syncable::ModelTypePayloadMap;
-using syncable::ModelTypeBitSet;
using sync_pb::GetUpdatesCallerInfo;
namespace {
@@ -459,13 +460,13 @@ void SyncScheduler::ScheduleCleanupDisabledTypes() {
void SyncScheduler::ScheduleNudge(
const TimeDelta& delay,
- NudgeSource source, syncable::ModelEnumSet types,
+ NudgeSource source, ModelEnumSet types,
const tracked_objects::Location& nudge_location) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
SDVLOG_LOC(nudge_location, 2)
<< "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
<< "source " << GetNudgeSourceString(source) << ", "
- << "types " << syncable::ModelEnumSetToString(types);
+ << "types " << ModelEnumSetToString(types);
ModelTypePayloadMap types_with_payloads =
syncable::ModelTypePayloadMapFromEnumSet(types, std::string());
@@ -562,7 +563,7 @@ void SyncScheduler::ScheduleNudgeImpl(
// Helper to extract the routing info and workers corresponding to types in
// |types| from |registrar|.
-void GetModelSafeParamsForTypes(syncable::ModelEnumSet types,
+void GetModelSafeParamsForTypes(ModelEnumSet types,
ModelSafeWorkerRegistrar* registrar, ModelSafeRoutingInfo* routes,
std::vector<ModelSafeWorker*>* workers) {
ModelSafeRoutingInfo r_tmp;
@@ -573,7 +574,7 @@ void GetModelSafeParamsForTypes(syncable::ModelEnumSet types,
bool passive_group_added = false;
typedef std::vector<ModelSafeWorker*>::const_iterator iter;
- for (syncable::ModelEnumSet::Iterator it = types.First();
+ for (ModelEnumSet::Iterator it = types.First();
it.Good(); it.Inc()) {
const syncable::ModelType t = it.Get();
DCHECK_EQ(1U, r_tmp.count(t));
@@ -605,7 +606,7 @@ void GetModelSafeParamsForTypes(syncable::ModelEnumSet types,
}
void SyncScheduler::ScheduleConfig(
- syncable::ModelEnumSet types,
+ ModelEnumSet types,
GetUpdatesCallerInfo::GetUpdatesSource source) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
DCHECK(IsConfigRelatedUpdateSourceValue(source));
diff --git a/chrome/browser/sync/engine/sync_scheduler_unittest.cc b/chrome/browser/sync/engine/sync_scheduler_unittest.cc
index 3157b9d..672aa63 100644
--- a/chrome/browser/sync/engine/sync_scheduler_unittest.cc
+++ b/chrome/browser/sync/engine/sync_scheduler_unittest.cc
@@ -32,7 +32,7 @@ namespace browser_sync {
using sessions::SyncSession;
using sessions::SyncSessionContext;
using sessions::SyncSessionSnapshot;
-using syncable::ModelTypeBitSet;
+using syncable::ModelEnumSet;
using sync_pb::GetUpdatesCallerInfo;
class MockSyncer : public Syncer {
@@ -150,7 +150,7 @@ class SyncSchedulerTest : public testing::Test {
}
bool GetBackoffAndResetTest() {
- syncable::ModelEnumSet nudge_types;
+ ModelEnumSet nudge_types;
StartSyncScheduler(SyncScheduler::NORMAL_MODE);
RunLoop();
@@ -181,7 +181,7 @@ class SyncSchedulerTest : public testing::Test {
// Compare a ModelEnumSet to a ModelTypePayloadMap, ignoring
// payload values.
bool CompareModelEnumSetToModelTypePayloadMap(
- syncable::ModelEnumSet lhs,
+ ModelEnumSet lhs,
const syncable::ModelTypePayloadMap& rhs) {
size_t count = 0;
for (syncable::ModelTypePayloadMap::const_iterator i = rhs.begin();
@@ -239,7 +239,7 @@ ACTION(QuitLoopNowAction) {
// Test nudge scheduling.
TEST_F(SyncSchedulerTest, Nudge) {
SyncShareRecords records;
- syncable::ModelEnumSet model_types(syncable::BOOKMARKS);
+ ModelEnumSet model_types(syncable::BOOKMARKS);
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
@@ -283,7 +283,7 @@ TEST_F(SyncSchedulerTest, Nudge) {
// errors.
TEST_F(SyncSchedulerTest, Config) {
SyncShareRecords records;
- const syncable::ModelEnumSet model_types(syncable::BOOKMARKS);
+ const ModelEnumSet model_types(syncable::BOOKMARKS);
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
@@ -309,7 +309,7 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
EXPECT_CALL(*delay(), GetDelay(_))
.WillRepeatedly(Return(TimeDelta::FromMilliseconds(1)));
SyncShareRecords records;
- const syncable::ModelEnumSet model_types(syncable::BOOKMARKS);
+ const ModelEnumSet model_types(syncable::BOOKMARKS);
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateCommitFailed),
@@ -338,7 +338,7 @@ TEST_F(SyncSchedulerTest, ConfigWithBackingOff) {
// Issue 2 config commands. Second one right after the first has failed
// and make sure LATEST is executed.
TEST_F(SyncSchedulerTest, MultipleConfigWithBackingOff) {
- const syncable::ModelEnumSet
+ const ModelEnumSet
model_types1(syncable::BOOKMARKS),
model_types2(syncable::AUTOFILL);
UseMockDelayProvider();
@@ -380,7 +380,7 @@ TEST_F(SyncSchedulerTest, MultipleConfigWithBackingOff) {
// Issue a nudge when the config has failed. Make sure both the config and
// nudge are executed.
TEST_F(SyncSchedulerTest, NudgeWithConfigWithBackingOff) {
- const syncable::ModelEnumSet model_types(syncable::BOOKMARKS);
+ const ModelEnumSet model_types(syncable::BOOKMARKS);
UseMockDelayProvider();
EXPECT_CALL(*delay(), GetDelay(_))
.WillRepeatedly(Return(TimeDelta::FromMilliseconds(50)));
@@ -440,7 +440,7 @@ TEST_F(SyncSchedulerTest, NudgeCoalescing) {
EXPECT_CALL(*syncer(), SyncShare(_,_,_))
.WillOnce(DoAll(Invoke(sessions::test_util::SimulateSuccess),
WithArg<0>(RecordSyncShare(&r))));
- const syncable::ModelEnumSet
+ const ModelEnumSet
types1(syncable::BOOKMARKS),
types2(syncable::AUTOFILL),
types3(syncable::THEMES);
@@ -652,7 +652,7 @@ TEST_F(SyncSchedulerTest, SessionsCommitDelay) {
RunLoop();
EXPECT_EQ(delay1, scheduler()->sessions_commit_delay());
- const syncable::ModelEnumSet model_types(syncable::BOOKMARKS);
+ const ModelEnumSet model_types(syncable::BOOKMARKS);
scheduler()->ScheduleNudge(
zero(), NUDGE_SOURCE_LOCAL, model_types, FROM_HERE);
RunLoop();
@@ -671,7 +671,7 @@ TEST_F(SyncSchedulerTest, HasMoreToSync) {
RunLoop();
scheduler()->ScheduleNudge(
- zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE);
+ zero(), NUDGE_SOURCE_LOCAL, ModelEnumSet(), FROM_HERE);
RunLoop();
// If more nudges are scheduled, they'll be waited on by TearDown, and would
// cause our expectation to break.
@@ -679,7 +679,7 @@ TEST_F(SyncSchedulerTest, HasMoreToSync) {
// Test that no syncing occurs when throttled.
TEST_F(SyncSchedulerTest, ThrottlingDoesThrottle) {
- const syncable::ModelEnumSet types(syncable::BOOKMARKS);
+ const ModelEnumSet types(syncable::BOOKMARKS);
TimeDelta poll(TimeDelta::FromMilliseconds(5));
TimeDelta throttle(TimeDelta::FromMinutes(10));
scheduler()->OnReceivedLongPollIntervalUpdate(poll);
@@ -740,13 +740,13 @@ TEST_F(SyncSchedulerTest, ConfigurationMode) {
StartSyncScheduler(SyncScheduler::CONFIGURATION_MODE);
RunLoop();
- const syncable::ModelEnumSet nudge_types(syncable::AUTOFILL);
+ const ModelEnumSet nudge_types(syncable::AUTOFILL);
scheduler()->ScheduleNudge(
zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE);
scheduler()->ScheduleNudge(
zero(), NUDGE_SOURCE_LOCAL, nudge_types, FROM_HERE);
- const syncable::ModelEnumSet config_types(syncable::BOOKMARKS);
+ const ModelEnumSet config_types(syncable::BOOKMARKS);
scheduler()->ScheduleConfig(
config_types, GetUpdatesCallerInfo::RECONFIGURATION);
@@ -801,7 +801,7 @@ TEST_F(SyncSchedulerTest, BackoffTriggers) {
TEST_F(SyncSchedulerTest, BackoffDropsJobs) {
SyncShareRecords r;
TimeDelta poll(TimeDelta::FromMilliseconds(5));
- const syncable::ModelEnumSet types(syncable::BOOKMARKS);
+ const ModelEnumSet types(syncable::BOOKMARKS);
scheduler()->OnReceivedLongPollIntervalUpdate(poll);
UseMockDelayProvider();
@@ -965,7 +965,7 @@ TEST_F(SyncSchedulerTest, SyncerSteps) {
RunLoop();
scheduler()->ScheduleNudge(
- zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE);
+ zero(), NUDGE_SOURCE_LOCAL, ModelEnumSet(), FROM_HERE);
PumpLoop();
// Pump again to run job.
PumpLoop();
@@ -992,7 +992,7 @@ TEST_F(SyncSchedulerTest, SyncerSteps) {
RunLoop();
scheduler()->ScheduleConfig(
- syncable::ModelEnumSet(), GetUpdatesCallerInfo::RECONFIGURATION);
+ ModelEnumSet(), GetUpdatesCallerInfo::RECONFIGURATION);
PumpLoop();
PumpLoop();
@@ -1044,7 +1044,7 @@ TEST_F(SyncSchedulerTest, StartWhenNotConnected) {
RunLoop();
scheduler()->ScheduleNudge(
- zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE);
+ zero(), NUDGE_SOURCE_LOCAL, ModelEnumSet(), FROM_HERE);
// Should save the nudge for until after the server is reachable.
PumpLoop();
@@ -1064,7 +1064,7 @@ TEST_F(SyncSchedulerTest, SetsPreviousRoutingInfo) {
RunLoop();
scheduler()->ScheduleNudge(
- zero(), NUDGE_SOURCE_LOCAL, syncable::ModelEnumSet(), FROM_HERE);
+ zero(), NUDGE_SOURCE_LOCAL, ModelEnumSet(), FROM_HERE);
PumpLoop();
// Pump again to run job.
PumpLoop();
diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc
index b2e718e..d511beb 100644
--- a/chrome/browser/sync/engine/syncer_unittest.cc
+++ b/chrome/browser/sync/engine/syncer_unittest.cc
@@ -2157,8 +2157,8 @@ TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) {
}
TEST_F(SyncerTest, ParentAndChildBothMatch) {
- syncable::ModelTypeBitSet all_types;
- all_types.set();
+ const syncable::FullModelEnumSet all_types =
+ syncable::FullModelEnumSet::All();
ScopedDirLookup dir(syncdb_.manager(), syncdb_.name());
CHECK(dir.good());
syncable::Id parent_id = ids_.NewServerId();
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index ae90c19..d2f86d0 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -684,7 +684,7 @@ void SyncBackendHost::Core::DoShutdown(bool sync_disabled) {
}
void SyncBackendHost::Core::DoRequestConfig(
- const syncable::ModelTypeBitSet& types_to_config,
+ syncable::ModelEnumSet types_to_config,
sync_api::ConfigureReason reason) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
sync_manager_->RequestConfig(types_to_config, reason);
@@ -1011,22 +1011,24 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() {
pending_download_state_.reset(pending_config_mode_state_.release());
// Always configure nigori if it's enabled.
- syncable::ModelTypeSet types_to_config =
- pending_download_state_->added_types;
+ syncable::ModelEnumSet types_to_config =
+ syncable::ModelTypeSetToEnumSet(
+ pending_download_state_->added_types);
if (IsNigoriEnabled()) {
// Note: Nigori is the only type that gets added with a nonempty
// progress marker during config. If the server returns a migration
// error then we will go into unrecoverable error. We dont handle it
// explicitly because server might help us out here by not sending a
// migraiton error for nigori during config.
- types_to_config.insert(syncable::NIGORI);
+ types_to_config.Put(syncable::NIGORI);
}
- SVLOG(1) << "Types " << ModelTypeSetToString(types_to_config)
+ SVLOG(1) << "Types "
+ << syncable::ModelEnumSetToString(types_to_config)
<< " added; calling DoRequestConfig";
sync_thread_.message_loop()->PostTask(FROM_HERE,
base::Bind(&SyncBackendHost::Core::DoRequestConfig,
core_.get(),
- syncable::ModelTypeBitSetFromSet(types_to_config),
+ types_to_config,
pending_download_state_->reason));
}
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 3d4be77..80dfa87 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -386,7 +386,7 @@ class SyncBackendHost {
void DoShutdown(bool stopping_sync);
virtual void DoRequestConfig(
- const syncable::ModelTypeBitSet& types_to_config,
+ syncable::ModelEnumSet types_to_config,
sync_api::ConfigureReason reason);
// Start the configuration mode. |callback| is called on the sync
diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc
index 7b08b65..bc084d5 100644
--- a/chrome/browser/sync/internal_api/sync_manager.cc
+++ b/chrome/browser/sync/internal_api/sync_manager.cc
@@ -78,7 +78,7 @@ using browser_sync::sessions::SyncSessionContext;
using syncable::DirectoryManager;
using syncable::ImmutableWriteTransactionInfo;
using syncable::ModelType;
-using syncable::ModelTypeBitSet;
+using syncable::ModelEnumSet;
using syncable::SPECIFICS;
using sync_pb::GetUpdatesCallerInfo;
@@ -207,7 +207,7 @@ class SyncManager::SyncInternal
// Conditionally sets the flag in the Nigori node which instructs other
// clients to start syncing tabs.
- void MaybeSetSyncTabsInNigoriNode(syncable::ModelEnumSet enabled_types);
+ void MaybeSetSyncTabsInNigoriNode(ModelEnumSet enabled_types);
// Tell the sync engine to start the syncing process.
void StartSyncingNormally();
@@ -243,8 +243,8 @@ class SyncManager::SyncInternal
// builds the list of sync-engine initiated changes that will be forwarded to
// the SyncManager's Observers.
virtual void HandleTransactionCompleteChangeEvent(
- syncable::ModelEnumSet models_with_changes) OVERRIDE;
- virtual syncable::ModelEnumSet HandleTransactionEndingChangeEvent(
+ ModelEnumSet models_with_changes) OVERRIDE;
+ virtual ModelEnumSet HandleTransactionEndingChangeEvent(
const ImmutableWriteTransactionInfo& write_transaction_info,
syncable::BaseTransaction* trans) OVERRIDE;
virtual void HandleCalculateChangesChangeEventFromSyncApi(
@@ -642,7 +642,7 @@ void SyncManager::UpdateEnabledTypes() {
}
void SyncManager::MaybeSetSyncTabsInNigoriNode(
- syncable::ModelEnumSet enabled_types) {
+ ModelEnumSet enabled_types) {
DCHECK(thread_checker_.CalledOnValidThread());
data_->MaybeSetSyncTabsInNigoriNode(enabled_types);
}
@@ -701,8 +701,8 @@ void SyncManager::RequestClearServerData() {
data_->scheduler()->ScheduleClearUserData();
}
-void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types,
- ConfigureReason reason) {
+void SyncManager::RequestConfig(
+ ModelEnumSet types, ConfigureReason reason) {
DCHECK(thread_checker_.CalledOnValidThread());
if (!data_->scheduler()) {
LOG(INFO)
@@ -711,9 +711,7 @@ void SyncManager::RequestConfig(const syncable::ModelTypeBitSet& types,
return;
}
StartConfigurationMode(base::Closure());
- data_->scheduler()->ScheduleConfig(
- syncable::ModelTypeBitSetToEnumSet(types),
- GetSourceFromReason(reason));
+ data_->scheduler()->ScheduleConfig(types, GetSourceFromReason(reason));
}
void SyncManager::StartConfigurationMode(const base::Closure& callback) {
@@ -967,7 +965,7 @@ void SyncManager::SyncInternal::UpdateEnabledTypes() {
DCHECK(thread_checker_.CalledOnValidThread());
ModelSafeRoutingInfo routes;
registrar_->GetModelSafeRoutingInfo(&routes);
- const syncable::ModelEnumSet enabled_types = GetRoutingInfoTypes(routes);
+ const ModelEnumSet enabled_types = GetRoutingInfoTypes(routes);
sync_notifier_->UpdateEnabledTypes(enabled_types);
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSyncTabsForOtherClients)) {
@@ -976,7 +974,7 @@ void SyncManager::SyncInternal::UpdateEnabledTypes() {
}
void SyncManager::SyncInternal::MaybeSetSyncTabsInNigoriNode(
- const syncable::ModelEnumSet enabled_types) {
+ const ModelEnumSet enabled_types) {
// The initialized_ check is to ensure that we don't CHECK in GetUserShare
// when this is called on start-up. It's ok to ignore that case, since
// presumably this would've run when the user originally enabled sessions.
@@ -1351,7 +1349,7 @@ void SyncManager::SyncInternal::OnServerConnectionEvent(
}
void SyncManager::SyncInternal::HandleTransactionCompleteChangeEvent(
- syncable::ModelEnumSet models_with_changes) {
+ ModelEnumSet models_with_changes) {
// This notification happens immediately after the transaction mutex is
// released. This allows work to be performed without blocking other threads
// from acquiring a transaction.
@@ -1359,7 +1357,7 @@ void SyncManager::SyncInternal::HandleTransactionCompleteChangeEvent(
return;
// Call commit.
- for (syncable::ModelEnumSet::Iterator it = models_with_changes.First();
+ for (ModelEnumSet::Iterator it = models_with_changes.First();
it.Good(); it.Inc()) {
change_delegate_->OnChangesComplete(it.Get());
change_observer_.Call(
@@ -1367,7 +1365,7 @@ void SyncManager::SyncInternal::HandleTransactionCompleteChangeEvent(
}
}
-syncable::ModelEnumSet
+ModelEnumSet
SyncManager::SyncInternal::HandleTransactionEndingChangeEvent(
const ImmutableWriteTransactionInfo& write_transaction_info,
syncable::BaseTransaction* trans) {
@@ -1375,7 +1373,7 @@ syncable::ModelEnumSet
// falls out of scope. It happens while the channel mutex is still held,
// and while the transaction mutex is held, so it cannot be re-entrant.
if (!change_delegate_ || ChangeBuffersAreEmpty())
- return syncable::ModelEnumSet();
+ return ModelEnumSet();
// This will continue the WriteTransaction using a read only wrapper.
// This is the last chance for read to occur in the WriteTransaction
@@ -1383,7 +1381,7 @@ syncable::ModelEnumSet
// underlying transaction.
ReadTransaction read_trans(GetUserShare(), trans);
- syncable::ModelEnumSet models_with_changes;
+ ModelEnumSet models_with_changes;
for (int i = syncable::FIRST_REAL_MODEL_TYPE;
i < syncable::MODEL_TYPE_COUNT; ++i) {
const syncable::ModelType type = syncable::ModelTypeFromInt(i);
@@ -1538,7 +1536,7 @@ void SyncManager::SyncInternal::RequestNudge(
if (scheduler())
scheduler()->ScheduleNudge(
TimeDelta::FromMilliseconds(0), browser_sync::NUDGE_SOURCE_LOCAL,
- syncable::ModelEnumSet(), location);
+ ModelEnumSet(), location);
}
void SyncManager::SyncInternal::RequestNudgeForDataType(
@@ -1564,7 +1562,7 @@ void SyncManager::SyncInternal::RequestNudgeForDataType(
}
scheduler()->ScheduleNudge(nudge_delay,
browser_sync::NUDGE_SOURCE_LOCAL,
- syncable::ModelEnumSet(type),
+ ModelEnumSet(type),
nudge_location);
}
@@ -1626,7 +1624,7 @@ void SyncManager::SyncInternal::OnSyncEngineEvent(
if (is_notifiable_commit) {
allstatus_.IncrementNotifiableCommits();
if (sync_notifier_.get()) {
- const syncable::ModelEnumSet changed_types =
+ const ModelEnumSet changed_types =
syncable::ModelTypePayloadMapToEnumSet(
event.snapshot->source.types);
sync_notifier_->SendNotification(changed_types);
@@ -2015,7 +2013,7 @@ void SyncManager::TriggerOnNotificationStateChangeForTest(
}
void SyncManager::TriggerOnIncomingNotificationForTest(
- syncable::ModelEnumSet model_types) {
+ ModelEnumSet model_types) {
DCHECK(thread_checker_.CalledOnValidThread());
syncable::ModelTypePayloadMap model_types_with_payloads =
syncable::ModelTypePayloadMapFromEnumSet(model_types,
diff --git a/chrome/browser/sync/internal_api/sync_manager.h b/chrome/browser/sync/internal_api/sync_manager.h
index 0e2788b..138ec92 100644
--- a/chrome/browser/sync/internal_api/sync_manager.h
+++ b/chrome/browser/sync/internal_api/sync_manager.h
@@ -483,8 +483,8 @@ class SyncManager {
// Switches the mode of operation to CONFIGURATION_MODE and
// schedules a config task to fetch updates for |types|.
- void RequestConfig(const syncable::ModelTypeBitSet& types,
- sync_api::ConfigureReason reason);
+ void RequestConfig(syncable::ModelEnumSet types,
+ sync_api::ConfigureReason reason);
void RequestCleanupDisabledTypes();
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 1cef47f..3506401 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -345,12 +345,14 @@ bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
GetPreferredDataTypes(&preferred_types);
syncable::ModelTypeSet encrypted_types;
GetEncryptedDataTypes(&encrypted_types);
- syncable::ModelTypeBitSet preferred_types_bitset =
- syncable::ModelTypeBitSetFromSet(preferred_types);
- syncable::ModelTypeBitSet encrypted_types_bitset =
- syncable::ModelTypeBitSetFromSet(encrypted_types);
+ const syncable::ModelEnumSet preferred_types_enum_set =
+ syncable::ModelTypeSetToEnumSet(preferred_types);
+ const syncable::ModelEnumSet encrypted_types_enum_set =
+ syncable::ModelTypeSetToEnumSet(encrypted_types);
DCHECK(encrypted_types.count(syncable::PASSWORDS));
- return (preferred_types_bitset & encrypted_types_bitset).any();
+ return
+ !Intersection(preferred_types_enum_set,
+ encrypted_types_enum_set).Empty();
}
void ProfileSyncService::OnSyncConfigureDone(
diff --git a/chrome/browser/sync/sync_prefs.cc b/chrome/browser/sync/sync_prefs.cc
index 1e27f4a..e013bda 100644
--- a/chrome/browser/sync/sync_prefs.cc
+++ b/chrome/browser/sync/sync_prefs.cc
@@ -468,21 +468,21 @@ void SyncPrefs::RegisterPreferences() {
// We will start prompting people about new data types after the launch of
// SESSIONS - all previously launched data types are treated as if they are
// already acknowledged.
- syncable::ModelTypeBitSet model_set;
- model_set.set(syncable::BOOKMARKS);
- model_set.set(syncable::PREFERENCES);
- model_set.set(syncable::PASSWORDS);
- model_set.set(syncable::AUTOFILL_PROFILE);
- model_set.set(syncable::AUTOFILL);
- model_set.set(syncable::THEMES);
- model_set.set(syncable::EXTENSIONS);
- model_set.set(syncable::NIGORI);
- model_set.set(syncable::SEARCH_ENGINES);
- model_set.set(syncable::APPS);
- model_set.set(syncable::TYPED_URLS);
- model_set.set(syncable::SESSIONS);
+ syncable::ModelEnumSet model_set;
+ model_set.Put(syncable::BOOKMARKS);
+ model_set.Put(syncable::PREFERENCES);
+ model_set.Put(syncable::PASSWORDS);
+ model_set.Put(syncable::AUTOFILL_PROFILE);
+ model_set.Put(syncable::AUTOFILL);
+ model_set.Put(syncable::THEMES);
+ model_set.Put(syncable::EXTENSIONS);
+ model_set.Put(syncable::NIGORI);
+ model_set.Put(syncable::SEARCH_ENGINES);
+ model_set.Put(syncable::APPS);
+ model_set.Put(syncable::TYPED_URLS);
+ model_set.Put(syncable::SESSIONS);
pref_service_->RegisterListPref(prefs::kSyncAcknowledgedSyncTypes,
- syncable::ModelTypeBitSetToValue(model_set),
+ syncable::ModelEnumSetToValue(model_set),
PrefService::UNSYNCABLE_PREF);
pref_service_->RegisterDictionaryPref(prefs::kSyncMaxInvalidationVersions,
diff --git a/chrome/browser/sync/syncable/model_type.cc b/chrome/browser/sync/syncable/model_type.cc
index 48b923e..b7e147c 100644
--- a/chrome/browser/sync/syncable/model_type.cc
+++ b/chrome/browser/sync/syncable/model_type.cc
@@ -350,19 +350,6 @@ ModelType ModelTypeFromString(const std::string& model_type_string) {
return UNSPECIFIED;
}
-std::string ModelTypeBitSetToString(const ModelTypeBitSet& model_types) {
- std::string result;
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- if (model_types[i]) {
- if (!result.empty()) {
- result += ", ";
- }
- result += ModelTypeToString(ModelTypeFromInt(i));
- }
- }
- return result;
-}
-
std::string ModelEnumSetToString(ModelEnumSet model_types) {
std::string result;
for (ModelEnumSet::Iterator it = model_types.First(); it.Good(); it.Inc()) {
@@ -374,36 +361,6 @@ std::string ModelEnumSetToString(ModelEnumSet model_types) {
return result;
}
-ModelTypeBitSet ModelTypeBitSetFromSet(const ModelTypeSet& set) {
- ModelTypeBitSet bitset;
- for (ModelTypeSet::const_iterator iter = set.begin(); iter != set.end();
- ++iter) {
- bitset.set(*iter);
- }
- return bitset;
-}
-
-ModelTypeSet ModelTypeBitSetToSet(const ModelTypeBitSet& bit_set) {
- ModelTypeSet set;
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- syncable::ModelType type = syncable::ModelTypeFromInt(i);
- if (bit_set[type]) {
- set.insert(type);
- }
- }
- return set;
-}
-
-ModelEnumSet ModelTypeBitSetToEnumSet(const ModelTypeBitSet& bitset) {
- ModelEnumSet enum_set;
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- if (bitset[i]) {
- enum_set.Put(syncable::ModelTypeFromInt(i));
- }
- }
- return enum_set;
-}
-
ModelTypeSet ModelEnumSetToSet(ModelEnumSet enum_set) {
ModelTypeSet model_type_set;
for (ModelEnumSet::Iterator it = enum_set.First(); it.Good(); it.Inc()) {
@@ -421,17 +378,6 @@ ModelEnumSet ModelTypeSetToEnumSet(const ModelTypeSet& model_type_set) {
return enum_set;
}
-ListValue* ModelTypeBitSetToValue(const ModelTypeBitSet& model_types) {
- ListValue* value = new ListValue();
- for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
- if (model_types[i]) {
- value->Append(
- Value::CreateStringValue(ModelTypeToString(ModelTypeFromInt(i))));
- }
- }
- return value;
-}
-
base::ListValue* ModelEnumSetToValue(ModelEnumSet model_types) {
ListValue* value = new ListValue();
for (ModelEnumSet::Iterator it = model_types.First(); it.Good(); it.Inc()) {
@@ -441,14 +387,6 @@ base::ListValue* ModelEnumSetToValue(ModelEnumSet model_types) {
return value;
}
-ModelTypeBitSet ModelTypeBitSetFromValue(const base::ListValue& value) {
- ModelTypeBitSet result;
- for (ListValue::const_iterator i = value.begin(); i != value.end(); ++i) {
- result.set(ModelTypeFromValue(**i));
- }
- return result;
-}
-
ListValue* ModelTypeSetToValue(const ModelTypeSet& model_types) {
ListValue* value = new ListValue();
for (ModelTypeSet::const_iterator i = model_types.begin();
diff --git a/chrome/browser/sync/syncable/model_type.h b/chrome/browser/sync/syncable/model_type.h
index 97cb6cd..f31c377 100644
--- a/chrome/browser/sync/syncable/model_type.h
+++ b/chrome/browser/sync/syncable/model_type.h
@@ -10,7 +10,6 @@
#define CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_H_
#pragma once
-#include <bitset>
#include <set>
#include <string>
@@ -86,10 +85,11 @@ enum ModelType {
MODEL_TYPE_COUNT,
};
-typedef std::bitset<MODEL_TYPE_COUNT> ModelTypeBitSet;
typedef std::set<ModelType> ModelTypeSet;
typedef browser_sync::EnumSet<
ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE> ModelEnumSet;
+typedef browser_sync::EnumSet<
+ ModelType, UNSPECIFIED, LAST_REAL_MODEL_TYPE> FullModelEnumSet;
inline ModelType ModelTypeFromInt(int i) {
DCHECK_GE(i, 0);
@@ -142,30 +142,15 @@ std::string ModelTypeSetToString(const ModelTypeSet& model_types);
// Returns the ModelType corresponding to the name |model_type_string|.
ModelType ModelTypeFromString(const std::string& model_type_string);
-std::string ModelTypeBitSetToString(const ModelTypeBitSet& model_types);
-
std::string ModelEnumSetToString(ModelEnumSet model_types);
-// Convert a ModelTypeSet to a ModelTypeBitSet.
-ModelTypeBitSet ModelTypeBitSetFromSet(const ModelTypeSet& set);
-
-// Convert a ModelTypeBitSet to a ModelTypeSet.
-ModelTypeSet ModelTypeBitSetToSet(const ModelTypeBitSet& bit_set);
-
-ModelEnumSet ModelTypeBitSetToEnumSet(const ModelTypeBitSet& bitset);
-
ModelTypeSet ModelEnumSetToSet(ModelEnumSet enum_set);
ModelEnumSet ModelTypeSetToEnumSet(const ModelTypeSet& model_type_set);
// Caller takes ownership of returned list.
-base::ListValue* ModelTypeBitSetToValue(const ModelTypeBitSet& model_types);
-
-// Caller takes ownership of returned list.
base::ListValue* ModelEnumSetToValue(ModelEnumSet model_types);
-ModelTypeBitSet ModelTypeBitSetFromValue(const base::ListValue& value);
-
// Caller takes ownership of returned list.
base::ListValue* ModelTypeSetToValue(const ModelTypeSet& model_types);
diff --git a/chrome/browser/sync/syncable/model_type_unittest.cc b/chrome/browser/sync/syncable/model_type_unittest.cc
index 5b39a3cb..2db0ab9 100644
--- a/chrome/browser/sync/syncable/model_type_unittest.cc
+++ b/chrome/browser/sync/syncable/model_type_unittest.cc
@@ -38,33 +38,6 @@ TEST_F(ModelTypeTest, ModelTypeFromValue) {
}
}
-TEST_F(ModelTypeTest, ModelTypeBitSetToValue) {
- ModelTypeBitSet model_types;
- model_types.set(syncable::BOOKMARKS);
- model_types.set(syncable::APPS);
-
- scoped_ptr<ListValue> value(ModelTypeBitSetToValue(model_types));
- EXPECT_EQ(2u, value->GetSize());
- std::string types[2];
- EXPECT_TRUE(value->GetString(0, &types[0]));
- EXPECT_TRUE(value->GetString(1, &types[1]));
- EXPECT_EQ("Bookmarks", types[0]);
- EXPECT_EQ("Apps", types[1]);
-}
-
-TEST_F(ModelTypeTest, ModelTypeBitSetFromValue) {
- // Try empty set first.
- ModelTypeBitSet model_types;
- scoped_ptr<ListValue> value(ModelTypeBitSetToValue(model_types));
- EXPECT_EQ(model_types, ModelTypeBitSetFromValue(*value));
-
- // Now try with a few random types.
- model_types.set(syncable::BOOKMARKS);
- model_types.set(syncable::APPS);
- value.reset(ModelTypeBitSetToValue(model_types));
- EXPECT_EQ(model_types, ModelTypeBitSetFromValue(*value));
-}
-
TEST_F(ModelTypeTest, ModelTypeSetToValue) {
ModelTypeSet model_types;
model_types.insert(syncable::BOOKMARKS);
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 3c90757..f6889f5 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -1025,14 +1025,14 @@ int64 Directory::unsynced_entity_count() const {
return kernel_->unsynced_metahandles->size();
}
-syncable::ModelTypeBitSet
- Directory::GetServerTypesWithUnappliedUpdates(
- BaseTransaction* trans) const {
- syncable::ModelTypeBitSet server_types;
+FullModelEnumSet Directory::GetServerTypesWithUnappliedUpdates(
+ BaseTransaction* trans) const {
+ syncable::FullModelEnumSet server_types;
ScopedKernelLock lock(this);
- for (int i = 0; i < MODEL_TYPE_COUNT; ++i) {
- if (!kernel_->unapplied_update_metahandles[i].empty()) {
- server_types.set(i);
+ for (int i = UNSPECIFIED; i < MODEL_TYPE_COUNT; ++i) {
+ const ModelType type = ModelTypeFromInt(i);
+ if (!kernel_->unapplied_update_metahandles[type].empty()) {
+ server_types.Put(type);
}
}
return server_types;
@@ -1040,13 +1040,13 @@ syncable::ModelTypeBitSet
void Directory::GetUnappliedUpdateMetaHandles(
BaseTransaction* trans,
- syncable::ModelTypeBitSet server_types,
+ FullModelEnumSet server_types,
UnappliedUpdateMetaHandles* result) {
result->clear();
ScopedKernelLock lock(this);
- for (int i = 0; i < MODEL_TYPE_COUNT; ++i) {
+ for (int i = UNSPECIFIED; i < MODEL_TYPE_COUNT; ++i) {
const ModelType type = ModelTypeFromInt(i);
- if (server_types.test(type)) {
+ if (server_types.Has(type)) {
std::copy(kernel_->unapplied_update_metahandles[type].begin(),
kernel_->unapplied_update_metahandles[type].end(),
back_inserter(*result));
diff --git a/chrome/browser/sync/syncable/syncable.h b/chrome/browser/sync/syncable/syncable.h
index c699911..0f9fc84 100644
--- a/chrome/browser/sync/syncable/syncable.h
+++ b/chrome/browser/sync/syncable/syncable.h
@@ -971,14 +971,14 @@ class Directory {
// Returns all server types with unapplied updates. A subset of
// those types can then be passed into
// GetUnappliedUpdateMetaHandles() below.
- syncable::ModelTypeBitSet GetServerTypesWithUnappliedUpdates(
+ FullModelEnumSet GetServerTypesWithUnappliedUpdates(
BaseTransaction* trans) const;
// Get all the metahandles for unapplied updates for a given set of
// server types.
typedef std::vector<int64> UnappliedUpdateMetaHandles;
void GetUnappliedUpdateMetaHandles(BaseTransaction* trans,
- syncable::ModelTypeBitSet server_types,
+ FullModelEnumSet server_types,
UnappliedUpdateMetaHandles* result);
// Checks tree metadata consistency.
diff --git a/chrome/browser/sync/syncable/syncable_unittest.cc b/chrome/browser/sync/syncable/syncable_unittest.cc
index 6f4be5a..6348c7f 100644
--- a/chrome/browser/sync/syncable/syncable_unittest.cc
+++ b/chrome/browser/sync/syncable/syncable_unittest.cc
@@ -885,8 +885,8 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) {
TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) {
Directory::UnappliedUpdateMetaHandles handles;
int64 handle1, handle2;
- syncable::ModelTypeBitSet all_types;
- all_types.set();
+ const syncable::FullModelEnumSet all_types =
+ syncable::FullModelEnumSet::All();
{
WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());