Chromium Code Reviews| Index: sync/tools/sync_client.cc |
| diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc |
| index 1b9dbf8333fcf426e30c2a736d4ebf2b187fc1f3..4f338d6b7a86ea7324a3ad9526a9ddfbbed22394 100644 |
| --- a/sync/tools/sync_client.cc |
| +++ b/sync/tools/sync_client.cc |
| @@ -52,6 +52,7 @@ |
| // TODO(akalin): Refactor to combine shared code with |
| // sync_listen_notifications. |
| +namespace syncer { |
| namespace { |
| const char kEmailSwitch[] = "email"; |
| @@ -64,22 +65,20 @@ const char kNotificationMethodSwitch[] = "notification-method"; |
| class NullInvalidationStateTracker |
| : public base::SupportsWeakPtr<NullInvalidationStateTracker>, |
| - public syncer::InvalidationStateTracker { |
| + public InvalidationStateTracker { |
| public: |
| NullInvalidationStateTracker() {} |
| virtual ~NullInvalidationStateTracker() {} |
| - virtual syncer::InvalidationVersionMap |
| - GetAllMaxVersions() const OVERRIDE { |
| - return syncer::InvalidationVersionMap(); |
| + virtual InvalidationVersionMap GetAllMaxVersions() const OVERRIDE { |
| + return InvalidationVersionMap(); |
| } |
| virtual void SetMaxVersion( |
| const invalidation::ObjectId& id, |
| int64 max_invalidation_version) OVERRIDE { |
| VLOG(1) << "Setting max invalidation version for " |
| - << syncer::ObjectIdToString(id) << " to " |
| - << max_invalidation_version; |
| + << ObjectIdToString(id) << " to " << max_invalidation_version; |
| } |
| virtual std::string GetInvalidationState() const OVERRIDE { |
| @@ -129,7 +128,7 @@ class MyTestURLRequestContextGetter : public TestURLRequestContextGetter { |
| }; |
| // TODO(akalin): Use system encryptor once it's moved to sync/. |
| -class NullEncryptor : public syncer::Encryptor { |
| +class NullEncryptor : public Encryptor { |
| public: |
| virtual ~NullEncryptor() {} |
| @@ -152,26 +151,26 @@ std::string ValueToString(const Value& value) { |
| return str; |
| } |
| -class LoggingChangeDelegate : public syncer::SyncManager::ChangeDelegate { |
| +class LoggingChangeDelegate : public SyncManager::ChangeDelegate { |
| public: |
| virtual ~LoggingChangeDelegate() {} |
| virtual void OnChangesApplied( |
| - syncer::ModelType model_type, |
| - const syncer::BaseTransaction* trans, |
| - const syncer::ImmutableChangeRecordList& changes) OVERRIDE { |
| + ModelType model_type, |
| + const BaseTransaction* trans, |
| + const ImmutableChangeRecordList& changes) OVERRIDE { |
| LOG(INFO) << "Changes applied for " |
| - << syncer::ModelTypeToString(model_type); |
| + << ModelTypeToString(model_type); |
| size_t i = 1; |
| size_t change_count = changes.Get().size(); |
| - for (syncer::ChangeRecordList::const_iterator it = |
| + for (ChangeRecordList::const_iterator it = |
| changes.Get().begin(); it != changes.Get().end(); ++it) { |
| scoped_ptr<base::DictionaryValue> change_value(it->ToValue()); |
| LOG(INFO) << "Change (" << i << "/" << change_count << "): " |
| << ValueToString(*change_value); |
| - if (it->action != syncer::ChangeRecord::ACTION_DELETE) { |
| - syncer::ReadNode node(trans); |
| - CHECK_EQ(node.InitByIdLookup(it->id), syncer::BaseNode::INIT_OK); |
| + if (it->action != ChangeRecord::ACTION_DELETE) { |
| + ReadNode node(trans); |
| + CHECK_EQ(node.InitByIdLookup(it->id), BaseNode::INIT_OK); |
| scoped_ptr<base::DictionaryValue> details(node.GetDetailsAsValue()); |
| VLOG(1) << "Details: " << ValueToString(*details); |
| } |
| @@ -179,14 +178,14 @@ class LoggingChangeDelegate : public syncer::SyncManager::ChangeDelegate { |
| } |
| } |
| - virtual void OnChangesComplete(syncer::ModelType model_type) OVERRIDE { |
| + virtual void OnChangesComplete(ModelType model_type) OVERRIDE { |
| LOG(INFO) << "Changes complete for " |
| - << syncer::ModelTypeToString(model_type); |
| + << ModelTypeToString(model_type); |
| } |
| }; |
| class LoggingUnrecoverableErrorHandler |
| - : public syncer::UnrecoverableErrorHandler { |
| + : public UnrecoverableErrorHandler { |
| public: |
| virtual ~LoggingUnrecoverableErrorHandler() {} |
| @@ -201,14 +200,14 @@ class LoggingUnrecoverableErrorHandler |
| }; |
| class LoggingJsEventHandler |
| - : public syncer::JsEventHandler, |
| + : public JsEventHandler, |
| public base::SupportsWeakPtr<LoggingJsEventHandler> { |
| public: |
| virtual ~LoggingJsEventHandler() {} |
| virtual void HandleJsEvent( |
| const std::string& name, |
| - const syncer::JsEventDetails& details) OVERRIDE { |
| + const JsEventDetails& details) OVERRIDE { |
| VLOG(1) << name << ": " << details.ToString(); |
| } |
| }; |
| @@ -253,8 +252,10 @@ notifier::NotifierOptions ParseNotifierOptions( |
| } |
| } // namespace |
| +} // namespace syncer |
| int main(int argc, char* argv[]) { |
| + using namespace syncer; |
|
Nicolas Zea
2012/07/19 19:37:56
I think style guide forbids this usage?
akalin
2012/07/19 20:56:02
Done, did what I wanted some other way
|
| #if defined(OS_MACOSX) |
| base::mac::ScopedNSAutoreleasePool pool; |
| #endif |
| @@ -275,7 +276,7 @@ int main(int argc, char* argv[]) { |
| // Parse command line. |
| const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| - syncer::SyncCredentials credentials; |
| + SyncCredentials credentials; |
| credentials.email = command_line.GetSwitchValueASCII(kEmailSwitch); |
| credentials.sync_token = command_line.GetSwitchValueASCII(kTokenSwitch); |
| // TODO(akalin): Write a wrapper script that gets a token for an |
| @@ -307,7 +308,7 @@ int main(int argc, char* argv[]) { |
| ParseNotifierOptions(command_line, context_getter); |
| const char kClientInfo[] = "sync_listen_notifications"; |
| NullInvalidationStateTracker null_invalidation_state_tracker; |
| - syncer::SyncNotifierFactory sync_notifier_factory( |
| + SyncNotifierFactory sync_notifier_factory( |
| notifier_options, kClientInfo, |
| null_invalidation_state_tracker.AsWeakPtr()); |
| @@ -316,20 +317,20 @@ int main(int argc, char* argv[]) { |
| CHECK(database_dir.CreateUniqueTempDir()); |
| // Set up model type parameters. |
| - const syncer::ModelTypeSet model_types = syncer::ModelTypeSet::All(); |
| - syncer::ModelSafeRoutingInfo routing_info; |
| - for (syncer::ModelTypeSet::Iterator it = model_types.First(); |
| + const ModelTypeSet model_types = ModelTypeSet::All(); |
| + ModelSafeRoutingInfo routing_info; |
| + for (ModelTypeSet::Iterator it = model_types.First(); |
| it.Good(); it.Inc()) { |
| - routing_info[it.Get()] = syncer::GROUP_PASSIVE; |
| + routing_info[it.Get()] = GROUP_PASSIVE; |
| } |
| - scoped_refptr<syncer::PassiveModelWorker> passive_model_safe_worker = |
| - new syncer::PassiveModelWorker(&sync_loop); |
| - std::vector<syncer::ModelSafeWorker*> workers; |
| + scoped_refptr<PassiveModelWorker> passive_model_safe_worker = |
| + new PassiveModelWorker(&sync_loop); |
| + std::vector<ModelSafeWorker*> workers; |
| workers.push_back(passive_model_safe_worker.get()); |
| // Set up sync manager. |
| - syncer::SyncManagerFactory sync_manager_factory; |
| - scoped_ptr<syncer::SyncManager> sync_manager = |
| + SyncManagerFactory sync_manager_factory; |
| + scoped_ptr<SyncManager> sync_manager = |
| sync_manager_factory.CreateSyncManager("sync_client manager"); |
| LoggingJsEventHandler js_event_handler; |
| const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev"; |
| @@ -340,19 +341,18 @@ int main(int argc, char* argv[]) { |
| const char kUserAgent[] = "sync_client"; |
| // TODO(akalin): Replace this with just the context getter once |
| // HttpPostProviderFactory is removed. |
| - scoped_ptr<syncer::HttpPostProviderFactory> post_factory( |
| - new syncer::HttpBridgeFactory(context_getter, kUserAgent)); |
| + scoped_ptr<HttpPostProviderFactory> post_factory( |
| + new HttpBridgeFactory(context_getter, kUserAgent)); |
| // Used only when committing bookmarks, so it's okay to leave this |
| // as NULL. |
| - syncer::ExtensionsActivityMonitor* extensions_activity_monitor = NULL; |
| + ExtensionsActivityMonitor* extensions_activity_monitor = NULL; |
| LoggingChangeDelegate change_delegate; |
| const char kRestoredKeyForBootstrapping[] = ""; |
| - const syncer::SyncManager::TestingMode kTestingMode = |
| - syncer::SyncManager::NON_TEST; |
| + const SyncManager::TestingMode kTestingMode = SyncManager::NON_TEST; |
| NullEncryptor null_encryptor; |
| LoggingUnrecoverableErrorHandler unrecoverable_error_handler; |
| sync_manager->Init(database_dir.path(), |
| - syncer::WeakHandle<syncer::JsEventHandler>( |
| + WeakHandle<JsEventHandler>( |
| js_event_handler.AsWeakPtr()), |
| kSyncServerAndPath, |
| kSyncServerPort, |
| @@ -364,15 +364,15 @@ int main(int argc, char* argv[]) { |
| extensions_activity_monitor, |
| &change_delegate, |
| credentials, |
| - scoped_ptr<syncer::SyncNotifier>( |
| + scoped_ptr<SyncNotifier>( |
| sync_notifier_factory.CreateSyncNotifier()), |
| kRestoredKeyForBootstrapping, |
| kTestingMode, |
| &null_encryptor, |
| &unrecoverable_error_handler, |
| &LogUnrecoverableErrorContext); |
| - // TODO(akalin): We have pass in model parameters multiple times. |
| - // Organize handling of model types. |
| + // TODO(akalin): Avoid passing in model parameters multiple times by |
| + // organizing handling of model types. |
| sync_manager->UpdateEnabledTypes(model_types); |
| sync_manager->StartSyncingNormally(routing_info); |