Index: chrome/browser/sync/glue/generic_change_processor.cc |
diff --git a/chrome/browser/sync/glue/generic_change_processor.cc b/chrome/browser/sync/glue/generic_change_processor.cc |
index 8a064af20c4d499b27e6799e7d027245416e36b0..2b15d55eaaf0e21808fa5a1f53f65007191fd316 100644 |
--- a/chrome/browser/sync/glue/generic_change_processor.cc |
+++ b/chrome/browser/sync/glue/generic_change_processor.cc |
@@ -20,23 +20,26 @@ |
namespace browser_sync { |
GenericChangeProcessor::GenericChangeProcessor( |
- SyncableService* local_service, |
+ UnrecoverableErrorHandler* error_handler) |
+ : ChangeProcessor(error_handler), |
+ local_service_(NULL), |
+ share_handle_(NULL) {} |
+ |
+GenericChangeProcessor::GenericChangeProcessor( |
UnrecoverableErrorHandler* error_handler, |
+ SyncableService* local_service, |
sync_api::UserShare* user_share) |
: ChangeProcessor(error_handler), |
local_service_(local_service), |
- user_share_(user_share) { |
- DCHECK(local_service_); |
-} |
- |
-GenericChangeProcessor::~GenericChangeProcessor() { |
- // Set to null to ensure it's not used after destruction. |
- local_service_ = NULL; |
+ share_handle_(user_share) { |
} |
+j |
+GenericChangeProcessor::~GenericChangeProcessor() {} |
void GenericChangeProcessor::ApplyChangesFromSyncModel( |
const sync_api::BaseTransaction* trans, |
const sync_api::ImmutableChangeRecordList& changes) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK(running()); |
DCHECK(syncer_changes_.empty()); |
for (sync_api::ChangeRecordList::const_iterator it = |
@@ -65,12 +68,13 @@ void GenericChangeProcessor::ApplyChangesFromSyncModel( |
} |
void GenericChangeProcessor::CommitChangesFromSyncModel() { |
+ DCHECK(CalledOnValidThread()); |
if (!running()) |
return; |
if (syncer_changes_.empty()) |
return; |
SyncError error = local_service_->ProcessSyncChanges(FROM_HERE, |
- syncer_changes_); |
+ syncer_changes_); |
syncer_changes_.clear(); |
if (error.IsSet()) { |
error_handler()->OnUnrecoverableError(error.location(), error.message()); |
@@ -80,6 +84,7 @@ void GenericChangeProcessor::CommitChangesFromSyncModel() { |
SyncError GenericChangeProcessor::GetSyncDataForType( |
syncable::ModelType type, |
SyncDataList* current_sync_data) { |
+ DCHECK(CalledOnValidThread()); |
std::string type_name = syncable::ModelTypeToString(type); |
sync_api::ReadTransaction trans(FROM_HERE, share_handle()); |
sync_api::ReadNode root(&trans); |
@@ -137,6 +142,7 @@ bool AttemptDelete(const SyncChange& change, sync_api::WriteNode* node) { |
SyncError GenericChangeProcessor::ProcessSyncChanges( |
const tracked_objects::Location& from_here, |
const SyncChangeList& list_of_changes) { |
+ DCHECK(CalledOnValidThread()); |
sync_api::WriteTransaction trans(from_here, share_handle()); |
for (SyncChangeList::const_iterator iter = list_of_changes.begin(); |
@@ -216,6 +222,7 @@ SyncError GenericChangeProcessor::ProcessSyncChanges( |
bool GenericChangeProcessor::SyncModelHasUserCreatedNodes( |
syncable::ModelType type, |
bool* has_nodes) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK(has_nodes); |
DCHECK_NE(type, syncable::UNSPECIFIED); |
std::string type_name = syncable::ModelTypeToString(type); |
@@ -236,6 +243,7 @@ bool GenericChangeProcessor::SyncModelHasUserCreatedNodes( |
} |
bool GenericChangeProcessor::CryptoReadyIfNecessary(syncable::ModelType type) { |
+ DCHECK(CalledOnValidThread()); |
DCHECK_NE(type, syncable::UNSPECIFIED); |
// We only access the cryptographer while holding a transaction. |
sync_api::ReadTransaction trans(FROM_HERE, share_handle()); |
@@ -245,12 +253,28 @@ bool GenericChangeProcessor::CryptoReadyIfNecessary(syncable::ModelType type) { |
trans.GetCryptographer()->is_ready(); |
} |
-void GenericChangeProcessor::StartImpl(Profile* profile) {} |
+void GenericChangeProcessor::set_local_service(SyncableService* local_service) { |
+ local_service_ = local_service; |
akalin
2011/10/07 20:51:16
may as well add DCHECK(CalledOnvalidThread()) for
Nicolas Zea
2011/10/07 22:05:52
Done, with the exception of StopImpl, which unfort
akalin
2011/10/07 22:18:28
Ah, can you add a comment explaining that? (Eithe
|
+} |
-void GenericChangeProcessor::StopImpl() {} |
+SyncableService* GenericChangeProcessor::local_service() const { |
+ return local_service_; |
+} |
+ |
+void GenericChangeProcessor::set_share_handle(sync_api::UserShare* user_share) { |
+ share_handle_ = user_share; |
+} |
+ |
+void GenericChangeProcessor::StartImpl(Profile* profile) { |
+ DCHECK(CalledOnValidThread()); |
+} |
+ |
+void GenericChangeProcessor::StopImpl() { |
+} |
-sync_api::UserShare* GenericChangeProcessor::share_handle() { |
- return user_share_; |
+sync_api::UserShare* GenericChangeProcessor::share_handle() const { |
+ DCHECK(CalledOnValidThread()); |
+ return share_handle_; |
} |
} // namespace browser_sync |