Chromium Code Reviews| Index: sync/internal_api/sync_manager_impl.cc |
| diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc |
| index 107ed606e743b2bdbd91d550541e84f238a5b35f..d06cdf36f6746c1bfc8b5846f8303dabf57f7877 100644 |
| --- a/sync/internal_api/sync_manager_impl.cc |
| +++ b/sync/internal_api/sync_manager_impl.cc |
| @@ -65,6 +65,12 @@ |
| using base::TimeDelta; |
| using sync_pb::GetUpdatesCallerInfo; |
| +namespace syncer { |
| + |
| +using sessions::SyncSessionContext; |
| +using syncable::ImmutableWriteTransactionInfo; |
| +using syncable::SPECIFICS; |
| + |
| namespace { |
| // Delays for syncer nudges. |
| @@ -73,16 +79,24 @@ static const int kPreferencesNudgeDelayMilliseconds = 2000; |
| static const int kSyncRefreshDelayMsec = 500; |
| static const int kSyncSchedulerDelayMsec = 250; |
| +// The maximum number of times we will automatically overwrite the nigori node |
| +// because the encryption keys don't match (per chrome instantiation). |
| +static const int kNigoriOverwriteLimit = 10; |
| + |
| +// Maximum count and size for traffic recorder. |
| +static const unsigned int kMaxMessagesToRecord = 10; |
| +static const unsigned int kMaxMessageSizeToRecord = 5 * 1024; |
| + |
| GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( |
| - syncer::ConfigureReason reason) { |
| + ConfigureReason reason) { |
| switch (reason) { |
| - case syncer::CONFIGURE_REASON_RECONFIGURATION: |
| + case CONFIGURE_REASON_RECONFIGURATION: |
| return GetUpdatesCallerInfo::RECONFIGURATION; |
| - case syncer::CONFIGURE_REASON_MIGRATION: |
| + case CONFIGURE_REASON_MIGRATION: |
| return GetUpdatesCallerInfo::MIGRATION; |
| - case syncer::CONFIGURE_REASON_NEW_CLIENT: |
| + case CONFIGURE_REASON_NEW_CLIENT: |
| return GetUpdatesCallerInfo::NEW_CLIENT; |
| - case syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE: |
| + case CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE: |
| return GetUpdatesCallerInfo::NEWLY_SUPPORTED_DATATYPE; |
| default: |
| NOTREACHED(); |
| @@ -91,28 +105,14 @@ GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( |
| return GetUpdatesCallerInfo::UNKNOWN; |
| } |
| -// The maximum number of times we will automatically overwrite the nigori node |
| -// because the encryption keys don't match (per chrome instantiation). |
| -static const int kNigoriOverwriteLimit = 10; |
| - |
| -} // namespace |
| - |
| -namespace syncer { |
| - |
| -using sessions::SyncSessionContext; |
| -using syncable::ImmutableWriteTransactionInfo; |
| -using syncable::SPECIFICS; |
| - |
| -// Maximum count and size for traffic recorder. |
| -const unsigned int kMaxMessagesToRecord = 10; |
| -const unsigned int kMaxMessageSizeToRecord = 5 * 1024; |
| +} // namespace |
| ////////////////////////////////////////////////////////////////////////// |
| // SyncManagerImpl's implementation: SyncManagerImpl::SyncInternal |
| class SyncManagerImpl::SyncInternal |
| : public net::NetworkChangeNotifier::IPAddressObserver, |
| - public syncer::Cryptographer::Observer, |
| - public syncer::SyncNotifierObserver, |
| + public Cryptographer::Observer, |
| + public SyncNotifierObserver, |
| public JsBackend, |
| public SyncEngineEventListener, |
| public ServerConnectionEventListener, |
| @@ -133,10 +133,9 @@ class SyncManagerImpl::SyncInternal |
| created_on_loop_(MessageLoop::current()), |
| nigori_overwrite_count_(0) { |
| // Pre-fill |notification_info_map_|. |
| - for (int i = syncer::FIRST_REAL_MODEL_TYPE; |
| - i < syncer::MODEL_TYPE_COUNT; ++i) { |
| + for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
| notification_info_map_.insert( |
| - std::make_pair(syncer::ModelTypeFromInt(i), NotificationInfo())); |
| + std::make_pair(ModelTypeFromInt(i), NotificationInfo())); |
| } |
| // Bind message handlers. |
| @@ -177,13 +176,13 @@ class SyncManagerImpl::SyncInternal |
| bool use_ssl, |
| const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| scoped_ptr<HttpPostProviderFactory> post_factory, |
| - const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
| - const std::vector<syncer::ModelSafeWorker*>& workers, |
| - syncer::ExtensionsActivityMonitor* |
| + const ModelSafeRoutingInfo& model_safe_routing_info, |
| + const std::vector<ModelSafeWorker*>& workers, |
| + ExtensionsActivityMonitor* |
| extensions_activity_monitor, |
| SyncManager::ChangeDelegate* change_delegate, |
| const SyncCredentials& credentials, |
| - scoped_ptr<syncer::SyncNotifier> sync_notifier, |
| + scoped_ptr<SyncNotifier> sync_notifier, |
| const std::string& restored_key_for_bootstrapping, |
| SyncManager::TestingMode testing_mode, |
| Encryptor* encryptor, |
| @@ -210,7 +209,7 @@ class SyncManagerImpl::SyncInternal |
| // Tell the sync engine to start the syncing process. |
| void StartSyncingNormally( |
| - const syncer::ModelSafeRoutingInfo& routing_info); |
| + const ModelSafeRoutingInfo& routing_info); |
| // Whether or not the Nigori node is encrypted using an explicit passphrase. |
| bool IsUsingExplicitPassphrase(); |
| @@ -300,16 +299,16 @@ class SyncManagerImpl::SyncInternal |
| // Cryptographer::Observer implementation. |
| virtual void OnEncryptedTypesChanged( |
| - syncer::ModelTypeSet encrypted_types, |
| + ModelTypeSet encrypted_types, |
| bool encrypt_everything) OVERRIDE; |
| // SyncNotifierObserver implementation. |
| virtual void OnNotificationsEnabled() OVERRIDE; |
| virtual void OnNotificationsDisabled( |
| - syncer::NotificationsDisabledReason reason) OVERRIDE; |
| + NotificationsDisabledReason reason) OVERRIDE; |
| virtual void OnIncomingNotification( |
| - const syncer::ModelTypePayloadMap& type_payloads, |
| - syncer::IncomingNotificationSource source) OVERRIDE; |
| + const ModelTypePayloadMap& type_payloads, |
| + IncomingNotificationSource source) OVERRIDE; |
| void AddObserver(SyncManager::Observer* observer); |
| void RemoveObserver(SyncManager::Observer* observer); |
| @@ -352,7 +351,7 @@ class SyncManagerImpl::SyncInternal |
| // ExtraPasswordChangeRecordData field of |buffer|. Otherwise sets |
| // |buffer|'s specifics field to contain the unencrypted data. |
| void SetExtraChangeRecordData(int64 id, |
| - syncer::ModelType type, |
| + ModelType type, |
| ChangeReorderBuffer* buffer, |
| Cryptographer* cryptographer, |
| const syncable::EntryKernel& original, |
| @@ -364,8 +363,8 @@ class SyncManagerImpl::SyncInternal |
| ModelTypeSet GetTypesWithEmptyProgressMarkerToken(ModelTypeSet types) { |
| DCHECK(initialized_); |
| - syncer::ModelTypeSet result; |
| - for (syncer::ModelTypeSet::Iterator i = types.First(); |
| + ModelTypeSet result; |
| + for (ModelTypeSet::Iterator i = types.First(); |
| i.Good(); i.Inc()) { |
| sync_pb::DataTypeProgressMarker marker; |
| directory()->GetDownloadProgress(i.Get(), &marker); |
| @@ -377,7 +376,7 @@ class SyncManagerImpl::SyncInternal |
| return result; |
| } |
| - syncer::ModelTypeSet InitialSyncEndedTypes() { |
| + ModelTypeSet InitialSyncEndedTypes() { |
| DCHECK(initialized_); |
| return directory()->initial_sync_ended_types(); |
| } |
| @@ -416,7 +415,7 @@ class SyncManagerImpl::SyncInternal |
| } |
| }; |
| - typedef std::map<syncer::ModelType, NotificationInfo> NotificationInfoMap; |
| + typedef std::map<ModelType, NotificationInfo> NotificationInfoMap; |
| typedef JsArgList |
| (SyncManagerImpl::SyncInternal::*UnboundJsMessageHandler)( |
| const JsArgList&); |
| @@ -442,7 +441,7 @@ class SyncManagerImpl::SyncInternal |
| // If the datatype isn't one where the browser model cares about position, |
| // don't bother notifying that data model of position-only changes. |
| if (!ShouldMaintainPosition( |
| - syncer::GetModelTypeFromSpecifics(b.ref(SPECIFICS)))) |
| + GetModelTypeFromSpecifics(b.ref(SPECIFICS)))) |
| return false; |
| if (a.ref(syncable::NEXT_ID) != b.ref(syncable::NEXT_ID)) |
| return true; |
| @@ -461,12 +460,11 @@ class SyncManagerImpl::SyncInternal |
| const syncable::EntryKernel& b = mutation.mutated; |
| const sync_pb::EntitySpecifics& a_specifics = a.ref(SPECIFICS); |
| const sync_pb::EntitySpecifics& b_specifics = b.ref(SPECIFICS); |
| - DCHECK_EQ(syncer::GetModelTypeFromSpecifics(a_specifics), |
| - syncer::GetModelTypeFromSpecifics(b_specifics)); |
| - syncer::ModelType model_type = |
| - syncer::GetModelTypeFromSpecifics(b_specifics); |
| + DCHECK_EQ(GetModelTypeFromSpecifics(a_specifics), |
| + GetModelTypeFromSpecifics(b_specifics)); |
| + ModelType model_type = GetModelTypeFromSpecifics(b_specifics); |
| // Suppress updates to items that aren't tracked by any browser model. |
| - if (model_type < syncer::FIRST_REAL_MODEL_TYPE || |
| + if (model_type < FIRST_REAL_MODEL_TYPE || |
| !a.ref(syncable::UNIQUE_SERVER_TAG).empty()) { |
| return false; |
| } |
| @@ -488,7 +486,7 @@ class SyncManagerImpl::SyncInternal |
| } |
| bool ChangeBuffersAreEmpty() { |
| - for (int i = 0; i < syncer::MODEL_TYPE_COUNT; ++i) { |
| + for (int i = 0; i < MODEL_TYPE_COUNT; ++i) { |
| if (!change_buffers_[i].IsEmpty()) |
| return false; |
| } |
| @@ -499,8 +497,7 @@ class SyncManagerImpl::SyncInternal |
| // Called for every notification. This updates the notification statistics |
| // to be displayed in about:sync. |
| - void UpdateNotificationInfo( |
| - const syncer::ModelTypePayloadMap& type_payloads); |
| + void UpdateNotificationInfo(const ModelTypePayloadMap& type_payloads); |
| // Checks for server reachabilty and requests a nudge. |
| void OnIPAddressChangedImpl(); |
| @@ -552,7 +549,7 @@ class SyncManagerImpl::SyncInternal |
| // This can be called from any thread, but only between calls to |
| // OpenDirectory() and ShutdownOnSyncThread(). |
| - syncer::WeakHandle<SyncManager::ChangeObserver> change_observer_; |
| + WeakHandle<SyncManager::ChangeObserver> change_observer_; |
| ObserverList<SyncManager::Observer> observers_; |
| @@ -569,7 +566,7 @@ class SyncManagerImpl::SyncInternal |
| scoped_ptr<SyncScheduler> scheduler_; |
| // The SyncNotifier which notifies us when updates need to be downloaded. |
| - scoped_ptr<syncer::SyncNotifier> sync_notifier_; |
| + scoped_ptr<SyncNotifier> sync_notifier_; |
| // A multi-purpose status watch object that aggregates stats from various |
| // sync components. |
| @@ -581,7 +578,7 @@ class SyncManagerImpl::SyncInternal |
| // forwarded to the observer slightly later, at the TRANSACTION_ENDING |
| // step by HandleTransactionEndingChangeEvent. The list is cleared in the |
| // TRANSACTION_COMPLETE step by HandleTransactionCompleteChangeEvent. |
| - ChangeReorderBuffer change_buffers_[syncer::MODEL_TYPE_COUNT]; |
| + ChangeReorderBuffer change_buffers_[MODEL_TYPE_COUNT]; |
| SyncManager::ChangeDelegate* change_delegate_; |
| @@ -606,12 +603,12 @@ class SyncManagerImpl::SyncInternal |
| JsSyncManagerObserver js_sync_manager_observer_; |
| JsMutationEventObserver js_mutation_event_observer_; |
| - syncer::ThrottledDataTypeTracker throttled_data_type_tracker_; |
| + ThrottledDataTypeTracker throttled_data_type_tracker_; |
| // This is for keeping track of client events to send to the server. |
| DebugInfoEventListener debug_info_event_listener_; |
| - syncer::TrafficRecorder traffic_recorder_; |
| + TrafficRecorder traffic_recorder_; |
| Encryptor* encryptor_; |
| UnrecoverableErrorHandler* unrecoverable_error_handler_; |
| @@ -654,10 +651,10 @@ class NudgeStrategy { |
| static NudgeDelayStrategy GetNudgeDelayStrategy(const ModelType& type) { |
| switch (type) { |
| - case syncer::AUTOFILL: |
| + case AUTOFILL: |
| return ACCOMPANY_ONLY; |
| - case syncer::PREFERENCES: |
| - case syncer::SESSIONS: |
| + case PREFERENCES: |
| + case SESSIONS: |
| return CUSTOM; |
| default: |
| return IMMEDIATE; |
| @@ -676,16 +673,15 @@ class NudgeStrategy { |
| kDefaultNudgeDelayMilliseconds); |
| break; |
| case ACCOMPANY_ONLY: |
| - delay = TimeDelta::FromSeconds( |
| - syncer::kDefaultShortPollIntervalSeconds); |
| + delay = TimeDelta::FromSeconds(kDefaultShortPollIntervalSeconds); |
| break; |
| case CUSTOM: |
| switch (model_type) { |
| - case syncer::PREFERENCES: |
| + case PREFERENCES: |
| delay = TimeDelta::FromMilliseconds( |
| kPreferencesNudgeDelayMilliseconds); |
| break; |
| - case syncer::SESSIONS: |
| + case SESSIONS: |
| delay = core->scheduler()->sessions_commit_delay(); |
| break; |
| default: |
| @@ -710,12 +706,12 @@ bool SyncManagerImpl::Init( |
| bool use_ssl, |
| const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| scoped_ptr<HttpPostProviderFactory> post_factory, |
| - const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
| - const std::vector<syncer::ModelSafeWorker*>& workers, |
| - syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
| + const ModelSafeRoutingInfo& model_safe_routing_info, |
| + const std::vector<ModelSafeWorker*>& workers, |
| + ExtensionsActivityMonitor* extensions_activity_monitor, |
| SyncManager::ChangeDelegate* change_delegate, |
| const SyncCredentials& credentials, |
| - scoped_ptr<syncer::SyncNotifier> sync_notifier, |
| + scoped_ptr<SyncNotifier> sync_notifier, |
| const std::string& restored_key_for_bootstrapping, |
| SyncManager::TestingMode testing_mode, |
| Encryptor* encryptor, |
| @@ -762,12 +758,12 @@ void SyncManagerImpl::ThrowUnrecoverableError() { |
| FROM_HERE, "Simulating unrecoverable error for testing purposes."); |
| } |
| -syncer::ModelTypeSet SyncManagerImpl::InitialSyncEndedTypes() { |
| +ModelTypeSet SyncManagerImpl::InitialSyncEndedTypes() { |
| return data_->InitialSyncEndedTypes(); |
| } |
| -syncer::ModelTypeSet SyncManagerImpl::GetTypesWithEmptyProgressMarkerToken( |
| - syncer::ModelTypeSet types) { |
| +ModelTypeSet SyncManagerImpl::GetTypesWithEmptyProgressMarkerToken( |
| + ModelTypeSet types) { |
| return data_->GetTypesWithEmptyProgressMarkerToken(types); |
| } |
| @@ -776,7 +772,7 @@ bool SyncManagerImpl::PurgePartiallySyncedTypes() { |
| } |
| void SyncManagerImpl::StartSyncingNormally( |
| - const syncer::ModelSafeRoutingInfo& routing_info) { |
| + const ModelSafeRoutingInfo& routing_info) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| data_->StartSyncingNormally(routing_info); |
| } |
| @@ -821,8 +817,8 @@ bool SyncManagerImpl::IsUsingExplicitPassphrase() { |
| void SyncManagerImpl::ConfigureSyncer( |
| ConfigureReason reason, |
| - const syncer::ModelTypeSet& types_to_config, |
| - const syncer::ModelSafeRoutingInfo& new_routing_info, |
| + const ModelTypeSet& types_to_config, |
| + const ModelSafeRoutingInfo& new_routing_info, |
| const base::Closure& ready_task, |
| const base::Closure& retry_task) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| @@ -848,7 +844,7 @@ void SyncManagerImpl::ConfigureSyncer( |
| return; |
| } |
| - data_->scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); |
| + data_->scheduler()->Start(SyncScheduler::CONFIGURATION_MODE); |
| if (!data_->scheduler()->ScheduleConfiguration(params)) |
| retry_task.Run(); |
| @@ -862,12 +858,12 @@ bool SyncManagerImpl::SyncInternal::Init( |
| bool use_ssl, |
| const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| scoped_ptr<HttpPostProviderFactory> post_factory, |
| - const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
| - const std::vector<syncer::ModelSafeWorker*>& workers, |
| - syncer::ExtensionsActivityMonitor* extensions_activity_monitor, |
| + const ModelSafeRoutingInfo& model_safe_routing_info, |
| + const std::vector<ModelSafeWorker*>& workers, |
| + ExtensionsActivityMonitor* extensions_activity_monitor, |
| SyncManager::ChangeDelegate* change_delegate, |
| const SyncCredentials& credentials, |
| - scoped_ptr<syncer::SyncNotifier> sync_notifier, |
| + scoped_ptr<SyncNotifier> sync_notifier, |
| const std::string& restored_key_for_bootstrapping, |
| SyncManager::TestingMode testing_mode, |
| Encryptor* encryptor, |
| @@ -952,7 +948,7 @@ bool SyncManagerImpl::SyncInternal::Init( |
| if (success) { |
| if (scheduler()) { |
| - scheduler()->Start(syncer::SyncScheduler::CONFIGURATION_MODE); |
| + scheduler()->Start(SyncScheduler::CONFIGURATION_MODE); |
| } |
| initialized_ = true; |
| @@ -1002,7 +998,7 @@ void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigori( |
| const std::string& chrome_version, |
| const base::Closure& done_callback) { |
| DCHECK(initialized_); |
| - syncer::GetSessionName( |
| + GetSessionName( |
| blocking_task_runner_, |
| base::Bind( |
| &SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigoriCallback, |
| @@ -1049,7 +1045,7 @@ void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigoriCallback( |
| const std::string& chrome_version, |
| const base::Closure& done_callback, |
| const std::string& session_name) { |
| - if (!directory()->initial_sync_ended_for_type(syncer::NIGORI)) { |
| + if (!directory()->initial_sync_ended_for_type(NIGORI)) { |
| done_callback.Run(); // Should only happen during first time sync. |
| return; |
| } |
| @@ -1060,7 +1056,7 @@ void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigoriCallback( |
| Cryptographer* cryptographer = trans.GetCryptographer(); |
| WriteNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) == syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) == BaseNode::INIT_OK) { |
| sync_pb::NigoriSpecifics nigori(node.GetNigoriSpecifics()); |
| Cryptographer::UpdateResult result = cryptographer->Update(nigori); |
| if (result == Cryptographer::NEEDS_PASSPHRASE) { |
| @@ -1068,7 +1064,7 @@ void SyncManagerImpl::SyncInternal::UpdateCryptographerAndNigoriCallback( |
| if (cryptographer->has_pending_keys()) |
| pending_keys = cryptographer->GetPendingKeys(); |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_DECRYPTION, |
| + OnPassphraseRequired(REASON_DECRYPTION, |
| pending_keys)); |
| } |
| @@ -1138,7 +1134,7 @@ void SyncManagerImpl::SyncInternal::NotifyCryptographerState( |
| } |
| void SyncManagerImpl::SyncInternal::StartSyncingNormally( |
| - const syncer::ModelSafeRoutingInfo& routing_info) { |
| + const ModelSafeRoutingInfo& routing_info) { |
| // Start the sync scheduler. |
| if (scheduler()) { // NULL during certain unittests. |
| // TODO(sync): We always want the newest set of routes when we switch back |
| @@ -1155,9 +1151,9 @@ bool SyncManagerImpl::SyncInternal::OpenDirectory() { |
| // Set before Open(). |
| change_observer_ = |
| - syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()); |
| + MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()); |
| WeakHandle<syncable::TransactionObserver> transaction_observer( |
| - syncer::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr())); |
| + MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr())); |
| syncable::DirOpenResult open_result = syncable::NOT_INITIALIZED; |
| open_result = directory()->Open(username_for_share(), this, |
| @@ -1201,11 +1197,10 @@ bool SyncManagerImpl::SyncInternal::SignIn(const SyncCredentials& credentials) { |
| } |
| bool SyncManagerImpl::SyncInternal::PurgePartiallySyncedTypes() { |
| - syncer::ModelTypeSet partially_synced_types = |
| - syncer::ModelTypeSet::All(); |
| + ModelTypeSet partially_synced_types = ModelTypeSet::All(); |
| partially_synced_types.RemoveAll(InitialSyncEndedTypes()); |
| partially_synced_types.RemoveAll(GetTypesWithEmptyProgressMarkerToken( |
| - syncer::ModelTypeSet::All())); |
| + ModelTypeSet::All())); |
| UMA_HISTOGRAM_COUNTS("Sync.PartiallySyncedTypes", |
| partially_synced_types.Size()); |
| @@ -1251,7 +1246,7 @@ void SyncManagerImpl::SyncInternal::SetEncryptionPassphrase( |
| Cryptographer* cryptographer = trans.GetCryptographer(); |
| KeyParams key_params = {"localhost", "dummy", passphrase}; |
| WriteNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| // TODO(albertb): Plumb an UnrecoverableError all the way back to the PSS. |
| NOTREACHED(); |
| return; |
| @@ -1365,7 +1360,7 @@ void SyncManagerImpl::SyncInternal::SetDecryptionPassphrase( |
| Cryptographer* cryptographer = trans.GetCryptographer(); |
| KeyParams key_params = {"localhost", "dummy", passphrase}; |
| WriteNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| // TODO(albertb): Plumb an UnrecoverableError all the way back to the PSS. |
| NOTREACHED(); |
| return; |
| @@ -1518,11 +1513,11 @@ void SyncManagerImpl::SyncInternal::FinishSetPassphrase( |
| << "was ready."; |
| } else if (cryptographer->has_pending_keys()) { |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_DECRYPTION, |
| + OnPassphraseRequired(REASON_DECRYPTION, |
| cryptographer->GetPendingKeys())); |
| } else { |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_ENCRYPTION, |
| + OnPassphraseRequired(REASON_ENCRYPTION, |
| sync_pb::EncryptedData())); |
| } |
| return; |
| @@ -1554,7 +1549,7 @@ void SyncManagerImpl::SyncInternal::FinishSetPassphrase( |
| bool SyncManagerImpl::SyncInternal::IsUsingExplicitPassphrase() { |
| ReadTransaction trans(FROM_HERE, &share_); |
| ReadNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| // TODO(albertb): Plumb an UnrecoverableError all the way back to the PSS. |
| NOTREACHED(); |
| return false; |
| @@ -1568,7 +1563,7 @@ void SyncManagerImpl::SyncInternal::RefreshEncryption() { |
| WriteTransaction trans(FROM_HERE, GetUserShare()); |
| WriteNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| NOTREACHED() << "Unable to set encrypted datatypes because Nigori node not " |
| << "found."; |
| return; |
| @@ -1585,7 +1580,7 @@ void SyncManagerImpl::SyncInternal::RefreshEncryption() { |
| if (cryptographer->has_pending_keys()) |
| pending_keys = cryptographer->GetPendingKeys(); |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_DECRYPTION, |
| + OnPassphraseRequired(REASON_DECRYPTION, |
| pending_keys)); |
| return; |
| } |
| @@ -1608,15 +1603,15 @@ void SyncManagerImpl::SyncInternal::ReEncryptEverything( |
| Cryptographer* cryptographer = trans->GetCryptographer(); |
| if (!cryptographer || !cryptographer->is_ready()) |
| return; |
| - syncer::ModelTypeSet encrypted_types = GetEncryptedTypes(trans); |
| - for (syncer::ModelTypeSet::Iterator iter = encrypted_types.First(); |
| + ModelTypeSet encrypted_types = GetEncryptedTypes(trans); |
| + for (ModelTypeSet::Iterator iter = encrypted_types.First(); |
| iter.Good(); iter.Inc()) { |
| - if (iter.Get() == syncer::PASSWORDS || iter.Get() == syncer::NIGORI) |
| + if (iter.Get() == PASSWORDS || iter.Get() == NIGORI) |
| continue; // These types handle encryption differently. |
| ReadNode type_root(trans); |
| - std::string tag = syncer::ModelTypeToRootTag(iter.Get()); |
| - if (type_root.InitByTagLookup(tag) != syncer::BaseNode::INIT_OK) |
| + std::string tag = ModelTypeToRootTag(iter.Get()); |
| + if (type_root.InitByTagLookup(tag) != BaseNode::INIT_OK) |
| continue; // Don't try to reencrypt if the type's data is unavailable. |
| // Iterate through all children of this datatype. |
| @@ -1630,7 +1625,7 @@ void SyncManagerImpl::SyncInternal::ReEncryptEverything( |
| continue; |
| WriteNode child(trans); |
| - if (child.InitByIdLookup(child_id) != syncer::BaseNode::INIT_OK) { |
| + if (child.InitByIdLookup(child_id) != BaseNode::INIT_OK) { |
| NOTREACHED(); |
| continue; |
| } |
| @@ -1649,13 +1644,12 @@ void SyncManagerImpl::SyncInternal::ReEncryptEverything( |
| // Passwords are encrypted with their own legacy scheme. Passwords are always |
| // encrypted so we don't need to check GetEncryptedTypes() here. |
| ReadNode passwords_root(trans); |
| - std::string passwords_tag = syncer::ModelTypeToRootTag(syncer::PASSWORDS); |
| - if (passwords_root.InitByTagLookup(passwords_tag) == |
| - syncer::BaseNode::INIT_OK) { |
| + std::string passwords_tag = ModelTypeToRootTag(PASSWORDS); |
| + if (passwords_root.InitByTagLookup(passwords_tag) == BaseNode::INIT_OK) { |
| int64 child_id = passwords_root.GetFirstChildId(); |
| while (child_id != kInvalidId) { |
| WriteNode child(trans); |
| - if (child.InitByIdLookup(child_id) != syncer::BaseNode::INIT_OK) { |
| + if (child.InitByIdLookup(child_id) != BaseNode::INIT_OK) { |
| NOTREACHED(); |
| return; |
| } |
| @@ -1776,19 +1770,19 @@ void SyncManagerImpl::SyncInternal::OnServerConnectionEvent( |
| const ServerConnectionEvent& event) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| if (event.connection_code == |
| - syncer::HttpResponse::SERVER_CONNECTION_OK) { |
| + HttpResponse::SERVER_CONNECTION_OK) { |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| OnConnectionStatusChange(CONNECTION_OK)); |
| } |
| - if (event.connection_code == syncer::HttpResponse::SYNC_AUTH_ERROR) { |
| + if (event.connection_code == HttpResponse::SYNC_AUTH_ERROR) { |
| observing_ip_address_changes_ = false; |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| OnConnectionStatusChange(CONNECTION_AUTH_ERROR)); |
| } |
| if (event.connection_code == |
| - syncer::HttpResponse::SYNC_SERVER_ERROR) { |
| + HttpResponse::SYNC_SERVER_ERROR) { |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| OnConnectionStatusChange(CONNECTION_SERVER_ERROR)); |
| } |
| @@ -1830,9 +1824,8 @@ ModelTypeSet |
| ReadTransaction read_trans(GetUserShare(), trans); |
| ModelTypeSet models_with_changes; |
| - for (int i = syncer::FIRST_REAL_MODEL_TYPE; |
| - i < syncer::MODEL_TYPE_COUNT; ++i) { |
| - const syncer::ModelType type = syncer::ModelTypeFromInt(i); |
| + for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
| + const ModelType type = ModelTypeFromInt(i); |
| if (change_buffers_[type].IsEmpty()) |
| continue; |
| @@ -1867,7 +1860,7 @@ void SyncManagerImpl::SyncInternal:: |
| "CALCULATE_CHANGES called with unapplied old changes."; |
| // The mutated model type, or UNSPECIFIED if nothing was mutated. |
| - syncer::ModelTypeSet mutated_model_types; |
| + ModelTypeSet mutated_model_types; |
| const syncable::ImmutableEntryKernelMutationMap& mutations = |
| write_transaction_info.Get().mutations; |
| @@ -1877,16 +1870,16 @@ void SyncManagerImpl::SyncInternal:: |
| continue; |
| } |
| - syncer::ModelType model_type = |
| - syncer::GetModelTypeFromSpecifics( |
| + ModelType model_type = |
| + GetModelTypeFromSpecifics( |
|
Nicolas Zea
2012/07/19 19:37:56
move onto previous line?
akalin
2012/07/19 20:56:02
Done.
|
| it->second.mutated.ref(SPECIFICS)); |
| - if (model_type < syncer::FIRST_REAL_MODEL_TYPE) { |
| + if (model_type < FIRST_REAL_MODEL_TYPE) { |
| NOTREACHED() << "Permanent or underspecified item changed via syncapi."; |
| continue; |
| } |
| // Found real mutation. |
| - if (model_type != syncer::UNSPECIFIED) { |
| + if (model_type != UNSPECIFIED) { |
| mutated_model_types.Put(model_type); |
| } |
| } |
| @@ -1905,14 +1898,14 @@ void SyncManagerImpl::SyncInternal:: |
| } |
| void SyncManagerImpl::SyncInternal::SetExtraChangeRecordData(int64 id, |
| - syncer::ModelType type, ChangeReorderBuffer* buffer, |
| + ModelType type, ChangeReorderBuffer* buffer, |
| Cryptographer* cryptographer, const syncable::EntryKernel& original, |
| bool existed_before, bool exists_now) { |
| // If this is a deletion and the datatype was encrypted, we need to decrypt it |
| // and attach it to the buffer. |
| if (!exists_now && existed_before) { |
| sync_pb::EntitySpecifics original_specifics(original.ref(SPECIFICS)); |
| - if (type == syncer::PASSWORDS) { |
| + if (type == PASSWORDS) { |
| // Passwords must use their own legacy ExtraPasswordChangeRecordData. |
| scoped_ptr<sync_pb::PasswordSpecificsData> data( |
| DecryptPasswordSpecifics(original_specifics, cryptographer)); |
| @@ -1951,10 +1944,10 @@ void SyncManagerImpl::SyncInternal::HandleCalculateChangesChangeEventFromSyncer( |
| bool exists_now = !it->second.mutated.ref(syncable::IS_DEL); |
| // Omit items that aren't associated with a model. |
| - syncer::ModelType type = |
| - syncer::GetModelTypeFromSpecifics( |
| + ModelType type = |
| + GetModelTypeFromSpecifics( |
|
Nicolas Zea
2012/07/19 19:37:56
here too
akalin
2012/07/19 20:56:02
Done.
|
| it->second.mutated.ref(SPECIFICS)); |
| - if (type < syncer::FIRST_REAL_MODEL_TYPE) |
| + if (type < FIRST_REAL_MODEL_TYPE) |
| continue; |
| int64 handle = it->first; |
| @@ -1981,7 +1974,7 @@ void SyncManagerImpl::SyncInternal::RequestNudge( |
| const tracked_objects::Location& location) { |
| if (scheduler()) { |
| scheduler()->ScheduleNudgeAsync( |
| - TimeDelta::FromMilliseconds(0), syncer::NUDGE_SOURCE_LOCAL, |
| + TimeDelta::FromMilliseconds(0), NUDGE_SOURCE_LOCAL, |
| ModelTypeSet(), location); |
| } |
| } |
| @@ -2006,7 +1999,7 @@ void SyncManagerImpl::SyncInternal::RequestNudgeForDataTypes( |
| types.First().Get(), |
| this); |
| scheduler()->ScheduleNudgeAsync(nudge_delay, |
| - syncer::NUDGE_SOURCE_LOCAL, |
| + NUDGE_SOURCE_LOCAL, |
| types, |
| nudge_location); |
| } |
| @@ -2033,14 +2026,14 @@ void SyncManagerImpl::SyncInternal::OnSyncEngineEvent( |
| DVLOG(1) << "OnPassPhraseRequired Sent"; |
| sync_pb::EncryptedData pending_keys = cryptographer->GetPendingKeys(); |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_DECRYPTION, |
| + OnPassphraseRequired(REASON_DECRYPTION, |
| pending_keys)); |
| } else if (!cryptographer->is_ready() && |
| - event.snapshot.initial_sync_ended().Has(syncer::NIGORI)) { |
| + event.snapshot.initial_sync_ended().Has(NIGORI)) { |
| DVLOG(1) << "OnPassphraseRequired sent because cryptographer is not " |
| << "ready"; |
| FOR_EACH_OBSERVER(SyncManager::Observer, observers_, |
| - OnPassphraseRequired(syncer::REASON_ENCRYPTION, |
| + OnPassphraseRequired(REASON_ENCRYPTION, |
| sync_pb::EncryptedData())); |
| } |
| @@ -2060,7 +2053,7 @@ void SyncManagerImpl::SyncInternal::OnSyncEngineEvent( |
| WriteTransaction trans(FROM_HERE, GetUserShare()); |
| WriteNode nigori_node(&trans); |
| if (nigori_node.InitByTagLookup(kNigoriTag) == |
| - syncer::BaseNode::INIT_OK) { |
| + BaseNode::INIT_OK) { |
| Cryptographer* cryptographer = trans.GetCryptographer(); |
| UpdateNigoriEncryptionState(cryptographer, &nigori_node); |
| } |
| @@ -2079,8 +2072,7 @@ void SyncManagerImpl::SyncInternal::OnSyncEngineEvent( |
| if (is_notifiable_commit) { |
| if (sync_notifier_.get()) { |
| const ModelTypeSet changed_types = |
| - syncer::ModelTypePayloadMapToEnumSet( |
| - event.snapshot.source().types); |
| + ModelTypePayloadMapToEnumSet(event.snapshot.source().types); |
| sync_notifier_->SendNotification(changed_types); |
| } else { |
| DVLOG(1) << "Not sending notification: sync_notifier_ is NULL"; |
| @@ -2157,7 +2149,7 @@ DictionaryValue* SyncManagerImpl::SyncInternal::NotificationInfoToValue( |
| for (NotificationInfoMap::const_iterator it = notification_info.begin(); |
| it != notification_info.end(); ++it) { |
| const std::string& model_type_str = |
| - syncer::ModelTypeToString(it->first); |
| + ModelTypeToString(it->first); |
| value->Set(model_type_str, it->second.ToValue()); |
| } |
| @@ -2229,7 +2221,7 @@ JsArgList GetNodeInfoById(const JsArgList& args, |
| continue; |
| } |
| ReadNode node(&trans); |
| - if (node.InitByIdLookup(id) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByIdLookup(id) != BaseNode::INIT_OK) { |
| continue; |
| } |
| node_summaries->Append((node.*info_getter)()); |
| @@ -2290,7 +2282,7 @@ JsArgList SyncManagerImpl::SyncInternal::GetChildNodeIds( |
| } |
| void SyncManagerImpl::SyncInternal::OnEncryptedTypesChanged( |
| - syncer::ModelTypeSet encrypted_types, |
| + ModelTypeSet encrypted_types, |
| bool encrypt_everything) { |
| // NOTE: We're in a transaction. |
| FOR_EACH_OBSERVER( |
| @@ -2299,8 +2291,8 @@ void SyncManagerImpl::SyncInternal::OnEncryptedTypesChanged( |
| } |
| void SyncManagerImpl::SyncInternal::UpdateNotificationInfo( |
| - const syncer::ModelTypePayloadMap& type_payloads) { |
| - for (syncer::ModelTypePayloadMap::const_iterator it = type_payloads.begin(); |
| + const ModelTypePayloadMap& type_payloads) { |
| + for (ModelTypePayloadMap::const_iterator it = type_payloads.begin(); |
| it != type_payloads.end(); ++it) { |
| NotificationInfo* info = ¬ification_info_map_[it->first]; |
| info->total_count++; |
| @@ -2327,9 +2319,9 @@ void SyncManagerImpl::SyncInternal::OnNotificationsEnabled() { |
| } |
| void SyncManagerImpl::SyncInternal::OnNotificationsDisabled( |
| - syncer::NotificationsDisabledReason reason) { |
| + NotificationsDisabledReason reason) { |
| DVLOG(1) << "Notifications disabled with reason " |
| - << syncer::NotificationsDisabledReasonToString(reason); |
| + << NotificationsDisabledReasonToString(reason); |
| allstatus_.SetNotificationsEnabled(false); |
| if (scheduler()) { |
| scheduler()->set_notifications_enabled(false); |
| @@ -2347,21 +2339,21 @@ void SyncManagerImpl::SyncInternal::OnNotificationsDisabled( |
| } |
| void SyncManagerImpl::SyncInternal::OnIncomingNotification( |
| - const syncer::ModelTypePayloadMap& type_payloads, |
| - syncer::IncomingNotificationSource source) { |
| + const ModelTypePayloadMap& type_payloads, |
| + IncomingNotificationSource source) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - if (source == syncer::LOCAL_NOTIFICATION) { |
| + if (source == LOCAL_NOTIFICATION) { |
| if (scheduler()) { |
| scheduler()->ScheduleNudgeWithPayloadsAsync( |
| TimeDelta::FromMilliseconds(kSyncRefreshDelayMsec), |
| - syncer::NUDGE_SOURCE_LOCAL_REFRESH, |
| + NUDGE_SOURCE_LOCAL_REFRESH, |
| type_payloads, FROM_HERE); |
| } |
| } else if (!type_payloads.empty()) { |
| if (scheduler()) { |
| scheduler()->ScheduleNudgeWithPayloadsAsync( |
| TimeDelta::FromMilliseconds(kSyncSchedulerDelayMsec), |
| - syncer::NUDGE_SOURCE_NOTIFICATION, |
| + NUDGE_SOURCE_NOTIFICATION, |
| type_payloads, FROM_HERE); |
| } |
| allstatus_.IncrementNotificationsReceived(); |
| @@ -2375,14 +2367,13 @@ void SyncManagerImpl::SyncInternal::OnIncomingNotification( |
| DictionaryValue details; |
| ListValue* changed_types = new ListValue(); |
| details.Set("changedTypes", changed_types); |
| - for (syncer::ModelTypePayloadMap::const_iterator |
| - it = type_payloads.begin(); |
| + for (ModelTypePayloadMap::const_iterator it = type_payloads.begin(); |
| it != type_payloads.end(); ++it) { |
| const std::string& model_type_str = |
| - syncer::ModelTypeToString(it->first); |
| + ModelTypeToString(it->first); |
| changed_types->Append(Value::CreateStringValue(model_type_str)); |
| } |
| - details.SetString("source", (source == syncer::LOCAL_NOTIFICATION) ? |
| + details.SetString("source", (source == LOCAL_NOTIFICATION) ? |
| "LOCAL_NOTIFICATION" : "REMOTE_NOTIFICATION"); |
| js_event_handler_.Call(FROM_HERE, |
| &JsEventHandler::HandleJsEvent, |
| @@ -2441,16 +2432,15 @@ void SyncManagerImpl::SetSyncSchedulerForTest( |
| data_->SetSyncSchedulerForTest(scheduler.Pass()); |
| } |
| -syncer::ModelTypeSet SyncManagerImpl::GetEncryptedDataTypesForTest() const { |
| +ModelTypeSet SyncManagerImpl::GetEncryptedDataTypesForTest() const { |
| ReadTransaction trans(FROM_HERE, GetUserShare()); |
| return GetEncryptedTypes(&trans); |
| } |
| -bool SyncManagerImpl::ReceivedExperiment( |
| - syncer::Experiments* experiments) const { |
| +bool SyncManagerImpl::ReceivedExperiment(Experiments* experiments) const { |
| ReadTransaction trans(FROM_HERE, GetUserShare()); |
| ReadNode node(&trans); |
| - if (node.InitByTagLookup(kNigoriTag) != syncer::BaseNode::INIT_OK) { |
| + if (node.InitByTagLookup(kNigoriTag) != BaseNode::INIT_OK) { |
| DVLOG(1) << "Couldn't find Nigori node."; |
| return false; |
| } |
| @@ -2463,7 +2453,7 @@ bool SyncManagerImpl::ReceivedExperiment( |
| } |
| bool SyncManagerImpl::HasUnsyncedItems() const { |
| - syncer::ReadTransaction trans(FROM_HERE, GetUserShare()); |
| + ReadTransaction trans(FROM_HERE, GetUserShare()); |
| return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); |
| } |
| @@ -2475,18 +2465,18 @@ void SyncManagerImpl::SimulateEnableNotificationsForTest() { |
| void SyncManagerImpl::SimulateDisableNotificationsForTest(int reason) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| data_->OnNotificationsDisabled( |
| - static_cast<syncer::NotificationsDisabledReason>(reason)); |
| + static_cast<NotificationsDisabledReason>(reason)); |
| } |
| void SyncManagerImpl::TriggerOnIncomingNotificationForTest( |
| ModelTypeSet model_types) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - syncer::ModelTypePayloadMap model_types_with_payloads = |
| - syncer::ModelTypePayloadMapFromEnumSet(model_types, |
| + ModelTypePayloadMap model_types_with_payloads = |
| + ModelTypePayloadMapFromEnumSet(model_types, |
| std::string()); |
| data_->OnIncomingNotification(model_types_with_payloads, |
| - syncer::REMOTE_NOTIFICATION); |
| + REMOTE_NOTIFICATION); |
| } |
| // static. |