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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "sync/engine/commit_contribution.h" |
8 #include "sync/engine/commit_processor.h" | 9 #include "sync/engine/commit_processor.h" |
9 #include "sync/engine/commit_util.h" | 10 #include "sync/engine/commit_util.h" |
10 #include "sync/engine/sync_directory_commit_contribution.h" | |
11 #include "sync/engine/syncer.h" | 11 #include "sync/engine/syncer.h" |
12 #include "sync/engine/syncer_proto_util.h" | 12 #include "sync/engine/syncer_proto_util.h" |
13 #include "sync/sessions/sync_session.h" | 13 #include "sync/sessions/sync_session.h" |
14 | 14 |
15 namespace syncer { | 15 namespace syncer { |
16 | 16 |
17 Commit::Commit( | 17 Commit::Commit( |
18 const std::map<ModelType, SyncDirectoryCommitContribution*>& contributions, | 18 const std::map<ModelType, CommitContribution*>& contributions, |
19 const sync_pb::ClientToServerMessage& message, | 19 const sync_pb::ClientToServerMessage& message, |
20 ExtensionsActivity::Records extensions_activity_buffer) | 20 ExtensionsActivity::Records extensions_activity_buffer) |
21 : contributions_(contributions), | 21 : contributions_(contributions), |
22 deleter_(&contributions_), | 22 deleter_(&contributions_), |
23 message_(message), | 23 message_(message), |
24 extensions_activity_buffer_(extensions_activity_buffer), | 24 extensions_activity_buffer_(extensions_activity_buffer), |
25 cleaned_up_(false) { | 25 cleaned_up_(false) { |
26 } | 26 } |
27 | 27 |
28 Commit::~Commit() { | 28 Commit::~Commit() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 &extensions_activity_buffer, | 64 &extensions_activity_buffer, |
65 commit_message); | 65 commit_message); |
66 } | 66 } |
67 | 67 |
68 // Set the client config params. | 68 // Set the client config params. |
69 commit_util::AddClientConfigParamsToMessage( | 69 commit_util::AddClientConfigParamsToMessage( |
70 enabled_types, | 70 enabled_types, |
71 commit_message); | 71 commit_message); |
72 | 72 |
73 // Finally, serialize all our contributions. | 73 // Finally, serialize all our contributions. |
74 for (std::map<ModelType, SyncDirectoryCommitContribution*>::iterator it = | 74 for (std::map<ModelType, CommitContribution*>::iterator it = |
75 contributions.begin(); it != contributions.end(); ++it) { | 75 contributions.begin(); it != contributions.end(); ++it) { |
76 it->second->AddToCommitMessage(&message); | 76 it->second->AddToCommitMessage(&message); |
77 } | 77 } |
78 | 78 |
79 // If we made it this far, then we've successfully prepared a commit message. | 79 // If we made it this far, then we've successfully prepared a commit message. |
80 return new Commit(contributions, message, extensions_activity_buffer); | 80 return new Commit(contributions, message, extensions_activity_buffer); |
81 } | 81 } |
82 | 82 |
83 SyncerError Commit::PostAndProcessResponse( | 83 SyncerError Commit::PostAndProcessResponse( |
84 sessions::SyncSession* session, | 84 sessions::SyncSession* session, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 if (session->context()->debug_info_getter()) { | 125 if (session->context()->debug_info_getter()) { |
126 // Clear debug info now that we have successfully sent it to the server. | 126 // Clear debug info now that we have successfully sent it to the server. |
127 DVLOG(1) << "Clearing client debug info."; | 127 DVLOG(1) << "Clearing client debug info."; |
128 session->context()->debug_info_getter()->ClearDebugInfo(); | 128 session->context()->debug_info_getter()->ClearDebugInfo(); |
129 } | 129 } |
130 | 130 |
131 // Let the contributors process the responses to each of their requests. | 131 // Let the contributors process the responses to each of their requests. |
132 SyncerError processing_result = SYNCER_OK; | 132 SyncerError processing_result = SYNCER_OK; |
133 for (std::map<ModelType, SyncDirectoryCommitContribution*>::iterator it = | 133 for (std::map<ModelType, CommitContribution*>::iterator it = |
134 contributions_.begin(); it != contributions_.end(); ++it) { | 134 contributions_.begin(); it != contributions_.end(); ++it) { |
135 TRACE_EVENT1("sync", "ProcessCommitResponse", | 135 TRACE_EVENT1("sync", "ProcessCommitResponse", |
136 "type", ModelTypeToString(it->first)); | 136 "type", ModelTypeToString(it->first)); |
137 SyncerError type_result = | 137 SyncerError type_result = |
138 it->second->ProcessCommitResponse(response_, status); | 138 it->second->ProcessCommitResponse(response_, status); |
139 if (processing_result == SYNCER_OK && type_result != SYNCER_OK) { | 139 if (processing_result == SYNCER_OK && type_result != SYNCER_OK) { |
140 processing_result = type_result; | 140 processing_result = type_result; |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 // Handle bookmarks' special extensions activity stats. | 144 // Handle bookmarks' special extensions activity stats. |
145 if (session->status_controller(). | 145 if (session->status_controller(). |
146 model_neutral_state().num_successful_bookmark_commits == 0) { | 146 model_neutral_state().num_successful_bookmark_commits == 0) { |
147 extensions_activity->PutRecords(extensions_activity_buffer_); | 147 extensions_activity->PutRecords(extensions_activity_buffer_); |
148 } | 148 } |
149 | 149 |
150 return processing_result; | 150 return processing_result; |
151 } | 151 } |
152 | 152 |
153 void Commit::CleanUp() { | 153 void Commit::CleanUp() { |
154 for (ContributionMap::iterator it = contributions_.begin(); | 154 for (ContributionMap::iterator it = contributions_.begin(); |
155 it != contributions_.end(); ++it) { | 155 it != contributions_.end(); ++it) { |
156 it->second->CleanUp(); | 156 it->second->CleanUp(); |
157 } | 157 } |
158 cleaned_up_ = true; | 158 cleaned_up_ = true; |
159 } | 159 } |
160 | 160 |
161 } // namespace syncer | 161 } // namespace syncer |
OLD | NEW |