| 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 "chrome/browser/sync/engine/syncer.h" | 5 #include "chrome/browser/sync/engine/syncer.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "chrome/browser/sync/engine/apply_updates_command.h" | 12 #include "chrome/browser/sync/engine/apply_updates_command.h" |
| 13 #include "chrome/browser/sync/engine/build_and_process_conflict_sets_command.h" | |
| 14 #include "chrome/browser/sync/engine/build_commit_command.h" | 13 #include "chrome/browser/sync/engine/build_commit_command.h" |
| 15 #include "chrome/browser/sync/engine/cleanup_disabled_types_command.h" | 14 #include "chrome/browser/sync/engine/cleanup_disabled_types_command.h" |
| 16 #include "chrome/browser/sync/engine/clear_data_command.h" | 15 #include "chrome/browser/sync/engine/clear_data_command.h" |
| 17 #include "chrome/browser/sync/engine/conflict_resolver.h" | 16 #include "chrome/browser/sync/engine/conflict_resolver.h" |
| 18 #include "chrome/browser/sync/engine/download_updates_command.h" | 17 #include "chrome/browser/sync/engine/download_updates_command.h" |
| 19 #include "chrome/browser/sync/engine/get_commit_ids_command.h" | 18 #include "chrome/browser/sync/engine/get_commit_ids_command.h" |
| 20 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 19 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 21 #include "chrome/browser/sync/engine/post_commit_message_command.h" | 20 #include "chrome/browser/sync/engine/post_commit_message_command.h" |
| 22 #include "chrome/browser/sync/engine/process_commit_response_command.h" | 21 #include "chrome/browser/sync/engine/process_commit_response_command.h" |
| 23 #include "chrome/browser/sync/engine/process_updates_command.h" | 22 #include "chrome/browser/sync/engine/process_updates_command.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 ENUM_CASE(CLEANUP_DISABLED_TYPES); | 62 ENUM_CASE(CLEANUP_DISABLED_TYPES); |
| 64 ENUM_CASE(DOWNLOAD_UPDATES); | 63 ENUM_CASE(DOWNLOAD_UPDATES); |
| 65 ENUM_CASE(PROCESS_CLIENT_COMMAND); | 64 ENUM_CASE(PROCESS_CLIENT_COMMAND); |
| 66 ENUM_CASE(VERIFY_UPDATES); | 65 ENUM_CASE(VERIFY_UPDATES); |
| 67 ENUM_CASE(PROCESS_UPDATES); | 66 ENUM_CASE(PROCESS_UPDATES); |
| 68 ENUM_CASE(STORE_TIMESTAMPS); | 67 ENUM_CASE(STORE_TIMESTAMPS); |
| 69 ENUM_CASE(APPLY_UPDATES); | 68 ENUM_CASE(APPLY_UPDATES); |
| 70 ENUM_CASE(BUILD_COMMIT_REQUEST); | 69 ENUM_CASE(BUILD_COMMIT_REQUEST); |
| 71 ENUM_CASE(POST_COMMIT_MESSAGE); | 70 ENUM_CASE(POST_COMMIT_MESSAGE); |
| 72 ENUM_CASE(PROCESS_COMMIT_RESPONSE); | 71 ENUM_CASE(PROCESS_COMMIT_RESPONSE); |
| 73 ENUM_CASE(BUILD_AND_PROCESS_CONFLICT_SETS); | |
| 74 ENUM_CASE(RESOLVE_CONFLICTS); | 72 ENUM_CASE(RESOLVE_CONFLICTS); |
| 75 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); | 73 ENUM_CASE(APPLY_UPDATES_TO_RESOLVE_CONFLICTS); |
| 76 ENUM_CASE(CLEAR_PRIVATE_DATA); | 74 ENUM_CASE(CLEAR_PRIVATE_DATA); |
| 77 ENUM_CASE(SYNCER_END); | 75 ENUM_CASE(SYNCER_END); |
| 78 } | 76 } |
| 79 NOTREACHED(); | 77 NOTREACHED(); |
| 80 return ""; | 78 return ""; |
| 81 } | 79 } |
| 82 #undef ENUM_CASE | 80 #undef ENUM_CASE |
| 83 | 81 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 session->context()->max_commit_batch_size()); | 207 session->context()->max_commit_batch_size()); |
| 210 get_commit_ids_command.Execute(session); | 208 get_commit_ids_command.Execute(session); |
| 211 | 209 |
| 212 if (!session->status_controller().commit_ids().empty()) { | 210 if (!session->status_controller().commit_ids().empty()) { |
| 213 DVLOG(1) << "Building a commit message"; | 211 DVLOG(1) << "Building a commit message"; |
| 214 BuildCommitCommand build_commit_command; | 212 BuildCommitCommand build_commit_command; |
| 215 build_commit_command.Execute(session); | 213 build_commit_command.Execute(session); |
| 216 | 214 |
| 217 next_step = POST_COMMIT_MESSAGE; | 215 next_step = POST_COMMIT_MESSAGE; |
| 218 } else { | 216 } else { |
| 219 next_step = BUILD_AND_PROCESS_CONFLICT_SETS; | 217 next_step = RESOLVE_CONFLICTS; |
| 220 } | 218 } |
| 221 | 219 |
| 222 break; | 220 break; |
| 223 } | 221 } |
| 224 case POST_COMMIT_MESSAGE: { | 222 case POST_COMMIT_MESSAGE: { |
| 225 PostCommitMessageCommand post_commit_command; | 223 PostCommitMessageCommand post_commit_command; |
| 226 session->mutable_status_controller()->set_last_post_commit_result( | 224 session->mutable_status_controller()->set_last_post_commit_result( |
| 227 post_commit_command.Execute(session)); | 225 post_commit_command.Execute(session)); |
| 228 next_step = PROCESS_COMMIT_RESPONSE; | 226 next_step = PROCESS_COMMIT_RESPONSE; |
| 229 break; | 227 break; |
| 230 } | 228 } |
| 231 case PROCESS_COMMIT_RESPONSE: { | 229 case PROCESS_COMMIT_RESPONSE: { |
| 232 session->mutable_status_controller()->reset_num_conflicting_commits(); | 230 session->mutable_status_controller()->reset_num_conflicting_commits(); |
| 233 ProcessCommitResponseCommand process_response_command; | 231 ProcessCommitResponseCommand process_response_command; |
| 234 session->mutable_status_controller()-> | 232 session->mutable_status_controller()-> |
| 235 set_last_process_commit_response_result( | 233 set_last_process_commit_response_result( |
| 236 process_response_command.Execute(session)); | 234 process_response_command.Execute(session)); |
| 237 next_step = BUILD_AND_PROCESS_CONFLICT_SETS; | |
| 238 break; | |
| 239 } | |
| 240 case BUILD_AND_PROCESS_CONFLICT_SETS: { | |
| 241 BuildAndProcessConflictSetsCommand build_process_conflict_sets; | |
| 242 build_process_conflict_sets.Execute(session); | |
| 243 next_step = RESOLVE_CONFLICTS; | 235 next_step = RESOLVE_CONFLICTS; |
| 244 break; | 236 break; |
| 245 } | 237 } |
| 246 case RESOLVE_CONFLICTS: { | 238 case RESOLVE_CONFLICTS: { |
| 247 StatusController* status = session->mutable_status_controller(); | 239 StatusController* status = session->mutable_status_controller(); |
| 248 status->reset_conflicts_resolved(); | 240 status->reset_conflicts_resolved(); |
| 249 ResolveConflictsCommand resolve_conflicts_command; | 241 ResolveConflictsCommand resolve_conflicts_command; |
| 250 resolve_conflicts_command.Execute(session); | 242 resolve_conflicts_command.Execute(session); |
| 251 | 243 |
| 252 // Has ConflictingUpdates includes both blocking and non-blocking | 244 // Has ConflictingUpdates includes both resolvable and unresolvable |
| 253 // conflicts. If we have either, we want to attempt to reapply. | 245 // conflicts. If we have either, we want to attempt to reapply. |
| 254 if (status->HasConflictingUpdates()) | 246 if (status->HasConflictingUpdates()) |
| 255 next_step = APPLY_UPDATES_TO_RESOLVE_CONFLICTS; | 247 next_step = APPLY_UPDATES_TO_RESOLVE_CONFLICTS; |
| 256 else | 248 else |
| 257 next_step = SYNCER_END; | 249 next_step = SYNCER_END; |
| 258 break; | 250 break; |
| 259 } | 251 } |
| 260 case APPLY_UPDATES_TO_RESOLVE_CONFLICTS: { | 252 case APPLY_UPDATES_TO_RESOLVE_CONFLICTS: { |
| 261 StatusController* status = session->mutable_status_controller(); | 253 StatusController* status = session->mutable_status_controller(); |
| 262 DVLOG(1) << "Applying updates to resolve conflicts"; | 254 DVLOG(1) << "Applying updates to resolve conflicts"; |
| 263 ApplyUpdatesCommand apply_updates; | 255 ApplyUpdatesCommand apply_updates; |
| 264 | 256 |
| 265 // We only care to resolve conflicts again if we made progress on the | 257 // We only care to resolve conflicts again if we made progress on the |
| 266 // blocking conflicts. Whether or not we made progress on the | 258 // simple conflicts. |
| 267 // non-blocking doesn't matter. | |
| 268 int before_blocking_conflicting_updates = | 259 int before_blocking_conflicting_updates = |
| 269 status->TotalNumBlockingConflictingItems(); | 260 status->TotalNumSimpleConflictingItems(); |
| 270 apply_updates.Execute(session); | 261 apply_updates.Execute(session); |
| 271 int after_blocking_conflicting_updates = | 262 int after_blocking_conflicting_updates = |
| 272 status->TotalNumBlockingConflictingItems(); | 263 status->TotalNumSimpleConflictingItems(); |
| 273 // If the following call sets the conflicts_resolved value to true, | 264 // If the following call sets the conflicts_resolved value to true, |
| 274 // SyncSession::HasMoreToSync() will send us into another sync cycle | 265 // SyncSession::HasMoreToSync() will send us into another sync cycle |
| 275 // after this one completes. | 266 // after this one completes. |
| 276 // | 267 // |
| 277 // TODO(rlarocque, 109072): Make conflict resolution not require | 268 // TODO(rlarocque, 109072): Make conflict resolution not require |
| 278 // extra sync cycles/GetUpdates. | 269 // extra sync cycles/GetUpdates. |
| 279 status->update_conflicts_resolved(before_blocking_conflicting_updates > | 270 status->update_conflicts_resolved(before_blocking_conflicting_updates > |
| 280 after_blocking_conflicting_updates); | 271 after_blocking_conflicting_updates); |
| 281 next_step = SYNCER_END; | 272 next_step = SYNCER_END; |
| 282 break; | 273 break; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 entry->Put(SERVER_CTIME, Time()); | 343 entry->Put(SERVER_CTIME, Time()); |
| 353 entry->Put(SERVER_VERSION, 0); | 344 entry->Put(SERVER_VERSION, 0); |
| 354 entry->Put(SERVER_IS_DIR, false); | 345 entry->Put(SERVER_IS_DIR, false); |
| 355 entry->Put(SERVER_IS_DEL, false); | 346 entry->Put(SERVER_IS_DEL, false); |
| 356 entry->Put(IS_UNAPPLIED_UPDATE, false); | 347 entry->Put(IS_UNAPPLIED_UPDATE, false); |
| 357 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); | 348 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); |
| 358 entry->Put(SERVER_POSITION_IN_PARENT, 0); | 349 entry->Put(SERVER_POSITION_IN_PARENT, 0); |
| 359 } | 350 } |
| 360 | 351 |
| 361 } // namespace browser_sync | 352 } // namespace browser_sync |
| OLD | NEW |