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 "sync/engine/all_status.h" | 5 #include "sync/engine/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 "base/port.h" | 10 #include "base/port.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 SyncStatus AllStatus::CreateBlankStatus() const { | 26 SyncStatus AllStatus::CreateBlankStatus() const { |
27 // Status is initialized with the previous status value. Variables | 27 // Status is initialized with the previous status value. Variables |
28 // whose values accumulate (e.g. lifetime counters like updates_received) | 28 // whose values accumulate (e.g. lifetime counters like updates_received) |
29 // are not to be cleared here. | 29 // are not to be cleared here. |
30 SyncStatus status = status_; | 30 SyncStatus status = status_; |
31 status.encryption_conflicts = 0; | 31 status.encryption_conflicts = 0; |
32 status.hierarchy_conflicts = 0; | 32 status.hierarchy_conflicts = 0; |
33 status.server_conflicts = 0; | 33 status.server_conflicts = 0; |
34 status.committed_count = 0; | 34 status.committed_count = 0; |
35 status.updates_available = 0; | |
36 return status; | 35 return status; |
37 } | 36 } |
38 | 37 |
39 SyncStatus AllStatus::CalcSyncing(const SyncCycleEvent &event) const { | 38 SyncStatus AllStatus::CalcSyncing(const SyncCycleEvent &event) const { |
40 SyncStatus status = CreateBlankStatus(); | 39 SyncStatus status = CreateBlankStatus(); |
41 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; | 40 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; |
42 status.encryption_conflicts = snapshot.num_encryption_conflicts(); | 41 status.encryption_conflicts = snapshot.num_encryption_conflicts(); |
43 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); | 42 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); |
44 status.server_conflicts = snapshot.num_server_conflicts(); | 43 status.server_conflicts = snapshot.num_server_conflicts(); |
45 status.committed_count = | 44 status.committed_count = |
46 snapshot.model_neutral_state().num_successful_commits; | 45 snapshot.model_neutral_state().num_successful_commits; |
47 | 46 |
48 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_BEGIN) { | 47 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_BEGIN) { |
49 status.syncing = true; | 48 status.syncing = true; |
50 } else if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { | 49 } else if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { |
51 status.syncing = false; | 50 status.syncing = false; |
52 } | 51 } |
53 | 52 |
54 status.updates_available += snapshot.num_server_changes_remaining(); | |
55 | |
56 status.num_entries_by_type = snapshot.num_entries_by_type(); | 53 status.num_entries_by_type = snapshot.num_entries_by_type(); |
57 status.num_to_delete_entries_by_type = | 54 status.num_to_delete_entries_by_type = |
58 snapshot.num_to_delete_entries_by_type(); | 55 snapshot.num_to_delete_entries_by_type(); |
59 | 56 |
60 // Accumulate update count only once per session to avoid double-counting. | 57 // Accumulate update count only once per session to avoid double-counting. |
61 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { | 58 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { |
62 status.updates_received += | 59 status.updates_received += |
63 snapshot.model_neutral_state().num_updates_downloaded_total; | 60 snapshot.model_neutral_state().num_updates_downloaded_total; |
64 status.tombstone_updates_received += | 61 status.tombstone_updates_received += |
65 snapshot.model_neutral_state().num_tombstone_updates_downloaded_total; | 62 snapshot.model_neutral_state().num_tombstone_updates_downloaded_total; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) | 186 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) |
190 : allstatus_(allstatus) { | 187 : allstatus_(allstatus) { |
191 allstatus->mutex_.Acquire(); | 188 allstatus->mutex_.Acquire(); |
192 } | 189 } |
193 | 190 |
194 ScopedStatusLock::~ScopedStatusLock() { | 191 ScopedStatusLock::~ScopedStatusLock() { |
195 allstatus_->mutex_.Release(); | 192 allstatus_->mutex_.Release(); |
196 } | 193 } |
197 | 194 |
198 } // namespace syncer | 195 } // namespace syncer |
OLD | NEW |