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

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

Issue 442403003: Update SyncManager::Init to use a GURL for the sync server URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_client.cc too. Created 6 years, 4 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
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"
(...skipping 28 matching lines...) Expand all
39 #include "sync/internal_api/public/sync_manager.h" 39 #include "sync/internal_api/public/sync_manager.h"
40 #include "sync/internal_api/public/sync_manager_factory.h" 40 #include "sync/internal_api/public/sync_manager_factory.h"
41 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 41 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
42 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 42 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
43 #include "sync/internal_api/public/util/weak_handle.h" 43 #include "sync/internal_api/public/util/weak_handle.h"
44 #include "sync/js/js_event_details.h" 44 #include "sync/js/js_event_details.h"
45 #include "sync/js/js_event_handler.h" 45 #include "sync/js/js_event_handler.h"
46 #include "sync/test/fake_encryptor.h" 46 #include "sync/test/fake_encryptor.h"
47 #include "sync/tools/invalidation_helper.h" 47 #include "sync/tools/invalidation_helper.h"
48 #include "sync/tools/null_invalidation_state_tracker.h" 48 #include "sync/tools/null_invalidation_state_tracker.h"
49 #include "url/gurl.h"
49 50
50 #if defined(OS_MACOSX) 51 #if defined(OS_MACOSX)
51 #include "base/mac/scoped_nsautorelease_pool.h" 52 #include "base/mac/scoped_nsautorelease_pool.h"
52 #endif 53 #endif
53 54
54 // This is a simple utility that initializes a sync client and 55 // This is a simple utility that initializes a sync client and
55 // prints out any events. 56 // prints out any events.
56 57
57 // TODO(akalin): Refactor to combine shared code with 58 // TODO(akalin): Refactor to combine shared code with
58 // sync_listen_notifications. 59 // sync_listen_notifications.
59 namespace syncer { 60 namespace syncer {
60 namespace { 61 namespace {
61 62
62 const char kEmailSwitch[] = "email"; 63 const char kEmailSwitch[] = "email";
63 const char kTokenSwitch[] = "token"; 64 const char kTokenSwitch[] = "token";
64 const char kXmppHostPortSwitch[] = "xmpp-host-port"; 65 const char kXmppHostPortSwitch[] = "xmpp-host-port";
65 const char kXmppTrySslTcpFirstSwitch[] = "xmpp-try-ssltcp-first"; 66 const char kXmppTrySslTcpFirstSwitch[] = "xmpp-try-ssltcp-first";
66 const char kXmppAllowInsecureConnectionSwitch[] = 67 const char kXmppAllowInsecureConnectionSwitch[] =
67 "xmpp-allow-insecure-connection"; 68 "xmpp-allow-insecure-connection";
69 const char kSyncServiceURL[] = "https://clients4.google.com/chrome-sync/dev";
68 70
69 // Needed to use a real host resolver. 71 // Needed to use a real host resolver.
70 class MyTestURLRequestContext : public net::TestURLRequestContext { 72 class MyTestURLRequestContext : public net::TestURLRequestContext {
71 public: 73 public:
72 MyTestURLRequestContext() : TestURLRequestContext(true) { 74 MyTestURLRequestContext() : TestURLRequestContext(true) {
73 context_storage_.set_host_resolver( 75 context_storage_.set_host_resolver(
74 net::HostResolver::CreateDefaultResolver(NULL)); 76 net::HostResolver::CreateDefaultResolver(NULL));
75 context_storage_.set_transport_security_state( 77 context_storage_.set_transport_security_state(
76 new net::TransportSecurityState()); 78 new net::TransportSecurityState());
77 Init(); 79 Init();
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 scoped_refptr<PassiveModelWorker> passive_model_safe_worker = 399 scoped_refptr<PassiveModelWorker> passive_model_safe_worker =
398 new PassiveModelWorker(&sync_loop, NULL); 400 new PassiveModelWorker(&sync_loop, NULL);
399 std::vector<scoped_refptr<ModelSafeWorker> > workers; 401 std::vector<scoped_refptr<ModelSafeWorker> > workers;
400 workers.push_back(passive_model_safe_worker); 402 workers.push_back(passive_model_safe_worker);
401 403
402 // Set up sync manager. 404 // Set up sync manager.
403 SyncManagerFactory sync_manager_factory(SyncManagerFactory::NORMAL); 405 SyncManagerFactory sync_manager_factory(SyncManagerFactory::NORMAL);
404 scoped_ptr<SyncManager> sync_manager = 406 scoped_ptr<SyncManager> sync_manager =
405 sync_manager_factory.CreateSyncManager("sync_client manager"); 407 sync_manager_factory.CreateSyncManager("sync_client manager");
406 LoggingJsEventHandler js_event_handler; 408 LoggingJsEventHandler js_event_handler;
407 const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev";
408 int kSyncServerPort = 443;
409 bool kUseSsl = true;
410 // Used only by InitialProcessMetadata(), so it's okay to leave this as NULL. 409 // Used only by InitialProcessMetadata(), so it's okay to leave this as NULL.
411 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL; 410 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL;
412 const char kUserAgent[] = "sync_client"; 411 const char kUserAgent[] = "sync_client";
413 // TODO(akalin): Replace this with just the context getter once 412 // TODO(akalin): Replace this with just the context getter once
414 // HttpPostProviderFactory is removed. 413 // HttpPostProviderFactory is removed.
415 CancelationSignal factory_cancelation_signal; 414 CancelationSignal factory_cancelation_signal;
416 scoped_ptr<HttpPostProviderFactory> post_factory( 415 scoped_ptr<HttpPostProviderFactory> post_factory(
417 new HttpBridgeFactory(context_getter.get(), 416 new HttpBridgeFactory(context_getter.get(),
418 base::Bind(&StubNetworkTimeUpdateCallback), 417 base::Bind(&StubNetworkTimeUpdateCallback),
419 &factory_cancelation_signal)); 418 &factory_cancelation_signal));
420 post_factory->Init(kUserAgent); 419 post_factory->Init(kUserAgent);
421 // Used only when committing bookmarks, so it's okay to leave this 420 // Used only when committing bookmarks, so it's okay to leave this
422 // as NULL. 421 // as NULL.
423 ExtensionsActivity* extensions_activity = NULL; 422 ExtensionsActivity* extensions_activity = NULL;
424 LoggingChangeDelegate change_delegate; 423 LoggingChangeDelegate change_delegate;
425 const char kRestoredKeyForBootstrapping[] = ""; 424 const char kRestoredKeyForBootstrapping[] = "";
426 const char kRestoredKeystoreKeyForBootstrapping[] = ""; 425 const char kRestoredKeystoreKeyForBootstrapping[] = "";
427 NullEncryptor null_encryptor; 426 NullEncryptor null_encryptor;
428 InternalComponentsFactoryImpl::Switches factory_switches = { 427 InternalComponentsFactoryImpl::Switches factory_switches = {
429 InternalComponentsFactory::ENCRYPTION_KEYSTORE, 428 InternalComponentsFactory::ENCRYPTION_KEYSTORE,
430 InternalComponentsFactory::BACKOFF_NORMAL 429 InternalComponentsFactory::BACKOFF_NORMAL
431 }; 430 };
432 CancelationSignal scm_cancelation_signal; 431 CancelationSignal scm_cancelation_signal;
433 432
434 sync_manager->Init(database_dir.path(), 433 sync_manager->Init(database_dir.path(),
435 WeakHandle<JsEventHandler>( 434 WeakHandle<JsEventHandler>(js_event_handler.AsWeakPtr()),
436 js_event_handler.AsWeakPtr()), 435 GURL(kSyncServiceURL),
437 kSyncServerAndPath, 436 post_factory.Pass(),
438 kSyncServerPort, 437 workers,
439 kUseSsl, 438 extensions_activity,
440 post_factory.Pass(), 439 &change_delegate,
441 workers, 440 credentials,
442 extensions_activity, 441 invalidator_id,
443 &change_delegate, 442 kRestoredKeyForBootstrapping,
444 credentials, 443 kRestoredKeystoreKeyForBootstrapping,
445 invalidator_id, 444 new InternalComponentsFactoryImpl(factory_switches),
446 kRestoredKeyForBootstrapping, 445 &null_encryptor,
447 kRestoredKeystoreKeyForBootstrapping, 446 scoped_ptr<UnrecoverableErrorHandler>(
448 new InternalComponentsFactoryImpl(factory_switches), 447 new LoggingUnrecoverableErrorHandler).Pass(),
449 &null_encryptor, 448 &LogUnrecoverableErrorContext,
450 scoped_ptr<UnrecoverableErrorHandler>( 449 &scm_cancelation_signal);
451 new LoggingUnrecoverableErrorHandler).Pass(),
452 &LogUnrecoverableErrorContext,
453 &scm_cancelation_signal);
454 // TODO(akalin): Avoid passing in model parameters multiple times by 450 // TODO(akalin): Avoid passing in model parameters multiple times by
455 // organizing handling of model types. 451 // organizing handling of model types.
456 invalidator->UpdateCredentials(credentials.email, credentials.sync_token); 452 invalidator->UpdateCredentials(credentials.email, credentials.sync_token);
457 scoped_ptr<InvalidatorShim> shim(new InvalidatorShim(sync_manager.get())); 453 scoped_ptr<InvalidatorShim> shim(new InvalidatorShim(sync_manager.get()));
458 invalidator->RegisterHandler(shim.get()); 454 invalidator->RegisterHandler(shim.get());
459 invalidator->UpdateRegisteredIds( 455 invalidator->UpdateRegisteredIds(
460 shim.get(), ModelTypeSetToObjectIdSet(model_types)); 456 shim.get(), ModelTypeSetToObjectIdSet(model_types));
461 sync_manager->StartSyncingNormally(routing_info); 457 sync_manager->StartSyncingNormally(routing_info);
462 458
463 sync_loop.Run(); 459 sync_loop.Run();
464 460
465 io_thread.Stop(); 461 io_thread.Stop();
466 return 0; 462 return 0;
467 } 463 }
468 464
469 } // namespace 465 } // namespace
470 } // namespace syncer 466 } // namespace syncer
471 467
472 int main(int argc, char* argv[]) { 468 int main(int argc, char* argv[]) {
473 return syncer::SyncClientMain(argc, argv); 469 return syncer::SyncClientMain(argc, argv);
474 } 470 }
OLDNEW
« sync/internal_api/sync_manager_impl.cc ('K') | « sync/internal_api/test/fake_sync_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698