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
3 // found in the LICENSE file.
5 #include "sync/sessions/status_controller.h"
9 #include "base/basictypes.h"
10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/protocol/sync_protocol_error.h"
16 StatusController::StatusController() {
19 StatusController::~StatusController() {}
21 void StatusController::increment_num_updates_downloaded_by(int value) {
22 model_neutral_.num_updates_downloaded_total += value;
25 void StatusController::set_types_needing_local_migration(ModelTypeSet types) {
26 model_neutral_.types_needing_local_migration = types;
29 void StatusController::increment_num_tombstone_updates_downloaded_by(
31 model_neutral_.num_tombstone_updates_downloaded_total += value;
34 void StatusController::increment_num_reflected_updates_downloaded_by(
36 model_neutral_.num_reflected_updates_downloaded_total += value;
39 void StatusController::set_num_server_changes_remaining(
40 int64 changes_remaining) {
41 model_neutral_.num_server_changes_remaining = changes_remaining;
44 void StatusController::UpdateStartTime() {
45 sync_start_time_ = base::Time::Now();
48 void StatusController::set_num_successful_bookmark_commits(int value) {
49 model_neutral_.num_successful_bookmark_commits = value;
52 void StatusController::increment_num_successful_bookmark_commits() {
53 model_neutral_.num_successful_bookmark_commits++;
56 void StatusController::increment_num_successful_commits() {
57 model_neutral_.num_successful_commits++;
60 void StatusController::increment_num_updates_applied_by(int value) {
61 model_neutral_.num_updates_applied += value;
64 void StatusController::increment_num_encryption_conflicts_by(int value) {
65 model_neutral_.num_encryption_conflicts += value;
68 void StatusController::increment_num_hierarchy_conflicts_by(int value) {
69 model_neutral_.num_hierarchy_conflicts += value;
72 void StatusController::increment_num_server_conflicts() {
73 model_neutral_.num_server_conflicts++;
76 void StatusController::increment_num_local_overwrites() {
77 model_neutral_.num_local_overwrites++;
80 void StatusController::increment_num_server_overwrites() {
81 model_neutral_.num_server_overwrites++;
84 void StatusController::set_sync_protocol_error(
85 const SyncProtocolError& error) {
86 model_neutral_.sync_protocol_error = error;
89 void StatusController::set_last_get_key_result(const SyncerError result) {
90 model_neutral_.last_get_key_result = result;
93 void StatusController::set_last_download_updates_result(
94 const SyncerError result) {
95 model_neutral_.last_download_updates_result = result;
98 void StatusController::set_commit_result(const SyncerError result) {
99 model_neutral_.commit_result = result;
102 SyncerError StatusController::last_get_key_result() const {
103 return model_neutral_.last_get_key_result;
106 int StatusController::num_updates_applied() const {
107 return model_neutral_.num_updates_applied;
110 int StatusController::num_server_overwrites() const {
111 return model_neutral_.num_server_overwrites;
114 int StatusController::num_encryption_conflicts() const {
115 return model_neutral_.num_encryption_conflicts;
118 int StatusController::num_hierarchy_conflicts() const {
119 return model_neutral_.num_hierarchy_conflicts;
122 int StatusController::num_server_conflicts() const {
123 return model_neutral_.num_server_conflicts;
126 int StatusController::TotalNumConflictingItems() const {
128 sum += num_encryption_conflicts();
129 sum += num_hierarchy_conflicts();
130 sum += num_server_conflicts();
134 } // namespace sessions
135 } // namespace syncer