| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/tracked.h" | 9 #include "base/tracked.h" |
| 10 #include "chrome/browser/sync/engine/apply_updates_command.h" | 10 #include "chrome/browser/sync/engine/apply_updates_command.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 bool Syncer::ExitRequested() { | 64 bool Syncer::ExitRequested() { |
| 65 base::AutoLock lock(early_exit_requested_lock_); | 65 base::AutoLock lock(early_exit_requested_lock_); |
| 66 return early_exit_requested_; | 66 return early_exit_requested_; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void Syncer::RequestEarlyExit() { | 69 void Syncer::RequestEarlyExit() { |
| 70 base::AutoLock lock(early_exit_requested_lock_); | 70 base::AutoLock lock(early_exit_requested_lock_); |
| 71 early_exit_requested_ = true; | 71 early_exit_requested_ = true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void Syncer::CleanupDisabledTypes(sessions::SyncSession* session) { |
| 75 { |
| 76 ScopedDirLookup dir(session->context()->directory_manager(), |
| 77 session->context()->account_name()); |
| 78 // The directory must be good here. |
| 79 CHECK(dir.good()); |
| 80 } |
| 81 CleanupDisabledTypesCommand cleanup; |
| 82 cleanup.Execute(session); |
| 83 } |
| 84 |
| 74 void Syncer::SyncShare(sessions::SyncSession* session, | 85 void Syncer::SyncShare(sessions::SyncSession* session, |
| 75 const SyncerStep first_step, | 86 const SyncerStep first_step, |
| 76 const SyncerStep last_step) { | 87 const SyncerStep last_step) { |
| 77 ScopedDirLookup dir(session->context()->directory_manager(), | 88 { |
| 78 session->context()->account_name()); | 89 ScopedDirLookup dir(session->context()->directory_manager(), |
| 79 // The directory must be good here. | 90 session->context()->account_name()); |
| 80 CHECK(dir.good()); | 91 // The directory must be good here. |
| 92 CHECK(dir.good()); |
| 93 } |
| 81 | 94 |
| 82 ScopedSessionContextConflictResolver scoped(session->context(), | 95 ScopedSessionContextConflictResolver scoped(session->context(), |
| 83 &resolver_); | 96 &resolver_); |
| 84 SyncerStep current_step = first_step; | 97 SyncerStep current_step = first_step; |
| 85 | 98 |
| 86 SyncerStep next_step = current_step; | 99 SyncerStep next_step = current_step; |
| 87 while (!ExitRequested()) { | 100 while (!ExitRequested()) { |
| 88 switch (current_step) { | 101 switch (current_step) { |
| 89 case SYNCER_BEGIN: | 102 case SYNCER_BEGIN: |
| 90 VLOG(1) << "Syncer Begin"; | 103 VLOG(1) << "Syncer Begin"; |
| 91 // This isn't perfect, as we can end up bundling extensions activity | 104 // This isn't perfect, as we can end up bundling extensions activity |
| 92 // intended for the next session into the current one. We could do a | 105 // intended for the next session into the current one. We could do a |
| 93 // test-and-reset as with the source, but note that also falls short if | 106 // test-and-reset as with the source, but note that also falls short if |
| 94 // the commit request fails (e.g. due to lost connection), as we will | 107 // the commit request fails (e.g. due to lost connection), as we will |
| 95 // fall all the way back to the syncer thread main loop in that case, | 108 // fall all the way back to the syncer thread main loop in that case, |
| 96 // creating a new session when a connection is established, losing the | 109 // creating a new session when a connection is established, losing the |
| 97 // records set here on the original attempt. This should provide us | 110 // records set here on the original attempt. This should provide us |
| 98 // with the right data "most of the time", and we're only using this | 111 // with the right data "most of the time", and we're only using this |
| 99 // for analysis purposes, so Law of Large Numbers FTW. | 112 // for analysis purposes, so Law of Large Numbers FTW. |
| 100 session->context()->extensions_monitor()->GetAndClearRecords( | 113 session->context()->extensions_monitor()->GetAndClearRecords( |
| 101 session->mutable_extensions_activity()); | 114 session->mutable_extensions_activity()); |
| 102 next_step = CLEANUP_DISABLED_TYPES; | 115 next_step = CLEANUP_DISABLED_TYPES; |
| 103 break; | 116 break; |
| 104 case CLEANUP_DISABLED_TYPES: { | 117 case CLEANUP_DISABLED_TYPES: { |
| 105 VLOG(1) << "Cleaning up disabled types"; | 118 VLOG(1) << "Cleaning up disabled types"; |
| 106 CleanupDisabledTypesCommand cleanup; | 119 CleanupDisabledTypes(session); |
| 107 cleanup.Execute(session); | |
| 108 next_step = DOWNLOAD_UPDATES; | 120 next_step = DOWNLOAD_UPDATES; |
| 109 break; | 121 break; |
| 110 } | 122 } |
| 111 case DOWNLOAD_UPDATES: { | 123 case DOWNLOAD_UPDATES: { |
| 112 VLOG(1) << "Downloading Updates"; | 124 VLOG(1) << "Downloading Updates"; |
| 113 DownloadUpdatesCommand download_updates; | 125 DownloadUpdatesCommand download_updates; |
| 114 download_updates.Execute(session); | 126 download_updates.Execute(session); |
| 115 next_step = PROCESS_CLIENT_COMMAND; | 127 next_step = PROCESS_CLIENT_COMMAND; |
| 116 break; | 128 break; |
| 117 } | 129 } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 entry->Put(SERVER_CTIME, 0); | 342 entry->Put(SERVER_CTIME, 0); |
| 331 entry->Put(SERVER_VERSION, 0); | 343 entry->Put(SERVER_VERSION, 0); |
| 332 entry->Put(SERVER_IS_DIR, false); | 344 entry->Put(SERVER_IS_DIR, false); |
| 333 entry->Put(SERVER_IS_DEL, false); | 345 entry->Put(SERVER_IS_DEL, false); |
| 334 entry->Put(IS_UNAPPLIED_UPDATE, false); | 346 entry->Put(IS_UNAPPLIED_UPDATE, false); |
| 335 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); | 347 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); |
| 336 entry->Put(SERVER_POSITION_IN_PARENT, 0); | 348 entry->Put(SERVER_POSITION_IN_PARENT, 0); |
| 337 } | 349 } |
| 338 | 350 |
| 339 } // namespace browser_sync | 351 } // namespace browser_sync |
| OLD | NEW |