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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 InitializeBackend(!HasSyncSetupCompleted()); | 495 InitializeBackend(!HasSyncSetupCompleted()); |
496 | 496 |
497 // |backend_| may end up being NULL here in tests (in synchronous | 497 // |backend_| may end up being NULL here in tests (in synchronous |
498 // initialization mode). | 498 // initialization mode). |
499 // | 499 // |
500 // TODO(akalin): Fix this horribly non-intuitive behavior (see | 500 // TODO(akalin): Fix this horribly non-intuitive behavior (see |
501 // http://crbug.com/140354). | 501 // http://crbug.com/140354). |
502 if (backend_.get()) { | 502 if (backend_.get()) { |
503 backend_->UpdateRegisteredInvalidationIds( | 503 backend_->UpdateRegisteredInvalidationIds( |
504 invalidator_registrar_->GetAllRegisteredIds()); | 504 invalidator_registrar_->GetAllRegisteredIds()); |
| 505 for (AckHandleReplayQueue::const_iterator it = ack_replay_queue_.begin(); |
| 506 it != ack_replay_queue_.end(); ++it) { |
| 507 backend_->AcknowledgeInvalidation(it->first, it->second); |
| 508 } |
| 509 ack_replay_queue_.clear(); |
505 } | 510 } |
506 | 511 |
507 if (!sync_global_error_.get()) { | 512 if (!sync_global_error_.get()) { |
508 #if !defined(OS_ANDROID) | 513 #if !defined(OS_ANDROID) |
509 sync_global_error_.reset(new SyncGlobalError(this, signin())); | 514 sync_global_error_.reset(new SyncGlobalError(this, signin())); |
510 #endif | 515 #endif |
511 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 516 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
512 sync_global_error_.get()); | 517 sync_global_error_.get()); |
513 AddObserver(sync_global_error_.get()); | 518 AddObserver(sync_global_error_.get()); |
514 } | 519 } |
(...skipping 15 matching lines...) Expand all Loading... |
530 backend_->UpdateRegisteredInvalidationIds( | 535 backend_->UpdateRegisteredInvalidationIds( |
531 invalidator_registrar_->GetAllRegisteredIds()); | 536 invalidator_registrar_->GetAllRegisteredIds()); |
532 } | 537 } |
533 } | 538 } |
534 | 539 |
535 void ProfileSyncService::UnregisterInvalidationHandler( | 540 void ProfileSyncService::UnregisterInvalidationHandler( |
536 syncer::InvalidationHandler* handler) { | 541 syncer::InvalidationHandler* handler) { |
537 invalidator_registrar_->UnregisterHandler(handler); | 542 invalidator_registrar_->UnregisterHandler(handler); |
538 } | 543 } |
539 | 544 |
| 545 void ProfileSyncService::AcknowledgeInvalidation( |
| 546 const invalidation::ObjectId& id, |
| 547 const syncer::AckHandle& ack_handle) { |
| 548 if (backend_.get()) { |
| 549 backend_->AcknowledgeInvalidation(id, ack_handle); |
| 550 } else { |
| 551 // If |backend_| is NULL, save the acknowledgements to replay when |
| 552 // it's created and initialized. |
| 553 ack_replay_queue_.push_back(std::make_pair(id, ack_handle)); |
| 554 } |
| 555 } |
| 556 |
540 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { | 557 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { |
541 return invalidator_registrar_->GetInvalidatorState(); | 558 return invalidator_registrar_->GetInvalidatorState(); |
542 } | 559 } |
543 | 560 |
544 void ProfileSyncService::EmitInvalidationForTest( | 561 void ProfileSyncService::EmitInvalidationForTest( |
545 const invalidation::ObjectId& id, | 562 const invalidation::ObjectId& id, |
546 const std::string& payload) { | 563 const std::string& payload) { |
547 syncer::ObjectIdSet notify_ids; | 564 syncer::ObjectIdSet notify_ids; |
548 notify_ids.insert(id); | 565 notify_ids.insert(id); |
549 | 566 |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1991 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
1975 ProfileSyncService* old_this = this; | 1992 ProfileSyncService* old_this = this; |
1976 this->~ProfileSyncService(); | 1993 this->~ProfileSyncService(); |
1977 new(old_this) ProfileSyncService( | 1994 new(old_this) ProfileSyncService( |
1978 new ProfileSyncComponentsFactoryImpl(profile, | 1995 new ProfileSyncComponentsFactoryImpl(profile, |
1979 CommandLine::ForCurrentProcess()), | 1996 CommandLine::ForCurrentProcess()), |
1980 profile, | 1997 profile, |
1981 signin, | 1998 signin, |
1982 behavior); | 1999 behavior); |
1983 } | 2000 } |
OLD | NEW |