| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <cstddef> | 5 #include <cstddef> |
| 6 #include <cstdio> | 6 #include <cstdio> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "sync/internal_api/public/internal_components_factory_impl.h" | 34 #include "sync/internal_api/public/internal_components_factory_impl.h" |
| 35 #include "sync/internal_api/public/read_node.h" | 35 #include "sync/internal_api/public/read_node.h" |
| 36 #include "sync/internal_api/public/sync_manager.h" | 36 #include "sync/internal_api/public/sync_manager.h" |
| 37 #include "sync/internal_api/public/sync_manager_factory.h" | 37 #include "sync/internal_api/public/sync_manager_factory.h" |
| 38 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 38 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 39 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 39 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 40 #include "sync/internal_api/public/util/weak_handle.h" | 40 #include "sync/internal_api/public/util/weak_handle.h" |
| 41 #include "sync/js/js_event_details.h" | 41 #include "sync/js/js_event_details.h" |
| 42 #include "sync/js/js_event_handler.h" | 42 #include "sync/js/js_event_handler.h" |
| 43 #include "sync/notifier/invalidation_state_tracker.h" | 43 #include "sync/notifier/invalidation_state_tracker.h" |
| 44 #include "sync/notifier/sync_notifier.h" | 44 #include "sync/notifier/invalidator_factory.h" |
| 45 #include "sync/notifier/sync_notifier_factory.h" | 45 #include "sync/notifier/invalidator.h" |
| 46 #include "sync/test/fake_encryptor.h" | 46 #include "sync/test/fake_encryptor.h" |
| 47 | 47 |
| 48 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
| 49 #include "base/mac/scoped_nsautorelease_pool.h" | 49 #include "base/mac/scoped_nsautorelease_pool.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 // This is a simple utility that initializes a sync client and | 52 // This is a simple utility that initializes a sync client and |
| 53 // prints out any events. | 53 // prints out any events. |
| 54 | 54 |
| 55 // TODO(akalin): Refactor to combine shared code with | 55 // TODO(akalin): Refactor to combine shared code with |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( | 301 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( |
| 302 net::NetworkChangeNotifier::Create()); | 302 net::NetworkChangeNotifier::Create()); |
| 303 | 303 |
| 304 // Set up sync notifier factory. | 304 // Set up sync notifier factory. |
| 305 const scoped_refptr<MyTestURLRequestContextGetter> context_getter = | 305 const scoped_refptr<MyTestURLRequestContextGetter> context_getter = |
| 306 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()); | 306 new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()); |
| 307 const notifier::NotifierOptions& notifier_options = | 307 const notifier::NotifierOptions& notifier_options = |
| 308 ParseNotifierOptions(command_line, context_getter); | 308 ParseNotifierOptions(command_line, context_getter); |
| 309 const char kClientInfo[] = "sync_listen_notifications"; | 309 const char kClientInfo[] = "sync_listen_notifications"; |
| 310 NullInvalidationStateTracker null_invalidation_state_tracker; | 310 NullInvalidationStateTracker null_invalidation_state_tracker; |
| 311 SyncNotifierFactory sync_notifier_factory( | 311 InvalidatorFactory invalidator_factory( |
| 312 notifier_options, kClientInfo, | 312 notifier_options, kClientInfo, |
| 313 null_invalidation_state_tracker.AsWeakPtr()); | 313 null_invalidation_state_tracker.AsWeakPtr()); |
| 314 | 314 |
| 315 // Set up database directory for the syncer. | 315 // Set up database directory for the syncer. |
| 316 ScopedTempDir database_dir; | 316 ScopedTempDir database_dir; |
| 317 CHECK(database_dir.CreateUniqueTempDir()); | 317 CHECK(database_dir.CreateUniqueTempDir()); |
| 318 | 318 |
| 319 // Set up model type parameters. | 319 // Set up model type parameters. |
| 320 const ModelTypeSet model_types = ModelTypeSet::All(); | 320 const ModelTypeSet model_types = ModelTypeSet::All(); |
| 321 ModelSafeRoutingInfo routing_info; | 321 ModelSafeRoutingInfo routing_info; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 js_event_handler.AsWeakPtr()), | 361 js_event_handler.AsWeakPtr()), |
| 362 kSyncServerAndPath, | 362 kSyncServerAndPath, |
| 363 kSyncServerPort, | 363 kSyncServerPort, |
| 364 kUseSsl, | 364 kUseSsl, |
| 365 blocking_task_runner, | 365 blocking_task_runner, |
| 366 post_factory.Pass(), | 366 post_factory.Pass(), |
| 367 workers, | 367 workers, |
| 368 extensions_activity_monitor, | 368 extensions_activity_monitor, |
| 369 &change_delegate, | 369 &change_delegate, |
| 370 credentials, | 370 credentials, |
| 371 scoped_ptr<SyncNotifier>( | 371 scoped_ptr<Invalidator>( |
| 372 sync_notifier_factory.CreateSyncNotifier()), | 372 invalidator_factory.CreateInvalidator()), |
| 373 kRestoredKeyForBootstrapping, | 373 kRestoredKeyForBootstrapping, |
| 374 kRestoredKeystoreKeyForBootstrapping, | 374 kRestoredKeystoreKeyForBootstrapping, |
| 375 scoped_ptr<InternalComponentsFactory>( | 375 scoped_ptr<InternalComponentsFactory>( |
| 376 new InternalComponentsFactoryImpl(factory_switches)), | 376 new InternalComponentsFactoryImpl(factory_switches)), |
| 377 &null_encryptor, | 377 &null_encryptor, |
| 378 &unrecoverable_error_handler, | 378 &unrecoverable_error_handler, |
| 379 &LogUnrecoverableErrorContext); | 379 &LogUnrecoverableErrorContext); |
| 380 // TODO(akalin): Avoid passing in model parameters multiple times by | 380 // TODO(akalin): Avoid passing in model parameters multiple times by |
| 381 // organizing handling of model types. | 381 // organizing handling of model types. |
| 382 sync_manager->UpdateEnabledTypes(model_types); | 382 sync_manager->UpdateEnabledTypes(model_types); |
| 383 sync_manager->StartSyncingNormally(routing_info); | 383 sync_manager->StartSyncingNormally(routing_info); |
| 384 | 384 |
| 385 sync_loop.Run(); | 385 sync_loop.Run(); |
| 386 | 386 |
| 387 io_thread.Stop(); | 387 io_thread.Stop(); |
| 388 return 0; | 388 return 0; |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace | 391 } // namespace |
| 392 } // namespace syncer | 392 } // namespace syncer |
| 393 | 393 |
| 394 int main(int argc, char* argv[]) { | 394 int main(int argc, char* argv[]) { |
| 395 return syncer::SyncClientMain(argc, argv); | 395 return syncer::SyncClientMain(argc, argv); |
| 396 } | 396 } |
| OLD | NEW |