| 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/sessions/session_state.h" |   5 #include "sync/sessions/session_state.h" | 
|   6  |   6  | 
|   7 #include <set> |   7 #include <set> | 
|   8 #include <vector> |   8 #include <vector> | 
|   9  |   9  | 
|  10 #include "base/memory/scoped_ptr.h" |  10 #include "base/memory/scoped_ptr.h" | 
|  11 #include "base/values.h" |  11 #include "base/values.h" | 
|  12  |  12  | 
|  13 using std::set; |  13 using std::set; | 
|  14 using std::vector; |  14 using std::vector; | 
|  15  |  15  | 
|  16 namespace syncer { |  16 namespace syncer { | 
|  17 namespace sessions { |  17 namespace sessions { | 
|  18  |  18  | 
|  19 UpdateProgress::UpdateProgress() {} |  | 
|  20  |  | 
|  21 UpdateProgress::~UpdateProgress() {} |  | 
|  22  |  | 
|  23 void UpdateProgress::AddVerifyResult(const VerifyResult& verify_result, |  | 
|  24                                      const sync_pb::SyncEntity& entity) { |  | 
|  25   verified_updates_.push_back(std::make_pair(verify_result, entity)); |  | 
|  26 } |  | 
|  27  |  | 
|  28 void UpdateProgress::AddAppliedUpdate(const UpdateAttemptResponse& response, |  | 
|  29     const syncable::Id& id) { |  | 
|  30   applied_updates_.push_back(std::make_pair(response, id)); |  | 
|  31 } |  | 
|  32  |  | 
|  33 std::vector<AppliedUpdate>::iterator UpdateProgress::AppliedUpdatesBegin() { |  | 
|  34   return applied_updates_.begin(); |  | 
|  35 } |  | 
|  36  |  | 
|  37 std::vector<VerifiedUpdate>::const_iterator |  | 
|  38 UpdateProgress::VerifiedUpdatesBegin() const { |  | 
|  39   return verified_updates_.begin(); |  | 
|  40 } |  | 
|  41  |  | 
|  42 std::vector<AppliedUpdate>::const_iterator |  | 
|  43 UpdateProgress::AppliedUpdatesEnd() const { |  | 
|  44   return applied_updates_.end(); |  | 
|  45 } |  | 
|  46  |  | 
|  47 std::vector<VerifiedUpdate>::const_iterator |  | 
|  48 UpdateProgress::VerifiedUpdatesEnd() const { |  | 
|  49   return verified_updates_.end(); |  | 
|  50 } |  | 
|  51  |  | 
|  52 int UpdateProgress::SuccessfullyAppliedUpdateCount() const { |  | 
|  53   int count = 0; |  | 
|  54   for (std::vector<AppliedUpdate>::const_iterator it = |  | 
|  55        applied_updates_.begin(); |  | 
|  56        it != applied_updates_.end(); |  | 
|  57        ++it) { |  | 
|  58     if (it->first == SUCCESS) |  | 
|  59       count++; |  | 
|  60   } |  | 
|  61   return count; |  | 
|  62 } |  | 
|  63  |  | 
|  64 // Returns true if at least one update application failed due to a conflict |  | 
|  65 // during this sync cycle. |  | 
|  66 bool UpdateProgress::HasConflictingUpdates() const { |  | 
|  67   std::vector<AppliedUpdate>::const_iterator it; |  | 
|  68   for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) { |  | 
|  69     if (it->first != SUCCESS) { |  | 
|  70       return true; |  | 
|  71     } |  | 
|  72   } |  | 
|  73   return false; |  | 
|  74 } |  | 
|  75  |  | 
|  76 PerModelSafeGroupState::PerModelSafeGroupState() { |  19 PerModelSafeGroupState::PerModelSafeGroupState() { | 
|  77 } |  20 } | 
|  78  |  21  | 
|  79 PerModelSafeGroupState::~PerModelSafeGroupState() { |  22 PerModelSafeGroupState::~PerModelSafeGroupState() { | 
|  80 } |  23 } | 
|  81  |  24  | 
|  82 }  // namespace sessions |  25 }  // namespace sessions | 
|  83 }  // namespace syncer |  26 }  // namespace syncer | 
| OLD | NEW |