OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sync/engine/sync_directory_update_handler.h" |
| 6 |
| 7 #include "sync/engine/process_updates_util.h" |
| 8 #include "sync/sessions/status_controller.h" |
| 9 #include "sync/syncable/directory.h" |
| 10 #include "sync/syncable/syncable_model_neutral_write_transaction.h" |
| 11 |
| 12 namespace syncer { |
| 13 |
| 14 using syncable::SYNCER; |
| 15 |
| 16 SyncDirectoryUpdateHandler::SyncDirectoryUpdateHandler( |
| 17 syncable::Directory* dir, ModelType type) |
| 18 : dir_(dir), |
| 19 type_(type) {} |
| 20 |
| 21 SyncDirectoryUpdateHandler::~SyncDirectoryUpdateHandler() {} |
| 22 |
| 23 void SyncDirectoryUpdateHandler::GetDownloadProgress( |
| 24 sync_pb::DataTypeProgressMarker* progress_marker) const { |
| 25 dir_->GetDownloadProgress(type_, progress_marker); |
| 26 } |
| 27 |
| 28 void SyncDirectoryUpdateHandler::ProcessGetUpdatesResponse( |
| 29 const sync_pb::DataTypeProgressMarker& progress_marker, |
| 30 const SyncEntityList& applicable_updates, |
| 31 sessions::StatusController* status) { |
| 32 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_); |
| 33 UpdateSyncEntities(&trans, applicable_updates, status); |
| 34 UpdateProgressMarker(progress_marker); |
| 35 } |
| 36 |
| 37 void SyncDirectoryUpdateHandler::UpdateSyncEntities( |
| 38 syncable::ModelNeutralWriteTransaction* trans, |
| 39 const SyncEntityList& applicable_updates, |
| 40 sessions::StatusController* status) { |
| 41 ProcessDownloadedUpdates(dir_, trans, type_, applicable_updates, status); |
| 42 } |
| 43 |
| 44 void SyncDirectoryUpdateHandler::UpdateProgressMarker( |
| 45 const sync_pb::DataTypeProgressMarker& progress_marker) { |
| 46 int field_number = progress_marker.data_type_id(); |
| 47 ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number); |
| 48 if (!IsRealDataType(model_type) || type_ != model_type) { |
| 49 NOTREACHED() |
| 50 << "Update handler of type " << ModelTypeToString(type_) |
| 51 << " asked to process progress marker with invalid type " |
| 52 << field_number; |
| 53 } |
| 54 dir_->SetDownloadProgress(type_, progress_marker); |
| 55 } |
| 56 |
| 57 } // namespace syncer |
OLD | NEW |