| 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 "components/sync/engine_impl/all_status.h" | 5 #include "components/sync/engine_impl/all_status.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "components/sync/base/model_type.h" | 10 #include "components/sync/base/model_type.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 SyncStatus status = status_; | 28 SyncStatus status = status_; |
| 29 status.encryption_conflicts = 0; | 29 status.encryption_conflicts = 0; |
| 30 status.hierarchy_conflicts = 0; | 30 status.hierarchy_conflicts = 0; |
| 31 status.server_conflicts = 0; | 31 status.server_conflicts = 0; |
| 32 status.committed_count = 0; | 32 status.committed_count = 0; |
| 33 return status; | 33 return status; |
| 34 } | 34 } |
| 35 | 35 |
| 36 SyncStatus AllStatus::CalcSyncing(const SyncCycleEvent& event) const { | 36 SyncStatus AllStatus::CalcSyncing(const SyncCycleEvent& event) const { |
| 37 SyncStatus status = CreateBlankStatus(); | 37 SyncStatus status = CreateBlankStatus(); |
| 38 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; | 38 const SyncCycleSnapshot& snapshot = event.snapshot; |
| 39 status.encryption_conflicts = snapshot.num_encryption_conflicts(); | 39 status.encryption_conflicts = snapshot.num_encryption_conflicts(); |
| 40 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); | 40 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); |
| 41 status.server_conflicts = snapshot.num_server_conflicts(); | 41 status.server_conflicts = snapshot.num_server_conflicts(); |
| 42 status.committed_count = | 42 status.committed_count = |
| 43 snapshot.model_neutral_state().num_successful_commits; | 43 snapshot.model_neutral_state().num_successful_commits; |
| 44 | 44 |
| 45 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_BEGIN) { | 45 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_BEGIN) { |
| 46 status.syncing = true; | 46 status.syncing = true; |
| 47 } else if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { | 47 } else if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { |
| 48 status.syncing = false; | 48 status.syncing = false; |
| 49 } | 49 } |
| 50 | 50 |
| 51 status.num_entries_by_type = snapshot.num_entries_by_type(); | 51 status.num_entries_by_type = snapshot.num_entries_by_type(); |
| 52 status.num_to_delete_entries_by_type = | 52 status.num_to_delete_entries_by_type = |
| 53 snapshot.num_to_delete_entries_by_type(); | 53 snapshot.num_to_delete_entries_by_type(); |
| 54 | 54 |
| 55 // Accumulate update count only once per session to avoid double-counting. | 55 // Accumulate update count only once per cycle to avoid double-counting. |
| 56 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { | 56 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { |
| 57 status.updates_received += | 57 status.updates_received += |
| 58 snapshot.model_neutral_state().num_updates_downloaded_total; | 58 snapshot.model_neutral_state().num_updates_downloaded_total; |
| 59 status.tombstone_updates_received += | 59 status.tombstone_updates_received += |
| 60 snapshot.model_neutral_state().num_tombstone_updates_downloaded_total; | 60 snapshot.model_neutral_state().num_tombstone_updates_downloaded_total; |
| 61 status.reflected_updates_received += | 61 status.reflected_updates_received += |
| 62 snapshot.model_neutral_state().num_reflected_updates_downloaded_total; | 62 snapshot.model_neutral_state().num_reflected_updates_downloaded_total; |
| 63 status.num_commits_total += | 63 status.num_commits_total += |
| 64 snapshot.model_neutral_state().num_successful_commits; | 64 snapshot.model_neutral_state().num_successful_commits; |
| 65 status.num_local_overwrites_total += | 65 status.num_local_overwrites_total += |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) | 184 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) |
| 185 : allstatus_(allstatus) { | 185 : allstatus_(allstatus) { |
| 186 allstatus->mutex_.Acquire(); | 186 allstatus->mutex_.Acquire(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 ScopedStatusLock::~ScopedStatusLock() { | 189 ScopedStatusLock::~ScopedStatusLock() { |
| 190 allstatus_->mutex_.Release(); | 190 allstatus_->mutex_.Release(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace syncer | 193 } // namespace syncer |
| OLD | NEW |