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