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

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 10911073: NOT FOR COMMIT: Add DeviceInfo type and ChangeProcessor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix several issues Created 8 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/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | 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 "sync/internal_api/sync_manager_impl.h" 5 #include "sync/internal_api/sync_manager_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 29 matching lines...) Expand all
40 #include "sync/js/js_event_handler.h" 40 #include "sync/js/js_event_handler.h"
41 #include "sync/js/js_reply_handler.h" 41 #include "sync/js/js_reply_handler.h"
42 #include "sync/notifier/invalidation_util.h" 42 #include "sync/notifier/invalidation_util.h"
43 #include "sync/notifier/invalidator.h" 43 #include "sync/notifier/invalidator.h"
44 #include "sync/protocol/proto_value_conversions.h" 44 #include "sync/protocol/proto_value_conversions.h"
45 #include "sync/protocol/sync.pb.h" 45 #include "sync/protocol/sync.pb.h"
46 #include "sync/syncable/directory.h" 46 #include "sync/syncable/directory.h"
47 #include "sync/syncable/entry.h" 47 #include "sync/syncable/entry.h"
48 #include "sync/syncable/in_memory_directory_backing_store.h" 48 #include "sync/syncable/in_memory_directory_backing_store.h"
49 #include "sync/syncable/on_disk_directory_backing_store.h" 49 #include "sync/syncable/on_disk_directory_backing_store.h"
50 #include "sync/util/get_session_name.h"
51 50
52 using base::TimeDelta; 51 using base::TimeDelta;
53 using sync_pb::GetUpdatesCallerInfo; 52 using sync_pb::GetUpdatesCallerInfo;
54 53
55 namespace syncer { 54 namespace syncer {
56 55
57 using sessions::SyncSessionContext; 56 using sessions::SyncSessionContext;
58 using syncable::ImmutableWriteTransactionInfo; 57 using syncable::ImmutableWriteTransactionInfo;
59 using syncable::SPECIFICS; 58 using syncable::SPECIFICS;
60 59
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 retry_task.Run(); 335 retry_task.Run();
337 336
338 } 337 }
339 338
340 void SyncManagerImpl::Init( 339 void SyncManagerImpl::Init(
341 const FilePath& database_location, 340 const FilePath& database_location,
342 const WeakHandle<JsEventHandler>& event_handler, 341 const WeakHandle<JsEventHandler>& event_handler,
343 const std::string& sync_server_and_path, 342 const std::string& sync_server_and_path,
344 int port, 343 int port,
345 bool use_ssl, 344 bool use_ssl,
346 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
347 scoped_ptr<HttpPostProviderFactory> post_factory, 345 scoped_ptr<HttpPostProviderFactory> post_factory,
348 const std::vector<ModelSafeWorker*>& workers, 346 const std::vector<ModelSafeWorker*>& workers,
349 ExtensionsActivityMonitor* extensions_activity_monitor, 347 ExtensionsActivityMonitor* extensions_activity_monitor,
350 SyncManager::ChangeDelegate* change_delegate, 348 SyncManager::ChangeDelegate* change_delegate,
351 const SyncCredentials& credentials, 349 const SyncCredentials& credentials,
352 scoped_ptr<Invalidator> invalidator, 350 scoped_ptr<Invalidator> invalidator,
353 const std::string& restored_key_for_bootstrapping, 351 const std::string& restored_key_for_bootstrapping,
354 const std::string& restored_keystore_key_for_bootstrapping, 352 const std::string& restored_keystore_key_for_bootstrapping,
355 scoped_ptr<InternalComponentsFactory> internal_components_factory, 353 scoped_ptr<InternalComponentsFactory> internal_components_factory,
356 Encryptor* encryptor, 354 Encryptor* encryptor,
357 UnrecoverableErrorHandler* unrecoverable_error_handler, 355 UnrecoverableErrorHandler* unrecoverable_error_handler,
358 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) { 356 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) {
359 CHECK(!initialized_); 357 CHECK(!initialized_);
360 DCHECK(thread_checker_.CalledOnValidThread()); 358 DCHECK(thread_checker_.CalledOnValidThread());
361 DCHECK(post_factory.get()); 359 DCHECK(post_factory.get());
362 DCHECK(!credentials.email.empty()); 360 DCHECK(!credentials.email.empty());
363 DCHECK(!credentials.sync_token.empty()); 361 DCHECK(!credentials.sync_token.empty());
364 DVLOG(1) << "SyncManager starting Init..."; 362 DVLOG(1) << "SyncManager starting Init...";
365 363
366 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()); 364 weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr());
367 365
368 blocking_task_runner_ = blocking_task_runner;
369
370 change_delegate_ = change_delegate; 366 change_delegate_ = change_delegate;
371 367
372 invalidator_ = invalidator.Pass(); 368 invalidator_ = invalidator.Pass();
373 invalidator_->RegisterHandler(this); 369 invalidator_->RegisterHandler(this);
374 370
375 AddObserver(&js_sync_manager_observer_); 371 AddObserver(&js_sync_manager_observer_);
376 SetJsEventHandler(event_handler); 372 SetJsEventHandler(event_handler);
377 373
378 AddObserver(&debug_info_event_listener_); 374 AddObserver(&debug_info_event_listener_);
379 375
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 observing_ip_address_changes_ = true; 462 observing_ip_address_changes_ = true;
467 463
468 UpdateCredentials(credentials); 464 UpdateCredentials(credentials);
469 465
470 FOR_EACH_OBSERVER(SyncManager::Observer, observers_, 466 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
471 OnInitializationComplete( 467 OnInitializationComplete(
472 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()), 468 MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
473 true, InitialSyncEndedTypes())); 469 true, InitialSyncEndedTypes()));
474 } 470 }
475 471
476 void SyncManagerImpl::UpdateSessionNameCallback(
477 const std::string& chrome_version,
478 const std::string& session_name) {
479 WriteTransaction trans(FROM_HERE, GetUserShare());
480 WriteNode node(&trans);
481 // TODO(rlarocque): switch to device info node.
482 if (node.InitByTagLookup(syncer::kNigoriTag) != syncer::BaseNode::INIT_OK) {
483 return;
484 }
485
486 sync_pb::NigoriSpecifics nigori(node.GetNigoriSpecifics());
487 // Add or update device information.
488 bool contains_this_device = false;
489 for (int i = 0; i < nigori.device_information_size(); ++i) {
490 const sync_pb::DeviceInformation& device_information =
491 nigori.device_information(i);
492 if (device_information.cache_guid() == directory()->cache_guid()) {
493 // Update the version number in case it changed due to an update.
494 if (device_information.chrome_version() != chrome_version) {
495 sync_pb::DeviceInformation* mutable_device_information =
496 nigori.mutable_device_information(i);
497 mutable_device_information->set_chrome_version(
498 chrome_version);
499 }
500 contains_this_device = true;
501 }
502 }
503
504 if (!contains_this_device) {
505 sync_pb::DeviceInformation* device_information =
506 nigori.add_device_information();
507 device_information->set_cache_guid(directory()->cache_guid());
508 #if defined(OS_CHROMEOS)
509 device_information->set_platform("ChromeOS");
510 #elif defined(OS_LINUX)
511 device_information->set_platform("Linux");
512 #elif defined(OS_MACOSX)
513 device_information->set_platform("Mac");
514 #elif defined(OS_WIN)
515 device_information->set_platform("Windows");
516 #endif
517 device_information->set_name(session_name);
518 device_information->set_chrome_version(chrome_version);
519 }
520 node.SetNigoriSpecifics(nigori);
521 }
522
523
524 void SyncManagerImpl::OnPassphraseRequired( 472 void SyncManagerImpl::OnPassphraseRequired(
525 PassphraseRequiredReason reason, 473 PassphraseRequiredReason reason,
526 const sync_pb::EncryptedData& pending_keys) { 474 const sync_pb::EncryptedData& pending_keys) {
527 // Does nothing. 475 // Does nothing.
528 } 476 }
529 477
530 void SyncManagerImpl::OnPassphraseAccepted() { 478 void SyncManagerImpl::OnPassphraseAccepted() {
531 // Does nothing. 479 // Does nothing.
532 } 480 }
533 481
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 int SyncManagerImpl::GetDefaultNudgeDelay() { 1294 int SyncManagerImpl::GetDefaultNudgeDelay() {
1347 return kDefaultNudgeDelayMilliseconds; 1295 return kDefaultNudgeDelayMilliseconds;
1348 } 1296 }
1349 1297
1350 // static. 1298 // static.
1351 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1299 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1352 return kPreferencesNudgeDelayMilliseconds; 1300 return kPreferencesNudgeDelayMilliseconds;
1353 } 1301 }
1354 1302
1355 } // namespace syncer 1303 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698