| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/commit.h" | 5 #include "sync/engine/commit.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "sync/engine/commit_contribution.h" | 8 #include "sync/engine/commit_contribution.h" |
| 9 #include "sync/engine/commit_processor.h" | 9 #include "sync/engine/commit_processor.h" |
| 10 #include "sync/engine/commit_util.h" | 10 #include "sync/engine/commit_util.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 for (std::map<ModelType, CommitContribution*>::iterator it = | 76 for (std::map<ModelType, CommitContribution*>::iterator it = |
| 77 contributions.begin(); it != contributions.end(); ++it) { | 77 contributions.begin(); it != contributions.end(); ++it) { |
| 78 it->second->AddToCommitMessage(&message); | 78 it->second->AddToCommitMessage(&message); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // If we made it this far, then we've successfully prepared a commit message. | 81 // If we made it this far, then we've successfully prepared a commit message. |
| 82 return new Commit(contributions, message, extensions_activity_buffer); | 82 return new Commit(contributions, message, extensions_activity_buffer); |
| 83 } | 83 } |
| 84 | 84 |
| 85 SyncerError Commit::PostAndProcessResponse( | 85 SyncerError Commit::PostAndProcessResponse( |
| 86 sessions::NudgeTracker* nudge_tracker, |
| 86 sessions::SyncSession* session, | 87 sessions::SyncSession* session, |
| 87 sessions::StatusController* status, | 88 sessions::StatusController* status, |
| 88 ExtensionsActivity* extensions_activity) { | 89 ExtensionsActivity* extensions_activity) { |
| 89 ModelTypeSet request_types; | 90 ModelTypeSet request_types; |
| 90 for (ContributionMap::const_iterator it = contributions_.begin(); | 91 for (ContributionMap::const_iterator it = contributions_.begin(); |
| 91 it != contributions_.end(); ++it) { | 92 it != contributions_.end(); ++it) { |
| 92 request_types.Put(it->first); | 93 request_types.Put(it->first); |
| 93 } | 94 } |
| 94 session->mutable_status_controller()->set_commit_request_types(request_types); | 95 session->mutable_status_controller()->set_commit_request_types(request_types); |
| 95 | 96 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 147 } |
| 147 | 148 |
| 148 // Let the contributors process the responses to each of their requests. | 149 // Let the contributors process the responses to each of their requests. |
| 149 SyncerError processing_result = SYNCER_OK; | 150 SyncerError processing_result = SYNCER_OK; |
| 150 for (std::map<ModelType, CommitContribution*>::iterator it = | 151 for (std::map<ModelType, CommitContribution*>::iterator it = |
| 151 contributions_.begin(); it != contributions_.end(); ++it) { | 152 contributions_.begin(); it != contributions_.end(); ++it) { |
| 152 TRACE_EVENT1("sync", "ProcessCommitResponse", | 153 TRACE_EVENT1("sync", "ProcessCommitResponse", |
| 153 "type", ModelTypeToString(it->first)); | 154 "type", ModelTypeToString(it->first)); |
| 154 SyncerError type_result = | 155 SyncerError type_result = |
| 155 it->second->ProcessCommitResponse(response_, status); | 156 it->second->ProcessCommitResponse(response_, status); |
| 157 if (type_result == SERVER_RETURN_CONFLICT) { |
| 158 nudge_tracker->RecordCommitConflict(it->first); |
| 159 } |
| 156 if (processing_result == SYNCER_OK && type_result != SYNCER_OK) { | 160 if (processing_result == SYNCER_OK && type_result != SYNCER_OK) { |
| 157 processing_result = type_result; | 161 processing_result = type_result; |
| 158 } | 162 } |
| 159 } | 163 } |
| 160 | 164 |
| 161 // Handle bookmarks' special extensions activity stats. | 165 // Handle bookmarks' special extensions activity stats. |
| 162 if (session->status_controller(). | 166 if (session->status_controller(). |
| 163 model_neutral_state().num_successful_bookmark_commits == 0) { | 167 model_neutral_state().num_successful_bookmark_commits == 0) { |
| 164 extensions_activity->PutRecords(extensions_activity_buffer_); | 168 extensions_activity->PutRecords(extensions_activity_buffer_); |
| 165 } | 169 } |
| 166 | 170 |
| 167 return processing_result; | 171 return processing_result; |
| 168 } | 172 } |
| 169 | 173 |
| 170 void Commit::CleanUp() { | 174 void Commit::CleanUp() { |
| 171 for (ContributionMap::iterator it = contributions_.begin(); | 175 for (ContributionMap::iterator it = contributions_.begin(); |
| 172 it != contributions_.end(); ++it) { | 176 it != contributions_.end(); ++it) { |
| 173 it->second->CleanUp(); | 177 it->second->CleanUp(); |
| 174 } | 178 } |
| 175 cleaned_up_ = true; | 179 cleaned_up_ = true; |
| 176 } | 180 } |
| 177 | 181 |
| 178 } // namespace syncer | 182 } // namespace syncer |
| OLD | NEW |