| 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_commit_response_command.h" | 5 #include "sync/engine/process_commit_response_command.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 using std::set; | 25 using std::set; |
| 26 using std::string; | 26 using std::string; |
| 27 using std::vector; | 27 using std::vector; |
| 28 using sync_pb::CommitResponse; | 28 using sync_pb::CommitResponse; |
| 29 | 29 |
| 30 namespace syncer { | 30 namespace syncer { |
| 31 | 31 |
| 32 using sessions::OrderedCommitSet; | 32 using sessions::OrderedCommitSet; |
| 33 using sessions::StatusController; | 33 using sessions::StatusController; |
| 34 using sessions::SyncSession; | 34 using sessions::SyncSession; |
| 35 using sessions::ConflictProgress; | |
| 36 using syncable::WriteTransaction; | 35 using syncable::WriteTransaction; |
| 37 using syncable::MutableEntry; | 36 using syncable::MutableEntry; |
| 38 using syncable::Entry; | 37 using syncable::Entry; |
| 39 using syncable::BASE_VERSION; | 38 using syncable::BASE_VERSION; |
| 40 using syncable::GET_BY_ID; | 39 using syncable::GET_BY_ID; |
| 41 using syncable::ID; | 40 using syncable::ID; |
| 42 using syncable::IS_DEL; | 41 using syncable::IS_DEL; |
| 43 using syncable::IS_DIR; | 42 using syncable::IS_DIR; |
| 44 using syncable::IS_UNAPPLIED_UPDATE; | 43 using syncable::IS_UNAPPLIED_UPDATE; |
| 45 using syncable::IS_UNSYNCED; | 44 using syncable::IS_UNSYNCED; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 StatusController* status = session->mutable_status_controller(); | 102 StatusController* status = session->mutable_status_controller(); |
| 104 const CommitResponse& cr = commit_response_.commit(); | 103 const CommitResponse& cr = commit_response_.commit(); |
| 105 const sync_pb::CommitMessage& commit_message = commit_message_.commit(); | 104 const sync_pb::CommitMessage& commit_message = commit_message_.commit(); |
| 106 | 105 |
| 107 int transient_error_commits = 0; | 106 int transient_error_commits = 0; |
| 108 int conflicting_commits = 0; | 107 int conflicting_commits = 0; |
| 109 int error_commits = 0; | 108 int error_commits = 0; |
| 110 int successes = 0; | 109 int successes = 0; |
| 111 | 110 |
| 112 set<syncable::Id> deleted_folders; | 111 set<syncable::Id> deleted_folders; |
| 113 ConflictProgress* conflict_progress = status->mutable_conflict_progress(); | |
| 114 OrderedCommitSet::Projection proj = status->commit_id_projection( | 112 OrderedCommitSet::Projection proj = status->commit_id_projection( |
| 115 commit_set_); | 113 commit_set_); |
| 116 | 114 |
| 117 if (!proj.empty()) { // Scope for WriteTransaction. | 115 if (!proj.empty()) { // Scope for WriteTransaction. |
| 118 WriteTransaction trans(FROM_HERE, SYNCER, dir); | 116 WriteTransaction trans(FROM_HERE, SYNCER, dir); |
| 119 for (size_t i = 0; i < proj.size(); i++) { | 117 for (size_t i = 0; i < proj.size(); i++) { |
| 120 CommitResponse::ResponseType response_type = ProcessSingleCommitResponse( | 118 CommitResponse::ResponseType response_type = ProcessSingleCommitResponse( |
| 121 &trans, | 119 &trans, |
| 122 cr.entryresponse(proj[i]), | 120 cr.entryresponse(proj[i]), |
| 123 commit_message.entries(proj[i]), | 121 commit_message.entries(proj[i]), |
| 124 commit_set_.GetCommitIdAt(proj[i]), | 122 commit_set_.GetCommitIdAt(proj[i]), |
| 125 &deleted_folders); | 123 &deleted_folders); |
| 126 switch (response_type) { | 124 switch (response_type) { |
| 127 case CommitResponse::INVALID_MESSAGE: | 125 case CommitResponse::INVALID_MESSAGE: |
| 128 ++error_commits; | 126 ++error_commits; |
| 129 break; | 127 break; |
| 130 case CommitResponse::CONFLICT: | 128 case CommitResponse::CONFLICT: |
| 131 ++conflicting_commits; | 129 ++conflicting_commits; |
| 132 conflict_progress->AddServerConflictingItemById( | 130 status->increment_num_server_conflicts(); |
| 133 commit_set_.GetCommitIdAt(proj[i])); | |
| 134 break; | 131 break; |
| 135 case CommitResponse::SUCCESS: | 132 case CommitResponse::SUCCESS: |
| 136 // TODO(sync): worry about sync_rate_ rate calc? | 133 // TODO(sync): worry about sync_rate_ rate calc? |
| 137 ++successes; | 134 ++successes; |
| 138 if (commit_set_.GetModelTypeAt(proj[i]) == BOOKMARKS) | 135 if (commit_set_.GetModelTypeAt(proj[i]) == BOOKMARKS) |
| 139 status->increment_num_successful_bookmark_commits(); | 136 status->increment_num_successful_bookmark_commits(); |
| 140 status->increment_num_successful_commits(); | 137 status->increment_num_successful_commits(); |
| 141 break; | 138 break; |
| 142 case CommitResponse::OVER_QUOTA: | 139 case CommitResponse::OVER_QUOTA: |
| 143 // We handle over quota like a retry, which is same as transient. | 140 // We handle over quota like a retry, which is same as transient. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // been recursively deleted. | 469 // been recursively deleted. |
| 473 // TODO(nick): Here, commit_message.deleted() would be more correct than | 470 // TODO(nick): Here, commit_message.deleted() would be more correct than |
| 474 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then | 471 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then |
| 475 // deleted during the commit of the rename. Unit test & fix. | 472 // deleted during the commit of the rename. Unit test & fix. |
| 476 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { | 473 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { |
| 477 deleted_folders->insert(local_entry->Get(ID)); | 474 deleted_folders->insert(local_entry->Get(ID)); |
| 478 } | 475 } |
| 479 } | 476 } |
| 480 | 477 |
| 481 } // namespace syncer | 478 } // namespace syncer |
| OLD | NEW |