| OLD | NEW |
| (Empty) |
| 1 // Copyright 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 // StatusController handles all counter and status related number crunching and | |
| 6 // state tracking on behalf of a SyncSession. | |
| 7 // | |
| 8 // This object may be accessed from many different threads. It will be accessed | |
| 9 // most often from the syncer thread. However, when update application is in | |
| 10 // progress it may also be accessed from the worker threads. This is safe | |
| 11 // because only one of them will run at a time, and the syncer thread will be | |
| 12 // blocked until update application completes. | |
| 13 // | |
| 14 // This object contains only global state. None of its members are per model | |
| 15 // type counters. | |
| 16 | |
| 17 #ifndef SYNC_SESSIONS_STATUS_CONTROLLER_H_ | |
| 18 #define SYNC_SESSIONS_STATUS_CONTROLLER_H_ | |
| 19 | |
| 20 #include <map> | |
| 21 #include <vector> | |
| 22 | |
| 23 #include "base/logging.h" | |
| 24 #include "base/macros.h" | |
| 25 #include "base/stl_util.h" | |
| 26 #include "base/time/time.h" | |
| 27 #include "sync/base/sync_export.h" | |
| 28 #include "sync/internal_api/public/engine/model_safe_worker.h" | |
| 29 #include "sync/internal_api/public/sessions/model_neutral_state.h" | |
| 30 | |
| 31 namespace syncer { | |
| 32 namespace sessions { | |
| 33 | |
| 34 class SYNC_EXPORT StatusController { | |
| 35 public: | |
| 36 StatusController(); | |
| 37 ~StatusController(); | |
| 38 | |
| 39 // The types included in the get updates and commit client to server requests. | |
| 40 const ModelTypeSet get_updates_request_types() const; | |
| 41 void set_get_updates_request_types(ModelTypeSet value); | |
| 42 const ModelTypeSet commit_request_types() const; | |
| 43 void set_commit_request_types(ModelTypeSet value); | |
| 44 | |
| 45 // Various conflict counters. | |
| 46 int num_encryption_conflicts() const; | |
| 47 int num_hierarchy_conflicts() const; | |
| 48 int num_server_conflicts() const; | |
| 49 | |
| 50 // Aggregate sum of all conflicting items over all conflict types. | |
| 51 int TotalNumConflictingItems() const; | |
| 52 | |
| 53 // Number of successfully applied updates. | |
| 54 int num_updates_applied() const; | |
| 55 | |
| 56 int num_server_overwrites() const; | |
| 57 int num_local_overwrites() const; | |
| 58 | |
| 59 // The time at which we started the first sync cycle in this session. | |
| 60 base::Time sync_start_time() const { | |
| 61 return sync_start_time_; | |
| 62 } | |
| 63 | |
| 64 // If a poll was performed in this session, the time at which it finished. | |
| 65 // Not set if no poll was performed. | |
| 66 base::Time poll_finish_time() const { | |
| 67 return poll_finish_time_; | |
| 68 } | |
| 69 | |
| 70 const ModelNeutralState& model_neutral_state() const { | |
| 71 return model_neutral_; | |
| 72 } | |
| 73 | |
| 74 SyncerError last_get_key_result() const; | |
| 75 | |
| 76 // Download counters. | |
| 77 void increment_num_updates_downloaded_by(int value); | |
| 78 void increment_num_tombstone_updates_downloaded_by(int value); | |
| 79 void increment_num_reflected_updates_downloaded_by(int value); | |
| 80 | |
| 81 // Update application and conflict resolution counters. | |
| 82 void increment_num_updates_applied_by(int value); | |
| 83 void increment_num_encryption_conflicts_by(int value); | |
| 84 void increment_num_hierarchy_conflicts_by(int value); | |
| 85 void increment_num_server_conflicts(); | |
| 86 void increment_num_local_overwrites(); | |
| 87 void increment_num_server_overwrites(); | |
| 88 | |
| 89 // Commit counters. | |
| 90 void increment_num_successful_commits(); | |
| 91 void increment_num_successful_bookmark_commits(); | |
| 92 void set_num_successful_bookmark_commits(int value); | |
| 93 | |
| 94 // Server communication status tracking. | |
| 95 void set_last_get_key_result(const SyncerError result); | |
| 96 void set_last_download_updates_result(const SyncerError result); | |
| 97 void set_commit_result(const SyncerError result); | |
| 98 | |
| 99 void UpdateStartTime(); | |
| 100 void UpdatePollTime(); | |
| 101 | |
| 102 private: | |
| 103 ModelNeutralState model_neutral_; | |
| 104 | |
| 105 // Time the last sync cycle began. | |
| 106 base::Time sync_start_time_; | |
| 107 | |
| 108 // If a poll was performed, the time it finished. Not set if not poll was | |
| 109 // performed. | |
| 110 base::Time poll_finish_time_; | |
| 111 | |
| 112 DISALLOW_COPY_AND_ASSIGN(StatusController); | |
| 113 }; | |
| 114 | |
| 115 } // namespace sessions | |
| 116 } // namespace syncer | |
| 117 | |
| 118 #endif // SYNC_SESSIONS_STATUS_CONTROLLER_H_ | |
| OLD | NEW |