| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/sessions/sync_session.h" |
| 6 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 7 |
| 8 namespace browser_sync { |
| 9 namespace sessions { |
| 10 |
| 11 SyncSession::SyncSession(SyncSessionContext* context, Delegate* delegate) |
| 12 : context_(context), |
| 13 source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN), |
| 14 write_transaction_(NULL), |
| 15 delegate_(delegate), |
| 16 auth_failure_occurred_(false) { |
| 17 } |
| 18 |
| 19 SyncSessionSnapshot SyncSession::TakeSnapshot() const { |
| 20 syncable::ScopedDirLookup dir(context_->directory_manager(), |
| 21 context_->account_name()); |
| 22 if (!dir.good()) |
| 23 LOG(ERROR) << "Scoped dir lookup failed!"; |
| 24 |
| 25 const bool is_share_usable = dir->initial_sync_ended(); |
| 26 return SyncSessionSnapshot( |
| 27 status_controller_.syncer_status(), |
| 28 status_controller_.error_counters(), |
| 29 status_controller_.change_progress(), |
| 30 is_share_usable, |
| 31 HasMoreToSync(), |
| 32 delegate_->IsSyncingCurrentlySilenced(), |
| 33 status_controller_.unsynced_handles().size(), |
| 34 status_controller_.conflict_progress()->ConflictingItemsSize(), |
| 35 status_controller_.did_commit_items()); |
| 36 } |
| 37 |
| 38 sync_pb::GetUpdatesCallerInfo::GET_UPDATES_SOURCE |
| 39 SyncSession::TestAndSetSource() { |
| 40 sync_pb::GetUpdatesCallerInfo::GET_UPDATES_SOURCE old_source = source_; |
| 41 set_source(sync_pb::GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION); |
| 42 return old_source; |
| 43 } |
| 44 |
| 45 bool SyncSession::HasMoreToSync() const { |
| 46 const StatusController& status = status_controller_; |
| 47 return ((status.commit_ids().size() < status.unsynced_handles().size()) && |
| 48 status.syncer_status().num_successful_commits > 0) || |
| 49 status.conflict_sets_built() || |
| 50 status.conflicts_resolved() || |
| 51 // Or, we have conflicting updates, but we're making progress on |
| 52 // resolving them... |
| 53 !status.got_zero_updates() || |
| 54 status.timestamp_dirty(); |
| 55 } |
| 56 |
| 57 } // namespace sessions |
| 58 } // namespace browser_sync |
| OLD | NEW |