| 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/build_commit_command.h" | 8 #include "sync/engine/build_commit_command.h" |
| 9 #include "sync/engine/get_commit_ids_command.h" | 9 #include "sync/engine/get_commit_ids_command.h" |
| 10 #include "sync/engine/process_commit_response_command.h" | 10 #include "sync/engine/process_commit_response_command.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 build_commit_command.Execute(session); | 95 build_commit_command.Execute(session); |
| 96 | 96 |
| 97 SetSyncingBits(&trans, *commit_set); | 97 SetSyncingBits(&trans, *commit_set); |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 SyncerError BuildAndPostCommitsImpl(ModelTypeSet requested_types, | 101 SyncerError BuildAndPostCommitsImpl(ModelTypeSet requested_types, |
| 102 Syncer* syncer, | 102 Syncer* syncer, |
| 103 sessions::SyncSession* session, | 103 sessions::SyncSession* session, |
| 104 sessions::OrderedCommitSet* commit_set) { | 104 sessions::OrderedCommitSet* commit_set) { |
| 105 ModelTypeSet commit_request_types; |
| 105 while (!syncer->ExitRequested()) { | 106 while (!syncer->ExitRequested()) { |
| 106 sync_pb::ClientToServerMessage commit_message; | 107 sync_pb::ClientToServerMessage commit_message; |
| 107 ExtensionsActivityMonitor::Records extensions_activity_buffer; | 108 ExtensionsActivityMonitor::Records extensions_activity_buffer; |
| 108 | 109 |
| 109 if (!PrepareCommitMessage(session, | 110 if (!PrepareCommitMessage(session, |
| 110 requested_types, | 111 requested_types, |
| 111 commit_set, | 112 commit_set, |
| 112 &commit_message, | 113 &commit_message, |
| 113 &extensions_activity_buffer)) { | 114 &extensions_activity_buffer)) { |
| 114 break; | 115 break; |
| 115 } | 116 } |
| 116 | 117 |
| 118 commit_request_types.PutAll(commit_set->Types()); |
| 119 session->mutable_status_controller()->set_commit_request_types( |
| 120 commit_request_types); |
| 121 |
| 117 sync_pb::ClientToServerResponse commit_response; | 122 sync_pb::ClientToServerResponse commit_response; |
| 118 | 123 |
| 119 DVLOG(1) << "Sending commit message."; | 124 DVLOG(1) << "Sending commit message."; |
| 120 TRACE_EVENT_BEGIN0("sync", "PostCommit"); | 125 TRACE_EVENT_BEGIN0("sync", "PostCommit"); |
| 121 const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage( | 126 const SyncerError post_result = SyncerProtoUtil::PostClientToServerMessage( |
| 122 &commit_message, &commit_response, session); | 127 &commit_message, &commit_response, session); |
| 123 TRACE_EVENT_END0("sync", "PostCommit"); | 128 TRACE_EVENT_END0("sync", "PostCommit"); |
| 124 | 129 |
| 125 // TODO(rlarocque): Put all the post-commit logic in one place. | 130 // TODO(rlarocque): Put all the post-commit logic in one place. |
| 126 // See crbug.com/196338. | 131 // See crbug.com/196338. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 sessions::OrderedCommitSet commit_set(session->context()->routing_info()); | 182 sessions::OrderedCommitSet commit_set(session->context()->routing_info()); |
| 178 SyncerError result = | 183 SyncerError result = |
| 179 BuildAndPostCommitsImpl(requested_types, syncer, session, &commit_set); | 184 BuildAndPostCommitsImpl(requested_types, syncer, session, &commit_set); |
| 180 if (result != SYNCER_OK) { | 185 if (result != SYNCER_OK) { |
| 181 ClearSyncingBits(session->context()->directory(), commit_set); | 186 ClearSyncingBits(session->context()->directory(), commit_set); |
| 182 } | 187 } |
| 183 return result; | 188 return result; |
| 184 } | 189 } |
| 185 | 190 |
| 186 } // namespace syncer | 191 } // namespace syncer |
| OLD | NEW |