OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/engine/process_commit_response_command.h" | 5 #include "chrome/browser/sync/engine/process_commit_response_command.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // critical error, we trap it and don't LOG(ERROR). To enable this we keep | 128 // critical error, we trap it and don't LOG(ERROR). To enable this we keep |
129 // a map of conflicting new folders. | 129 // a map of conflicting new folders. |
130 int transient_error_commits = 0; | 130 int transient_error_commits = 0; |
131 int conflicting_commits = 0; | 131 int conflicting_commits = 0; |
132 int error_commits = 0; | 132 int error_commits = 0; |
133 int successes = 0; | 133 int successes = 0; |
134 set<syncable::Id> conflicting_new_folder_ids; | 134 set<syncable::Id> conflicting_new_folder_ids; |
135 set<syncable::Id> deleted_folders; | 135 set<syncable::Id> deleted_folders; |
136 ConflictProgress* conflict_progress = status->mutable_conflict_progress(); | 136 ConflictProgress* conflict_progress = status->mutable_conflict_progress(); |
137 OrderedCommitSet::Projection proj = status->commit_id_projection(); | 137 OrderedCommitSet::Projection proj = status->commit_id_projection(); |
138 { // Scope for WriteTransaction. | 138 if (!proj.empty()) { // Scope for WriteTransaction. |
139 WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__); | 139 WriteTransaction trans(dir, SYNCER, __FILE__, __LINE__); |
140 for (size_t i = 0; i < proj.size(); i++) { | 140 for (size_t i = 0; i < proj.size(); i++) { |
141 CommitResponse::ResponseType response_type = | 141 CommitResponse::ResponseType response_type = |
142 ProcessSingleCommitResponse(&trans, cr.entryresponse(proj[i]), | 142 ProcessSingleCommitResponse(&trans, cr.entryresponse(proj[i]), |
143 commit_message.entries(proj[i]), | 143 commit_message.entries(proj[i]), |
144 status->GetCommitIdAt(proj[i]), | 144 status->GetCommitIdAt(proj[i]), |
145 &conflicting_new_folder_ids, | 145 &conflicting_new_folder_ids, |
146 &deleted_folders); | 146 &deleted_folders); |
147 switch (response_type) { | 147 switch (response_type) { |
148 case CommitResponse::INVALID_MESSAGE: | 148 case CommitResponse::INVALID_MESSAGE: |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 // The server has the final say on positioning, so apply the absolute | 429 // The server has the final say on positioning, so apply the absolute |
430 // position that it returns. | 430 // position that it returns. |
431 if (entry_response.has_position_in_parent()) { | 431 if (entry_response.has_position_in_parent()) { |
432 // The SERVER_ field should already have been written. | 432 // The SERVER_ field should already have been written. |
433 DCHECK_EQ(entry_response.position_in_parent(), | 433 DCHECK_EQ(entry_response.position_in_parent(), |
434 local_entry->Get(SERVER_POSITION_IN_PARENT)); | 434 local_entry->Get(SERVER_POSITION_IN_PARENT)); |
435 | 435 |
436 // We just committed successfully, so we assume that the position | 436 // We just committed successfully, so we assume that the position |
437 // value we got applies to the PARENT_ID we submitted. | 437 // value we got applies to the PARENT_ID we submitted. |
438 syncable::Id new_prev = SyncerUtil::ComputePrevIdFromServerPosition( | 438 syncable::Id new_prev = local_entry->ComputePrevIdFromServerPosition( |
439 local_entry->write_transaction(), local_entry, | |
440 local_entry->Get(PARENT_ID)); | 439 local_entry->Get(PARENT_ID)); |
441 if (!local_entry->PutPredecessor(new_prev)) | 440 if (!local_entry->PutPredecessor(new_prev)) |
442 LOG(WARNING) << "PutPredecessor failed after successful commit"; | 441 LOG(WARNING) << "PutPredecessor failed after successful commit"; |
443 } | 442 } |
444 } | 443 } |
445 | 444 |
446 void ProcessCommitResponseCommand::ProcessSuccessfulCommitResponse( | 445 void ProcessCommitResponseCommand::ProcessSuccessfulCommitResponse( |
447 const sync_pb::SyncEntity& committed_entry, | 446 const sync_pb::SyncEntity& committed_entry, |
448 const CommitResponse_EntryResponse& entry_response, | 447 const CommitResponse_EntryResponse& entry_response, |
449 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, | 448 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // been recursively deleted. | 481 // been recursively deleted. |
483 // TODO(nick): Here, commit_message.deleted() would be more correct than | 482 // TODO(nick): Here, commit_message.deleted() would be more correct than |
484 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then | 483 // local_entry->Get(IS_DEL). For example, an item could be renamed, and then |
485 // deleted during the commit of the rename. Unit test & fix. | 484 // deleted during the commit of the rename. Unit test & fix. |
486 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { | 485 if (local_entry->Get(IS_DIR) && local_entry->Get(IS_DEL)) { |
487 deleted_folders->insert(local_entry->Get(ID)); | 486 deleted_folders->insert(local_entry->Get(ID)); |
488 } | 487 } |
489 } | 488 } |
490 | 489 |
491 } // namespace browser_sync | 490 } // namespace browser_sync |
OLD | NEW |