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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10911084: Implement Invalidator::Acknowledge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adapt patch to new TickClock interface Created 7 years, 9 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 "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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 InitializeBackend(!HasSyncSetupCompleted()); 490 InitializeBackend(!HasSyncSetupCompleted());
491 491
492 // |backend_| may end up being NULL here in tests (in synchronous 492 // |backend_| may end up being NULL here in tests (in synchronous
493 // initialization mode). 493 // initialization mode).
494 // 494 //
495 // TODO(akalin): Fix this horribly non-intuitive behavior (see 495 // TODO(akalin): Fix this horribly non-intuitive behavior (see
496 // http://crbug.com/140354). 496 // http://crbug.com/140354).
497 if (backend_.get()) { 497 if (backend_.get()) {
498 backend_->UpdateRegisteredInvalidationIds( 498 backend_->UpdateRegisteredInvalidationIds(
499 invalidator_registrar_->GetAllRegisteredIds()); 499 invalidator_registrar_->GetAllRegisteredIds());
500 for (AckHandleReplayQueue::const_iterator it = ack_replay_queue_.begin();
501 it != ack_replay_queue_.end(); ++it) {
502 backend_->AcknowledgeInvalidation(it->first, it->second);
503 }
504 ack_replay_queue_.clear();
500 } 505 }
501 506
502 if (!sync_global_error_.get()) { 507 if (!sync_global_error_.get()) {
503 #if !defined(OS_ANDROID) 508 #if !defined(OS_ANDROID)
504 sync_global_error_.reset(new SyncGlobalError(this, signin())); 509 sync_global_error_.reset(new SyncGlobalError(this, signin()));
505 #endif 510 #endif
506 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( 511 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
507 sync_global_error_.get()); 512 sync_global_error_.get());
508 AddObserver(sync_global_error_.get()); 513 AddObserver(sync_global_error_.get());
509 } 514 }
(...skipping 15 matching lines...) Expand all
525 backend_->UpdateRegisteredInvalidationIds( 530 backend_->UpdateRegisteredInvalidationIds(
526 invalidator_registrar_->GetAllRegisteredIds()); 531 invalidator_registrar_->GetAllRegisteredIds());
527 } 532 }
528 } 533 }
529 534
530 void ProfileSyncService::UnregisterInvalidationHandler( 535 void ProfileSyncService::UnregisterInvalidationHandler(
531 syncer::InvalidationHandler* handler) { 536 syncer::InvalidationHandler* handler) {
532 invalidator_registrar_->UnregisterHandler(handler); 537 invalidator_registrar_->UnregisterHandler(handler);
533 } 538 }
534 539
540 void ProfileSyncService::AcknowledgeInvalidation(
541 const invalidation::ObjectId& id,
542 const syncer::AckHandle& ack_handle) {
543 if (backend_.get()) {
544 backend_->AcknowledgeInvalidation(id, ack_handle);
545 } else {
546 // If |backend_| is NULL, save the acknowledgements to replay when
547 // it's created and initialized.
548 ack_replay_queue_.push_back(std::make_pair(id, ack_handle));
549 }
550 }
551
535 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { 552 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const {
536 return invalidator_registrar_->GetInvalidatorState(); 553 return invalidator_registrar_->GetInvalidatorState();
537 } 554 }
538 555
539 void ProfileSyncService::EmitInvalidationForTest( 556 void ProfileSyncService::EmitInvalidationForTest(
540 const invalidation::ObjectId& id, 557 const invalidation::ObjectId& id,
541 const std::string& payload) { 558 const std::string& payload) {
542 syncer::ObjectIdSet notify_ids; 559 syncer::ObjectIdSet notify_ids;
543 notify_ids.insert(id); 560 notify_ids.insert(id);
544 561
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1979 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1963 ProfileSyncService* old_this = this; 1980 ProfileSyncService* old_this = this;
1964 this->~ProfileSyncService(); 1981 this->~ProfileSyncService();
1965 new(old_this) ProfileSyncService( 1982 new(old_this) ProfileSyncService(
1966 new ProfileSyncComponentsFactoryImpl(profile, 1983 new ProfileSyncComponentsFactoryImpl(profile,
1967 CommandLine::ForCurrentProcess()), 1984 CommandLine::ForCurrentProcess()),
1968 profile, 1985 profile,
1969 signin, 1986 signin,
1970 behavior); 1987 behavior);
1971 } 1988 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698