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/cancelation_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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 sync_manager_factory.CreateSyncManager("sync_client manager"); | 328 sync_manager_factory.CreateSyncManager("sync_client manager"); |
328 LoggingJsEventHandler js_event_handler; | 329 LoggingJsEventHandler js_event_handler; |
329 const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev"; | 330 const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev"; |
330 int kSyncServerPort = 443; | 331 int kSyncServerPort = 443; |
331 bool kUseSsl = true; | 332 bool kUseSsl = true; |
332 // Used only by InitialProcessMetadata(), so it's okay to leave this as NULL. | 333 // Used only by InitialProcessMetadata(), so it's okay to leave this as NULL. |
333 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL; | 334 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL; |
334 const char kUserAgent[] = "sync_client"; | 335 const char kUserAgent[] = "sync_client"; |
335 // TODO(akalin): Replace this with just the context getter once | 336 // TODO(akalin): Replace this with just the context getter once |
336 // HttpPostProviderFactory is removed. | 337 // HttpPostProviderFactory is removed. |
| 338 CancelationSignal factory_cancelation_signal; |
337 scoped_ptr<HttpPostProviderFactory> post_factory( | 339 scoped_ptr<HttpPostProviderFactory> post_factory( |
338 new HttpBridgeFactory(context_getter.get(), | 340 new HttpBridgeFactory(context_getter.get(), |
339 kUserAgent, | 341 base::Bind(&StubNetworkTimeUpdateCallback), |
340 base::Bind(&StubNetworkTimeUpdateCallback))); | 342 &factory_cancelation_signal)); |
| 343 post_factory->Init(kUserAgent); |
341 // Used only when committing bookmarks, so it's okay to leave this | 344 // Used only when committing bookmarks, so it's okay to leave this |
342 // as NULL. | 345 // as NULL. |
343 ExtensionsActivity* extensions_activity = NULL; | 346 ExtensionsActivity* extensions_activity = NULL; |
344 LoggingChangeDelegate change_delegate; | 347 LoggingChangeDelegate change_delegate; |
345 const char kRestoredKeyForBootstrapping[] = ""; | 348 const char kRestoredKeyForBootstrapping[] = ""; |
346 const char kRestoredKeystoreKeyForBootstrapping[] = ""; | 349 const char kRestoredKeystoreKeyForBootstrapping[] = ""; |
347 NullEncryptor null_encryptor; | 350 NullEncryptor null_encryptor; |
348 InternalComponentsFactoryImpl::Switches factory_switches = { | 351 InternalComponentsFactoryImpl::Switches factory_switches = { |
349 InternalComponentsFactory::ENCRYPTION_KEYSTORE, | 352 InternalComponentsFactory::ENCRYPTION_KEYSTORE, |
350 InternalComponentsFactory::BACKOFF_NORMAL | 353 InternalComponentsFactory::BACKOFF_NORMAL |
351 }; | 354 }; |
| 355 CancelationSignal scm_cancelation_signal; |
352 | 356 |
353 sync_manager->Init(database_dir.path(), | 357 sync_manager->Init(database_dir.path(), |
354 WeakHandle<JsEventHandler>( | 358 WeakHandle<JsEventHandler>( |
355 js_event_handler.AsWeakPtr()), | 359 js_event_handler.AsWeakPtr()), |
356 kSyncServerAndPath, | 360 kSyncServerAndPath, |
357 kSyncServerPort, | 361 kSyncServerPort, |
358 kUseSsl, | 362 kUseSsl, |
359 post_factory.Pass(), | 363 post_factory.Pass(), |
360 workers, | 364 workers, |
361 extensions_activity, | 365 extensions_activity, |
362 &change_delegate, | 366 &change_delegate, |
363 credentials, | 367 credentials, |
364 invalidator_id, | 368 invalidator_id, |
365 kRestoredKeyForBootstrapping, | 369 kRestoredKeyForBootstrapping, |
366 kRestoredKeystoreKeyForBootstrapping, | 370 kRestoredKeystoreKeyForBootstrapping, |
367 new InternalComponentsFactoryImpl(factory_switches), | 371 new InternalComponentsFactoryImpl(factory_switches), |
368 &null_encryptor, | 372 &null_encryptor, |
369 scoped_ptr<UnrecoverableErrorHandler>( | 373 scoped_ptr<UnrecoverableErrorHandler>( |
370 new LoggingUnrecoverableErrorHandler).Pass(), | 374 new LoggingUnrecoverableErrorHandler).Pass(), |
371 &LogUnrecoverableErrorContext, false); | 375 &LogUnrecoverableErrorContext, false, |
| 376 &scm_cancelation_signal); |
372 // TODO(akalin): Avoid passing in model parameters multiple times by | 377 // TODO(akalin): Avoid passing in model parameters multiple times by |
373 // organizing handling of model types. | 378 // organizing handling of model types. |
374 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); | 379 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); |
375 invalidator->RegisterHandler(sync_manager.get()); | 380 invalidator->RegisterHandler(sync_manager.get()); |
376 invalidator->UpdateRegisteredIds( | 381 invalidator->UpdateRegisteredIds( |
377 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); | 382 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); |
378 sync_manager->StartSyncingNormally(routing_info); | 383 sync_manager->StartSyncingNormally(routing_info); |
379 | 384 |
380 sync_loop.Run(); | 385 sync_loop.Run(); |
381 | 386 |
382 io_thread.Stop(); | 387 io_thread.Stop(); |
383 return 0; | 388 return 0; |
384 } | 389 } |
385 | 390 |
386 } // namespace | 391 } // namespace |
387 } // namespace syncer | 392 } // namespace syncer |
388 | 393 |
389 int main(int argc, char* argv[]) { | 394 int main(int argc, char* argv[]) { |
390 return syncer::SyncClientMain(argc, argv); | 395 return syncer::SyncClientMain(argc, argv); |
391 } | 396 } |
OLD | NEW |