Chromium Code Reviews| 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 InitializeBackend(!HasSyncSetupCompleted()); | 491 InitializeBackend(!HasSyncSetupCompleted()); |
| 492 | 492 |
| 493 // |backend_| may end up being NULL here in tests (in synchronous | 493 // |backend_| may end up being NULL here in tests (in synchronous |
| 494 // initialization mode). | 494 // initialization mode). |
| 495 // | 495 // |
| 496 // TODO(akalin): Fix this horribly non-intuitive behavior (see | 496 // TODO(akalin): Fix this horribly non-intuitive behavior (see |
| 497 // http://crbug.com/140354). | 497 // http://crbug.com/140354). |
| 498 if (backend_.get()) { | 498 if (backend_.get()) { |
| 499 backend_->UpdateRegisteredInvalidationIds( | 499 backend_->UpdateRegisteredInvalidationIds( |
| 500 invalidator_registrar_->GetAllRegisteredIds()); | 500 invalidator_registrar_->GetAllRegisteredIds()); |
| 501 for (AckHandleReplayQueue::const_iterator it = ack_replay_queue_.begin(); | |
|
rlarocque
2013/02/12 21:48:04
I don't like the way this code (or the line above
dcheng
2013/02/12 22:39:28
I don't mind fixing this, but perhaps it would be
| |
| 502 it != ack_replay_queue_.end(); ++it) { | |
| 503 backend_->AcknowledgeInvalidation(it->first, it->second); | |
| 504 } | |
| 505 ack_replay_queue_.clear(); | |
| 501 } | 506 } |
| 502 | 507 |
| 503 if (!sync_global_error_.get()) { | 508 if (!sync_global_error_.get()) { |
| 504 #if !defined(OS_ANDROID) | 509 #if !defined(OS_ANDROID) |
| 505 sync_global_error_.reset(new SyncGlobalError(this, signin())); | 510 sync_global_error_.reset(new SyncGlobalError(this, signin())); |
| 506 #endif | 511 #endif |
| 507 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 512 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
| 508 sync_global_error_.get()); | 513 sync_global_error_.get()); |
| 509 AddObserver(sync_global_error_.get()); | 514 AddObserver(sync_global_error_.get()); |
| 510 } | 515 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 526 backend_->UpdateRegisteredInvalidationIds( | 531 backend_->UpdateRegisteredInvalidationIds( |
| 527 invalidator_registrar_->GetAllRegisteredIds()); | 532 invalidator_registrar_->GetAllRegisteredIds()); |
| 528 } | 533 } |
| 529 } | 534 } |
| 530 | 535 |
| 531 void ProfileSyncService::UnregisterInvalidationHandler( | 536 void ProfileSyncService::UnregisterInvalidationHandler( |
| 532 syncer::InvalidationHandler* handler) { | 537 syncer::InvalidationHandler* handler) { |
| 533 invalidator_registrar_->UnregisterHandler(handler); | 538 invalidator_registrar_->UnregisterHandler(handler); |
| 534 } | 539 } |
| 535 | 540 |
| 541 void ProfileSyncService::AcknowledgeInvalidation( | |
| 542 const invalidation::ObjectId& id, | |
| 543 const syncer::AckHandle& ack_handle) { | |
| 544 if (backend_.get()) { | |
| 545 backend_->AcknowledgeInvalidation(id, ack_handle); | |
| 546 } else { | |
| 547 // If |backend_| is NULL, save the acknowledgements to replay when | |
| 548 // it's created and initialized. | |
| 549 ack_replay_queue_.push_back(std::make_pair(id, ack_handle)); | |
| 550 } | |
| 551 } | |
| 552 | |
| 536 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { | 553 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { |
| 537 return invalidator_registrar_->GetInvalidatorState(); | 554 return invalidator_registrar_->GetInvalidatorState(); |
| 538 } | 555 } |
| 539 | 556 |
| 540 void ProfileSyncService::EmitInvalidationForTest( | 557 void ProfileSyncService::EmitInvalidationForTest( |
| 541 const invalidation::ObjectId& id, | 558 const invalidation::ObjectId& id, |
| 542 const std::string& payload) { | 559 const std::string& payload) { |
| 543 syncer::ObjectIdSet notify_ids; | 560 syncer::ObjectIdSet notify_ids; |
| 544 notify_ids.insert(id); | 561 notify_ids.insert(id); |
| 545 | 562 |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1966 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. | 1983 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. |
| 1967 ProfileSyncService* old_this = this; | 1984 ProfileSyncService* old_this = this; |
| 1968 this->~ProfileSyncService(); | 1985 this->~ProfileSyncService(); |
| 1969 new(old_this) ProfileSyncService( | 1986 new(old_this) ProfileSyncService( |
| 1970 new ProfileSyncComponentsFactoryImpl(profile, | 1987 new ProfileSyncComponentsFactoryImpl(profile, |
| 1971 CommandLine::ForCurrentProcess()), | 1988 CommandLine::ForCurrentProcess()), |
| 1972 profile, | 1989 profile, |
| 1973 signin, | 1990 signin, |
| 1974 behavior); | 1991 behavior); |
| 1975 } | 1992 } |
| OLD | NEW |