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

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

Issue 10704214: [Sync] Refactor sync manager into interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Comments Created 8 years, 5 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
« chrome/browser/sync/glue/sync_backend_host.cc ('K') | « sync/sync.gyp ('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/base64.h" 10 #include "base/base64.h"
(...skipping 14 matching lines...) Expand all
25 #include "net/base/host_port_pair.h" 25 #include "net/base/host_port_pair.h"
26 #include "net/base/host_resolver.h" 26 #include "net/base/host_resolver.h"
27 #include "net/base/network_change_notifier.h" 27 #include "net/base/network_change_notifier.h"
28 #include "net/url_request/url_request_test_util.h" 28 #include "net/url_request/url_request_test_util.h"
29 #include "sync/internal_api/public/base/model_type.h" 29 #include "sync/internal_api/public/base/model_type.h"
30 #include "sync/internal_api/public/base_node.h" 30 #include "sync/internal_api/public/base_node.h"
31 #include "sync/internal_api/public/engine/passive_model_worker.h" 31 #include "sync/internal_api/public/engine/passive_model_worker.h"
32 #include "sync/internal_api/public/http_bridge.h" 32 #include "sync/internal_api/public/http_bridge.h"
33 #include "sync/internal_api/public/read_node.h" 33 #include "sync/internal_api/public/read_node.h"
34 #include "sync/internal_api/public/sync_manager.h" 34 #include "sync/internal_api/public/sync_manager.h"
35 #include "sync/internal_api/public/sync_manager_factory.h"
35 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h" 36 #include "sync/internal_api/public/util/report_unrecoverable_error_function.h"
36 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" 37 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
37 #include "sync/internal_api/public/util/weak_handle.h" 38 #include "sync/internal_api/public/util/weak_handle.h"
38 #include "sync/js/js_event_details.h" 39 #include "sync/js/js_event_details.h"
39 #include "sync/js/js_event_handler.h" 40 #include "sync/js/js_event_handler.h"
40 #include "sync/notifier/invalidation_state_tracker.h" 41 #include "sync/notifier/invalidation_state_tracker.h"
42 #include "sync/notifier/sync_notifier.h"
41 #include "sync/notifier/sync_notifier_factory.h" 43 #include "sync/notifier/sync_notifier_factory.h"
42 #include "sync/test/fake_encryptor.h" 44 #include "sync/test/fake_encryptor.h"
43 45
44 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
45 #include "base/mac/scoped_nsautorelease_pool.h" 47 #include "base/mac/scoped_nsautorelease_pool.h"
46 #endif 48 #endif
47 49
48 // This is a simple utility that initializes a sync client and 50 // This is a simple utility that initializes a sync client and
49 // prints out any events. 51 // prints out any events.
50 52
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 for (syncer::ModelTypeSet::Iterator it = model_types.First(); 321 for (syncer::ModelTypeSet::Iterator it = model_types.First();
320 it.Good(); it.Inc()) { 322 it.Good(); it.Inc()) {
321 routing_info[it.Get()] = syncer::GROUP_PASSIVE; 323 routing_info[it.Get()] = syncer::GROUP_PASSIVE;
322 } 324 }
323 scoped_refptr<syncer::PassiveModelWorker> passive_model_safe_worker = 325 scoped_refptr<syncer::PassiveModelWorker> passive_model_safe_worker =
324 new syncer::PassiveModelWorker(&sync_loop); 326 new syncer::PassiveModelWorker(&sync_loop);
325 std::vector<syncer::ModelSafeWorker*> workers; 327 std::vector<syncer::ModelSafeWorker*> workers;
326 workers.push_back(passive_model_safe_worker.get()); 328 workers.push_back(passive_model_safe_worker.get());
327 329
328 // Set up sync manager. 330 // Set up sync manager.
329 syncer::SyncManager sync_manager("sync_client manager"); 331 syncer::SyncManagerFactory sync_manager_factory;
332 scoped_ptr<syncer::SyncManager> sync_manager =
333 sync_manager_factory.CreateSyncManager("sync_client manager");
330 LoggingJsEventHandler js_event_handler; 334 LoggingJsEventHandler js_event_handler;
331 const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev"; 335 const char kSyncServerAndPath[] = "clients4.google.com/chrome-sync/dev";
332 int kSyncServerPort = 443; 336 int kSyncServerPort = 443;
333 bool kUseSsl = true; 337 bool kUseSsl = true;
334 // Used only by RefreshNigori(), so it's okay to leave this as NULL. 338 // Used only by RefreshNigori(), so it's okay to leave this as NULL.
335 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL; 339 const scoped_refptr<base::TaskRunner> blocking_task_runner = NULL;
336 const char kUserAgent[] = "sync_client"; 340 const char kUserAgent[] = "sync_client";
337 // TODO(akalin): Replace this with just the context getter once 341 // TODO(akalin): Replace this with just the context getter once
338 // HttpPostProviderFactory is removed. 342 // HttpPostProviderFactory is removed.
339 scoped_ptr<syncer::HttpPostProviderFactory> post_factory( 343 scoped_ptr<syncer::HttpPostProviderFactory> post_factory(
340 new syncer::HttpBridgeFactory(context_getter, kUserAgent)); 344 new syncer::HttpBridgeFactory(context_getter, kUserAgent));
341 // Used only when committing bookmarks, so it's okay to leave this 345 // Used only when committing bookmarks, so it's okay to leave this
342 // as NULL. 346 // as NULL.
343 syncer::ExtensionsActivityMonitor* extensions_activity_monitor = NULL; 347 syncer::ExtensionsActivityMonitor* extensions_activity_monitor = NULL;
344 LoggingChangeDelegate change_delegate; 348 LoggingChangeDelegate change_delegate;
345 const char kRestoredKeyForBootstrapping[] = ""; 349 const char kRestoredKeyForBootstrapping[] = "";
346 const syncer::SyncManager::TestingMode kTestingMode = 350 const syncer::SyncManager::TestingMode kTestingMode =
347 syncer::SyncManager::NON_TEST; 351 syncer::SyncManager::NON_TEST;
348 NullEncryptor null_encryptor; 352 NullEncryptor null_encryptor;
349 LoggingUnrecoverableErrorHandler unrecoverable_error_handler; 353 LoggingUnrecoverableErrorHandler unrecoverable_error_handler;
350 sync_manager.Init(database_dir.path(), 354 sync_manager->Init(database_dir.path(),
351 syncer::WeakHandle<syncer::JsEventHandler>( 355 syncer::WeakHandle<syncer::JsEventHandler>(
352 js_event_handler.AsWeakPtr()), 356 js_event_handler.AsWeakPtr()),
353 kSyncServerAndPath, 357 kSyncServerAndPath,
354 kSyncServerPort, 358 kSyncServerPort,
355 kUseSsl, 359 kUseSsl,
356 blocking_task_runner, 360 blocking_task_runner,
357 post_factory.release(), 361 post_factory.Pass(),
358 routing_info, 362 routing_info,
359 workers, 363 workers,
360 extensions_activity_monitor, 364 extensions_activity_monitor,
361 &change_delegate, 365 &change_delegate,
362 credentials, 366 credentials,
363 sync_notifier_factory.CreateSyncNotifier(), 367 scoped_ptr<syncer::SyncNotifier>(
368 sync_notifier_factory.CreateSyncNotifier()),
364 kRestoredKeyForBootstrapping, 369 kRestoredKeyForBootstrapping,
365 kTestingMode, 370 kTestingMode,
366 &null_encryptor, 371 &null_encryptor,
367 &unrecoverable_error_handler, 372 &unrecoverable_error_handler,
368 &LogUnrecoverableErrorContext); 373 &LogUnrecoverableErrorContext);
369 // TODO(akalin): We have pass in model parameters multiple times. 374 // TODO(akalin): We have pass in model parameters multiple times.
370 // Organize handling of model types. 375 // Organize handling of model types.
371 sync_manager.UpdateEnabledTypes(model_types); 376 sync_manager->UpdateEnabledTypes(model_types);
372 sync_manager.StartSyncingNormally(routing_info); 377 sync_manager->StartSyncingNormally(routing_info);
373 378
374 sync_loop.Run(); 379 sync_loop.Run();
375 380
376 io_thread.Stop(); 381 io_thread.Stop();
377 return 0; 382 return 0;
378 } 383 }
OLDNEW
« chrome/browser/sync/glue/sync_backend_host.cc ('K') | « sync/sync.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698