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::increment_num_tombstone_updates_downloaded_by(
     26     int value) {
     27   model_neutral_.num_tombstone_updates_downloaded_total += value;
     28 }
     29 
     30 void StatusController::increment_num_reflected_updates_downloaded_by(
     31     int value) {
     32   model_neutral_.num_reflected_updates_downloaded_total += value;
     33 }
     34 
     35 void StatusController::UpdateStartTime() {
     36   sync_start_time_ = base::Time::Now();
     37 }
     38 
     39 void StatusController::set_num_successful_bookmark_commits(int value) {
     40   model_neutral_.num_successful_bookmark_commits = value;
     41 }
     42 
     43 void StatusController::increment_num_successful_bookmark_commits() {
     44   model_neutral_.num_successful_bookmark_commits++;
     45 }
     46 
     47 void StatusController::increment_num_successful_commits() {
     48   model_neutral_.num_successful_commits++;
     49 }
     50 
     51 void StatusController::increment_num_updates_applied_by(int value) {
     52   model_neutral_.num_updates_applied += value;
     53 }
     54 
     55 void StatusController::increment_num_encryption_conflicts_by(int value) {
     56   model_neutral_.num_encryption_conflicts += value;
     57 }
     58 
     59 void StatusController::increment_num_hierarchy_conflicts_by(int value) {
     60   model_neutral_.num_hierarchy_conflicts += value;
     61 }
     62 
     63 void StatusController::increment_num_server_conflicts() {
     64   model_neutral_.num_server_conflicts++;
     65 }
     66 
     67 void StatusController::increment_num_local_overwrites() {
     68   model_neutral_.num_local_overwrites++;
     69 }
     70 
     71 void StatusController::increment_num_server_overwrites() {
     72   model_neutral_.num_server_overwrites++;
     73 }
     74 
     75 void StatusController::set_last_get_key_result(const SyncerError result) {
     76   model_neutral_.last_get_key_result = result;
     77 }
     78 
     79 void StatusController::set_last_download_updates_result(
     80     const SyncerError result) {
     81   model_neutral_.last_download_updates_result = result;
     82 }
     83 
     84 void StatusController::set_commit_result(const SyncerError result) {
     85   model_neutral_.commit_result = result;
     86 }
     87 
     88 SyncerError StatusController::last_get_key_result() const {
     89   return model_neutral_.last_get_key_result;
     90 }
     91 
     92 int StatusController::num_updates_applied() const {
     93   return model_neutral_.num_updates_applied;
     94 }
     95 
     96 int StatusController::num_server_overwrites() const {
     97   return model_neutral_.num_server_overwrites;
     98 }
     99 
    100 int StatusController::num_encryption_conflicts() const {
    101   return model_neutral_.num_encryption_conflicts;
    102 }
    103 
    104 int StatusController::num_hierarchy_conflicts() const {
    105   return model_neutral_.num_hierarchy_conflicts;
    106 }
    107 
    108 int StatusController::num_server_conflicts() const {
    109   return model_neutral_.num_server_conflicts;
    110 }
    111 
    112 int 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