| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/test/engine/mock_update_handler.h" | 5 #include "sync/test/engine/mock_update_handler.h" |
| 6 | 6 |
| 7 #include "sync/internal_api/public/base/model_type.h" | 7 #include "sync/internal_api/public/base/model_type.h" |
| 8 | 8 |
| 9 namespace syncer { | 9 namespace syncer { |
| 10 | 10 |
| 11 MockUpdateHandler::MockUpdateHandler(ModelType type) | 11 MockUpdateHandler::MockUpdateHandler(ModelType type) |
| 12 : apply_updates_count_(0), | 12 : apply_updates_count_(0), |
| 13 passive_apply_updates_count_(0) { | 13 passive_apply_updates_count_(0) { |
| 14 progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); | 14 progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); |
| 15 const std::string& token_str = | 15 const std::string& token_str = |
| 16 std::string("Mock token: ") + std::string(ModelTypeToString(type)); | 16 std::string("Mock token: ") + std::string(ModelTypeToString(type)); |
| 17 progress_marker_.set_token(token_str); | 17 progress_marker_.set_token(token_str); |
| 18 } | 18 } |
| 19 | 19 |
| 20 MockUpdateHandler::~MockUpdateHandler() {} | 20 MockUpdateHandler::~MockUpdateHandler() {} |
| 21 | 21 |
| 22 void MockUpdateHandler::GetDownloadProgress( | 22 void MockUpdateHandler::GetDownloadProgress( |
| 23 sync_pb::DataTypeProgressMarker* progress_marker) const { | 23 sync_pb::DataTypeProgressMarker* progress_marker) const { |
| 24 progress_marker->CopyFrom(progress_marker_); | 24 progress_marker->CopyFrom(progress_marker_); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void MockUpdateHandler::GetDataTypeContext( |
| 28 sync_pb::DataTypeContext* context) const { |
| 29 context->Clear(); |
| 30 } |
| 31 |
| 27 void MockUpdateHandler::ProcessGetUpdatesResponse( | 32 void MockUpdateHandler::ProcessGetUpdatesResponse( |
| 28 const sync_pb::DataTypeProgressMarker& progress_marker, | 33 const sync_pb::DataTypeProgressMarker& progress_marker, |
| 29 const SyncEntityList& applicable_updates, | 34 const sync_pb::DataTypeContext& mutated_context, |
| 30 sessions::StatusController* status) { | 35 const SyncEntityList& applicable_updates, |
| 36 sessions::StatusController* status) { |
| 31 progress_marker_.CopyFrom(progress_marker); | 37 progress_marker_.CopyFrom(progress_marker); |
| 32 } | 38 } |
| 33 | 39 |
| 34 void MockUpdateHandler::ApplyUpdates(sessions::StatusController* status) { | 40 void MockUpdateHandler::ApplyUpdates(sessions::StatusController* status) { |
| 35 apply_updates_count_++; | 41 apply_updates_count_++; |
| 36 } | 42 } |
| 37 | 43 |
| 38 void MockUpdateHandler::PassiveApplyUpdates( | 44 void MockUpdateHandler::PassiveApplyUpdates( |
| 39 sessions::StatusController* status) { | 45 sessions::StatusController* status) { |
| 40 passive_apply_updates_count_++; | 46 passive_apply_updates_count_++; |
| 41 } | 47 } |
| 42 | 48 |
| 43 int MockUpdateHandler::GetApplyUpdatesCount() { | 49 int MockUpdateHandler::GetApplyUpdatesCount() { |
| 44 return apply_updates_count_; | 50 return apply_updates_count_; |
| 45 } | 51 } |
| 46 | 52 |
| 47 int MockUpdateHandler::GetPassiveApplyUpdatesCount() { | 53 int MockUpdateHandler::GetPassiveApplyUpdatesCount() { |
| 48 return passive_apply_updates_count_; | 54 return passive_apply_updates_count_; |
| 49 } | 55 } |
| 50 | 56 |
| 51 } // namespace syncer | 57 } // namespace syncer |
| OLD | NEW |