| 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 "sync/engine/process_updates_command.h" |    5 #include "sync/engine/process_updates_command.h" | 
|    6  |    6  | 
|    7 #include <vector> |    7 #include <vector> | 
|    8  |    8  | 
|    9 #include "base/basictypes.h" |    9 #include "base/basictypes.h" | 
|   10 #include "base/location.h" |   10 #include "base/location.h" | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|   23 // shifted to completely using Ordinals. |   23 // shifted to completely using Ordinals. | 
|   24 // See http://crbug.com/145412 . |   24 // See http://crbug.com/145412 . | 
|   25 #include "sync/internal_api/public/base/node_ordinal.h" |   25 #include "sync/internal_api/public/base/node_ordinal.h" | 
|   26  |   26  | 
|   27 using std::vector; |   27 using std::vector; | 
|   28  |   28  | 
|   29 namespace syncer { |   29 namespace syncer { | 
|   30  |   30  | 
|   31 using sessions::SyncSession; |   31 using sessions::SyncSession; | 
|   32 using sessions::StatusController; |   32 using sessions::StatusController; | 
|   33 using sessions::UpdateProgress; |  | 
|   34  |   33  | 
|   35 using syncable::GET_BY_ID; |   34 using syncable::GET_BY_ID; | 
|   36  |   35  | 
|   37 ProcessUpdatesCommand::ProcessUpdatesCommand() {} |   36 ProcessUpdatesCommand::ProcessUpdatesCommand() {} | 
|   38 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} |   37 ProcessUpdatesCommand::~ProcessUpdatesCommand() {} | 
|   39  |   38  | 
|   40 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( |   39 std::set<ModelSafeGroup> ProcessUpdatesCommand::GetGroupsToChange( | 
|   41     const sessions::SyncSession& session) const { |   40     const sessions::SyncSession& session) const { | 
|   42   std::set<ModelSafeGroup> groups_with_updates; |   41   std::set<ModelSafeGroup> groups_with_updates; | 
|   43  |   42  | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  134     // TODO(tim): Don't allow access to objects in other ModelSafeGroups. |  133     // TODO(tim): Don't allow access to objects in other ModelSafeGroups. | 
|  135     // See crbug.com/121521 . |  134     // See crbug.com/121521 . | 
|  136     ModelSafeGroup g = GetGroupForModelType(GetModelType(update), |  135     ModelSafeGroup g = GetGroupForModelType(GetModelType(update), | 
|  137                                             session->routing_info()); |  136                                             session->routing_info()); | 
|  138     if (g != status->group_restriction()) |  137     if (g != status->group_restriction()) | 
|  139       continue; |  138       continue; | 
|  140  |  139  | 
|  141     VerifyResult verify_result = VerifyUpdate(&trans, update, |  140     VerifyResult verify_result = VerifyUpdate(&trans, update, | 
|  142                                               requested_types, |  141                                               requested_types, | 
|  143                                               session->routing_info()); |  142                                               session->routing_info()); | 
|  144     status->mutable_update_progress()->AddVerifyResult(verify_result, update); |  | 
|  145     status->increment_num_updates_downloaded_by(1); |  143     status->increment_num_updates_downloaded_by(1); | 
|  146     if (!UpdateContainsNewVersion(&trans, update)) |  144     if (!UpdateContainsNewVersion(&trans, update)) | 
|  147       status->increment_num_reflected_updates_downloaded_by(1); |  145       status->increment_num_reflected_updates_downloaded_by(1); | 
|  148     if (update.deleted()) |  146     if (update.deleted()) | 
|  149       status->increment_num_tombstone_updates_downloaded_by(1); |  147       status->increment_num_tombstone_updates_downloaded_by(1); | 
|  150  |  148  | 
|  151     if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE) |  149     if (verify_result != VERIFY_SUCCESS && verify_result != VERIFY_UNDELETE) | 
|  152       continue; |  150       continue; | 
|  153  |  151  | 
|  154     ServerUpdateProcessingResult process_result = |  152     ServerUpdateProcessingResult process_result = | 
|  155        ProcessUpdate(update, dir->GetCryptographer(&trans), &trans); |  153        ProcessUpdate(update, dir->GetCryptographer(&trans), &trans); | 
|  156  |  154  | 
|  157     DCHECK(process_result == SUCCESS_PROCESSED || |  155     DCHECK(process_result == SUCCESS_PROCESSED || | 
|  158            process_result == SUCCESS_STORED); |  156            process_result == SUCCESS_STORED); | 
|  159   } |  157   } | 
|  160  |  158  | 
|  161   status->mutable_update_progress()->ClearVerifiedUpdates(); |  | 
|  162   return SYNCER_OK; |  159   return SYNCER_OK; | 
|  163 } |  160 } | 
|  164  |  161  | 
|  165 namespace { |  162 namespace { | 
|  166  |  163  | 
|  167 // In the event that IDs match, but tags differ AttemptReuniteClient tag |  164 // In the event that IDs match, but tags differ AttemptReuniteClient tag | 
|  168 // will have refused to unify the update. |  165 // will have refused to unify the update. | 
|  169 // We should not attempt to apply it at all since it violates consistency |  166 // We should not attempt to apply it at all since it violates consistency | 
|  170 // rules. |  167 // rules. | 
|  171 VerifyResult VerifyTagConsistency(const sync_pb::SyncEntity& entry, |  168 VerifyResult VerifyTagConsistency(const sync_pb::SyncEntity& entry, | 
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  346     target_entry.Put(syncable::BASE_SERVER_SPECIFICS, |  343     target_entry.Put(syncable::BASE_SERVER_SPECIFICS, | 
|  347                      sync_pb::EntitySpecifics()); |  344                      sync_pb::EntitySpecifics()); | 
|  348   } |  345   } | 
|  349  |  346  | 
|  350   UpdateServerFieldsFromUpdate(&target_entry, update, name); |  347   UpdateServerFieldsFromUpdate(&target_entry, update, name); | 
|  351  |  348  | 
|  352   return SUCCESS_PROCESSED; |  349   return SUCCESS_PROCESSED; | 
|  353 } |  350 } | 
|  354  |  351  | 
|  355 }  // namespace syncer |  352 }  // namespace syncer | 
| OLD | NEW |