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.
4
5#include "sync/sessions/status_controller.h"
6
7#include <vector>
8
9#include "base/basictypes.h"
10#include "sync/internal_api/public/base/model_type.h"
11#include "sync/protocol/sync_protocol_error.h"
12
13namespace syncer {
14namespace sessions {
15
16StatusController::StatusController() {
17}
18
19StatusController::~StatusController() {}
20
21void StatusController::increment_num_updates_downloaded_by(int value) {
22  model_neutral_.num_updates_downloaded_total += value;
23}
24
25void StatusController::increment_num_tombstone_updates_downloaded_by(
26    int value) {
27  model_neutral_.num_tombstone_updates_downloaded_total += value;
28}
29
30void StatusController::increment_num_reflected_updates_downloaded_by(
31    int value) {
32  model_neutral_.num_reflected_updates_downloaded_total += value;
33}
34
35void StatusController::UpdateStartTime() {
36  sync_start_time_ = base::Time::Now();
37}
38
39void StatusController::set_num_successful_bookmark_commits(int value) {
40  model_neutral_.num_successful_bookmark_commits = value;
41}
42
43void StatusController::increment_num_successful_bookmark_commits() {
44  model_neutral_.num_successful_bookmark_commits++;
45}
46
47void StatusController::increment_num_successful_commits() {
48  model_neutral_.num_successful_commits++;
49}
50
51void StatusController::increment_num_updates_applied_by(int value) {
52  model_neutral_.num_updates_applied += value;
53}
54
55void StatusController::increment_num_encryption_conflicts_by(int value) {
56  model_neutral_.num_encryption_conflicts += value;
57}
58
59void StatusController::increment_num_hierarchy_conflicts_by(int value) {
60  model_neutral_.num_hierarchy_conflicts += value;
61}
62
63void StatusController::increment_num_server_conflicts() {
64  model_neutral_.num_server_conflicts++;
65}
66
67void StatusController::increment_num_local_overwrites() {
68  model_neutral_.num_local_overwrites++;
69}
70
71void StatusController::increment_num_server_overwrites() {
72  model_neutral_.num_server_overwrites++;
73}
74
75void StatusController::set_last_get_key_result(const SyncerError result) {
76  model_neutral_.last_get_key_result = result;
77}
78
79void StatusController::set_last_download_updates_result(
80    const SyncerError result) {
81  model_neutral_.last_download_updates_result = result;
82}
83
84void StatusController::set_commit_result(const SyncerError result) {
85  model_neutral_.commit_result = result;
86}
87
88SyncerError StatusController::last_get_key_result() const {
89  return model_neutral_.last_get_key_result;
90}
91
92int StatusController::num_updates_applied() const {
93  return model_neutral_.num_updates_applied;
94}
95
96int StatusController::num_server_overwrites() const {
97  return model_neutral_.num_server_overwrites;
98}
99
100int StatusController::num_encryption_conflicts() const {
101  return model_neutral_.num_encryption_conflicts;
102}
103
104int StatusController::num_hierarchy_conflicts() const {
105  return model_neutral_.num_hierarchy_conflicts;
106}
107
108int StatusController::num_server_conflicts() const {
109  return model_neutral_.num_server_conflicts;
110}
111
112int StatusController::TotalNumConflictingItems() const {
113  int sum = 0;
114  sum += num_encryption_conflicts();
115  sum += num_hierarchy_conflicts();
116  sum += num_server_conflicts();
117  return sum;
118}
119
120}  // namespace sessions
121}  // namespace syncer
122