Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: sync/tools/sync_client.cc

Issue 23189021: sync: Gracefully handle very early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Retry: sync non-blocking early shutdown Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/test/engine/mock_connection_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // as NULL. 343 // as NULL.
343 ExtensionsActivity* extensions_activity = NULL; 344 ExtensionsActivity* extensions_activity = NULL;
344 LoggingChangeDelegate change_delegate; 345 LoggingChangeDelegate change_delegate;
345 const char kRestoredKeyForBootstrapping[] = ""; 346 const char kRestoredKeyForBootstrapping[] = "";
346 const char kRestoredKeystoreKeyForBootstrapping[] = ""; 347 const char kRestoredKeystoreKeyForBootstrapping[] = "";
347 NullEncryptor null_encryptor; 348 NullEncryptor null_encryptor;
348 InternalComponentsFactoryImpl::Switches factory_switches = { 349 InternalComponentsFactoryImpl::Switches factory_switches = {
349 InternalComponentsFactory::ENCRYPTION_KEYSTORE, 350 InternalComponentsFactory::ENCRYPTION_KEYSTORE,
350 InternalComponentsFactory::BACKOFF_NORMAL 351 InternalComponentsFactory::BACKOFF_NORMAL
351 }; 352 };
353 CancelationSignal cancelation_signal;
352 354
353 sync_manager->Init(database_dir.path(), 355 sync_manager->Init(database_dir.path(),
354 WeakHandle<JsEventHandler>( 356 WeakHandle<JsEventHandler>(
355 js_event_handler.AsWeakPtr()), 357 js_event_handler.AsWeakPtr()),
356 kSyncServerAndPath, 358 kSyncServerAndPath,
357 kSyncServerPort, 359 kSyncServerPort,
358 kUseSsl, 360 kUseSsl,
359 post_factory.Pass(), 361 post_factory.Pass(),
360 workers, 362 workers,
361 extensions_activity, 363 extensions_activity,
362 &change_delegate, 364 &change_delegate,
363 credentials, 365 credentials,
364 invalidator_id, 366 invalidator_id,
365 kRestoredKeyForBootstrapping, 367 kRestoredKeyForBootstrapping,
366 kRestoredKeystoreKeyForBootstrapping, 368 kRestoredKeystoreKeyForBootstrapping,
367 new InternalComponentsFactoryImpl(factory_switches), 369 new InternalComponentsFactoryImpl(factory_switches),
368 &null_encryptor, 370 &null_encryptor,
369 scoped_ptr<UnrecoverableErrorHandler>( 371 scoped_ptr<UnrecoverableErrorHandler>(
370 new LoggingUnrecoverableErrorHandler).Pass(), 372 new LoggingUnrecoverableErrorHandler).Pass(),
371 &LogUnrecoverableErrorContext, false); 373 &LogUnrecoverableErrorContext, false,
374 &cancelation_signal);
372 // TODO(akalin): Avoid passing in model parameters multiple times by 375 // TODO(akalin): Avoid passing in model parameters multiple times by
373 // organizing handling of model types. 376 // organizing handling of model types.
374 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); 377 invalidator->UpdateCredentials(credentials.email, credentials.sync_token);
375 invalidator->RegisterHandler(sync_manager.get()); 378 invalidator->RegisterHandler(sync_manager.get());
376 invalidator->UpdateRegisteredIds( 379 invalidator->UpdateRegisteredIds(
377 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types)); 380 sync_manager.get(), ModelTypeSetToObjectIdSet(model_types));
378 sync_manager->StartSyncingNormally(routing_info); 381 sync_manager->StartSyncingNormally(routing_info);
379 382
380 sync_loop.Run(); 383 sync_loop.Run();
381 384
382 io_thread.Stop(); 385 io_thread.Stop();
383 return 0; 386 return 0;
384 } 387 }
385 388
386 } // namespace 389 } // namespace
387 } // namespace syncer 390 } // namespace syncer
388 391
389 int main(int argc, char* argv[]) { 392 int main(int argc, char* argv[]) {
390 return syncer::SyncClientMain(argc, argv); 393 return syncer::SyncClientMain(argc, argv);
391 } 394 }
OLDNEW
« no previous file with comments | « sync/test/engine/mock_connection_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698