| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/debug/stack_trace.h" | 12 #include "base/debug/stack_trace.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 21 #include "base/task_runner.h" | 21 #include "base/task_runner.h" |
| 22 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
| 23 #include "jingle/notifier/base/notification_method.h" | 23 #include "jingle/notifier/base/notification_method.h" |
| 24 #include "jingle/notifier/base/notifier_options.h" | 24 #include "jingle/notifier/base/notifier_options.h" |
| 25 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
| 26 #include "net/base/network_change_notifier.h" | 26 #include "net/base/network_change_notifier.h" |
| 27 #include "net/dns/host_resolver.h" | 27 #include "net/dns/host_resolver.h" |
| 28 #include "net/http/transport_security_state.h" | 28 #include "net/http/transport_security_state.h" |
| 29 #include "net/url_request/url_request_test_util.h" | 29 #include "net/url_request/url_request_test_util.h" |
| 30 #include "sync/internal_api/public/base/cancellation_signal.h" |
| 30 #include "sync/internal_api/public/base/model_type.h" | 31 #include "sync/internal_api/public/base/model_type.h" |
| 31 #include "sync/internal_api/public/base_node.h" | 32 #include "sync/internal_api/public/base_node.h" |
| 32 #include "sync/internal_api/public/engine/passive_model_worker.h" | 33 #include "sync/internal_api/public/engine/passive_model_worker.h" |
| 33 #include "sync/internal_api/public/http_bridge.h" | 34 #include "sync/internal_api/public/http_bridge.h" |
| 34 #include "sync/internal_api/public/internal_components_factory_impl.h" | 35 #include "sync/internal_api/public/internal_components_factory_impl.h" |
| 35 #include "sync/internal_api/public/read_node.h" | 36 #include "sync/internal_api/public/read_node.h" |
| 36 #include "sync/internal_api/public/sync_manager.h" | 37 #include "sync/internal_api/public/sync_manager.h" |
| 37 #include "sync/internal_api/public/sync_manager_factory.h" | 38 #include "sync/internal_api/public/sync_manager_factory.h" |
| 38 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" | 39 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" |
| 39 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 40 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // as NULL. | 344 // as NULL. |
| 344 ExtensionsActivity* extensions_activity = NULL; | 345 ExtensionsActivity* extensions_activity = NULL; |
| 345 LoggingChangeDelegate change_delegate; | 346 LoggingChangeDelegate change_delegate; |
| 346 const char kRestoredKeyForBootstrapping[] = ""; | 347 const char kRestoredKeyForBootstrapping[] = ""; |
| 347 const char kRestoredKeystoreKeyForBootstrapping[] = ""; | 348 const char kRestoredKeystoreKeyForBootstrapping[] = ""; |
| 348 NullEncryptor null_encryptor; | 349 NullEncryptor null_encryptor; |
| 349 InternalComponentsFactoryImpl::Switches factory_switches = { | 350 InternalComponentsFactoryImpl::Switches factory_switches = { |
| 350 InternalComponentsFactory::ENCRYPTION_KEYSTORE, | 351 InternalComponentsFactory::ENCRYPTION_KEYSTORE, |
| 351 InternalComponentsFactory::BACKOFF_NORMAL | 352 InternalComponentsFactory::BACKOFF_NORMAL |
| 352 }; | 353 }; |
| 354 CancellationSignal cancellation_signal; |
| 353 | 355 |
| 354 sync_manager->Init(database_dir.path(), | 356 sync_manager->Init(database_dir.path(), |
| 355 WeakHandle<JsEventHandler>( | 357 WeakHandle<JsEventHandler>( |
| 356 js_event_handler.AsWeakPtr()), | 358 js_event_handler.AsWeakPtr()), |
| 357 kSyncServerAndPath, | 359 kSyncServerAndPath, |
| 358 kSyncServerPort, | 360 kSyncServerPort, |
| 359 kUseSsl, | 361 kUseSsl, |
| 360 post_factory.Pass(), | 362 post_factory.Pass(), |
| 361 workers, | 363 workers, |
| 362 extensions_activity, | 364 extensions_activity, |
| 363 &change_delegate, | 365 &change_delegate, |
| 364 credentials, | 366 credentials, |
| 365 invalidator_id, | 367 invalidator_id, |
| 366 kRestoredKeyForBootstrapping, | 368 kRestoredKeyForBootstrapping, |
| 367 kRestoredKeystoreKeyForBootstrapping, | 369 kRestoredKeystoreKeyForBootstrapping, |
| 368 new InternalComponentsFactoryImpl(factory_switches), | 370 new InternalComponentsFactoryImpl(factory_switches), |
| 369 &null_encryptor, | 371 &null_encryptor, |
| 370 scoped_ptr<UnrecoverableErrorHandler>( | 372 scoped_ptr<UnrecoverableErrorHandler>( |
| 371 new LoggingUnrecoverableErrorHandler).Pass(), | 373 new LoggingUnrecoverableErrorHandler).Pass(), |
| 372 &LogUnrecoverableErrorContext, false); | 374 &LogUnrecoverableErrorContext, false, |
| 375 &cancellation_signal); |
| 373 // TODO(akalin): Avoid passing in model parameters multiple times by | 376 // TODO(akalin): Avoid passing in model parameters multiple times by |
| 374 // organizing handling of model types. | 377 // organizing handling of model types. |
| 375 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); | 378 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); |
| 376 invalidator->RegisterHandler(sync_manager.get()); | 379 invalidator->RegisterHandler(sync_manager.get()); |
| 377 invalidator->UpdateRegisteredIds( | 380 invalidator->UpdateRegisteredIds( |
| 378 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); | 381 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); |
| 379 sync_manager->StartSyncingNormally(routing_info); | 382 sync_manager->StartSyncingNormally(routing_info); |
| 380 | 383 |
| 381 sync_loop.Run(); | 384 sync_loop.Run(); |
| 382 | 385 |
| 383 io_thread.Stop(); | 386 io_thread.Stop(); |
| 384 return 0; | 387 return 0; |
| 385 } | 388 } |
| 386 | 389 |
| 387 } // namespace | 390 } // namespace |
| 388 } // namespace syncer | 391 } // namespace syncer |
| 389 | 392 |
| 390 int main(int argc, char* argv[]) { | 393 int main(int argc, char* argv[]) { |
| 391 return syncer::SyncClientMain(argc, argv); | 394 return syncer::SyncClientMain(argc, argv); |
| 392 } | 395 } |
| OLD | NEW |