| 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/internal_api/all_status.h" | 5 #include "sync/internal_api/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 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 AllStatus::~AllStatus() { | 24 AllStatus::~AllStatus() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { | 27 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { |
| 28 // Status is initialized with the previous status value. Variables | 28 // Status is initialized with the previous status value. Variables |
| 29 // whose values accumulate (e.g. lifetime counters like updates_received) | 29 // whose values accumulate (e.g. lifetime counters like updates_received) |
| 30 // are not to be cleared here. | 30 // are not to be cleared here. |
| 31 sync_api::SyncManager::Status status = status_; | 31 sync_api::SyncManager::Status status = status_; |
| 32 status.unsynced_count = 0; | |
| 33 status.encryption_conflicts = 0; | 32 status.encryption_conflicts = 0; |
| 34 status.hierarchy_conflicts = 0; | 33 status.hierarchy_conflicts = 0; |
| 35 status.simple_conflicts = 0; | 34 status.simple_conflicts = 0; |
| 36 status.server_conflicts = 0; | 35 status.server_conflicts = 0; |
| 37 status.committed_count = 0; | 36 status.committed_count = 0; |
| 38 status.initial_sync_ended = false; | 37 status.initial_sync_ended = false; |
| 39 status.updates_available = 0; | 38 status.updates_available = 0; |
| 40 return status; | 39 return status; |
| 41 } | 40 } |
| 42 | 41 |
| 43 sync_api::SyncManager::Status AllStatus::CalcSyncing( | 42 sync_api::SyncManager::Status AllStatus::CalcSyncing( |
| 44 const SyncEngineEvent &event) const { | 43 const SyncEngineEvent &event) const { |
| 45 sync_api::SyncManager::Status status = CreateBlankStatus(); | 44 sync_api::SyncManager::Status status = CreateBlankStatus(); |
| 46 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; | 45 const sessions::SyncSessionSnapshot& snapshot = event.snapshot; |
| 47 status.unsynced_count = static_cast<int>(snapshot.unsynced_count()); | |
| 48 status.encryption_conflicts = snapshot.num_encryption_conflicts(); | 46 status.encryption_conflicts = snapshot.num_encryption_conflicts(); |
| 49 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); | 47 status.hierarchy_conflicts = snapshot.num_hierarchy_conflicts(); |
| 50 status.simple_conflicts = snapshot.num_simple_conflicts(); | 48 status.simple_conflicts = snapshot.num_simple_conflicts(); |
| 51 status.server_conflicts = snapshot.num_server_conflicts(); | 49 status.server_conflicts = snapshot.num_server_conflicts(); |
| 52 status.committed_count = snapshot.syncer_status().num_successful_commits; | 50 status.committed_count = snapshot.syncer_status().num_successful_commits; |
| 53 | 51 |
| 54 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_BEGIN) { | 52 if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_BEGIN) { |
| 55 status.syncing = true; | 53 status.syncing = true; |
| 56 } else if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { | 54 } else if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) { |
| 57 status.syncing = false; | 55 status.syncing = false; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) | 155 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) |
| 158 : allstatus_(allstatus) { | 156 : allstatus_(allstatus) { |
| 159 allstatus->mutex_.Acquire(); | 157 allstatus->mutex_.Acquire(); |
| 160 } | 158 } |
| 161 | 159 |
| 162 ScopedStatusLock::~ScopedStatusLock() { | 160 ScopedStatusLock::~ScopedStatusLock() { |
| 163 allstatus_->mutex_.Release(); | 161 allstatus_->mutex_.Release(); |
| 164 } | 162 } |
| 165 | 163 |
| 166 } // namespace browser_sync | 164 } // namespace browser_sync |
| OLD | NEW |