• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 namespace syncer {
14 namespace sessions {
15 
StatusController()16 StatusController::StatusController() {
17 }
18 
~StatusController()19 StatusController::~StatusController() {}
20 
increment_num_updates_downloaded_by(int value)21 void StatusController::increment_num_updates_downloaded_by(int value) {
22   model_neutral_.num_updates_downloaded_total += value;
23 }
24 
set_types_needing_local_migration(ModelTypeSet types)25 void StatusController::set_types_needing_local_migration(ModelTypeSet types) {
26   model_neutral_.types_needing_local_migration = types;
27 }
28 
increment_num_tombstone_updates_downloaded_by(int value)29 void StatusController::increment_num_tombstone_updates_downloaded_by(
30     int value) {
31   model_neutral_.num_tombstone_updates_downloaded_total += value;
32 }
33 
increment_num_reflected_updates_downloaded_by(int value)34 void StatusController::increment_num_reflected_updates_downloaded_by(
35     int value) {
36   model_neutral_.num_reflected_updates_downloaded_total += value;
37 }
38 
set_num_server_changes_remaining(int64 changes_remaining)39 void StatusController::set_num_server_changes_remaining(
40     int64 changes_remaining) {
41   model_neutral_.num_server_changes_remaining = changes_remaining;
42 }
43 
UpdateStartTime()44 void StatusController::UpdateStartTime() {
45   sync_start_time_ = base::Time::Now();
46 }
47 
set_num_successful_bookmark_commits(int value)48 void StatusController::set_num_successful_bookmark_commits(int value) {
49   model_neutral_.num_successful_bookmark_commits = value;
50 }
51 
increment_num_successful_bookmark_commits()52 void StatusController::increment_num_successful_bookmark_commits() {
53   model_neutral_.num_successful_bookmark_commits++;
54 }
55 
increment_num_successful_commits()56 void StatusController::increment_num_successful_commits() {
57   model_neutral_.num_successful_commits++;
58 }
59 
increment_num_updates_applied_by(int value)60 void StatusController::increment_num_updates_applied_by(int value) {
61   model_neutral_.num_updates_applied += value;
62 }
63 
increment_num_encryption_conflicts_by(int value)64 void StatusController::increment_num_encryption_conflicts_by(int value) {
65   model_neutral_.num_encryption_conflicts += value;
66 }
67 
increment_num_hierarchy_conflicts_by(int value)68 void StatusController::increment_num_hierarchy_conflicts_by(int value) {
69   model_neutral_.num_hierarchy_conflicts += value;
70 }
71 
increment_num_server_conflicts()72 void StatusController::increment_num_server_conflicts() {
73   model_neutral_.num_server_conflicts++;
74 }
75 
increment_num_local_overwrites()76 void StatusController::increment_num_local_overwrites() {
77   model_neutral_.num_local_overwrites++;
78 }
79 
increment_num_server_overwrites()80 void StatusController::increment_num_server_overwrites() {
81   model_neutral_.num_server_overwrites++;
82 }
83 
set_sync_protocol_error(const SyncProtocolError & error)84 void StatusController::set_sync_protocol_error(
85     const SyncProtocolError& error) {
86   model_neutral_.sync_protocol_error = error;
87 }
88 
set_last_get_key_result(const SyncerError result)89 void StatusController::set_last_get_key_result(const SyncerError result) {
90   model_neutral_.last_get_key_result = result;
91 }
92 
set_last_download_updates_result(const SyncerError result)93 void StatusController::set_last_download_updates_result(
94     const SyncerError result) {
95   model_neutral_.last_download_updates_result = result;
96 }
97 
set_commit_result(const SyncerError result)98 void StatusController::set_commit_result(const SyncerError result) {
99   model_neutral_.commit_result = result;
100 }
101 
last_get_key_result() const102 SyncerError StatusController::last_get_key_result() const {
103   return model_neutral_.last_get_key_result;
104 }
105 
num_updates_applied() const106 int StatusController::num_updates_applied() const {
107   return model_neutral_.num_updates_applied;
108 }
109 
num_server_overwrites() const110 int StatusController::num_server_overwrites() const {
111   return model_neutral_.num_server_overwrites;
112 }
113 
num_encryption_conflicts() const114 int StatusController::num_encryption_conflicts() const {
115   return model_neutral_.num_encryption_conflicts;
116 }
117 
num_hierarchy_conflicts() const118 int StatusController::num_hierarchy_conflicts() const {
119   return model_neutral_.num_hierarchy_conflicts;
120 }
121 
num_server_conflicts() const122 int StatusController::num_server_conflicts() const {
123   return model_neutral_.num_server_conflicts;
124 }
125 
TotalNumConflictingItems() const126 int StatusController::TotalNumConflictingItems() const {
127   int sum = 0;
128   sum += num_encryption_conflicts();
129   sum += num_hierarchy_conflicts();
130   sum += num_server_conflicts();
131   return sum;
132 }
133 
134 }  // namespace sessions
135 }  // namespace syncer
136