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