| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 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 // TODO(sync): We eventually want to fundamentally change how we represent | |
| 6 // status and inform the UI about the ways in which our status has changed. | |
| 7 // Right now, we're just trying to keep the various command classes from having | |
| 8 // to worry about this class. | |
| 9 // | |
| 10 // The UI will request that we fill this struct so it can show the current sync | |
| 11 // state. | |
| 12 // | |
| 13 // THIS CLASS PROVIDES NO SYNCHRONIZATION GUARANTEES. | |
| 14 | |
| 15 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_STATUS_H_ | |
| 16 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_STATUS_H_ | |
| 17 | |
| 18 #include "base/atomicops.h" | |
| 19 #include "base/port.h" | |
| 20 #include "chrome/browser/sync/engine/sync_cycle_state.h" | |
| 21 #include "chrome/browser/sync/engine/sync_process_state.h" | |
| 22 | |
| 23 namespace browser_sync { | |
| 24 | |
| 25 class SyncerSession; | |
| 26 | |
| 27 class SyncerStatus { | |
| 28 public: | |
| 29 SyncerStatus(SyncCycleState* cycle_state, SyncProcessState* state) | |
| 30 : sync_cycle_state_(cycle_state), | |
| 31 sync_process_state_(state) {} | |
| 32 explicit SyncerStatus(SyncerSession* s); | |
| 33 ~SyncerStatus(); | |
| 34 | |
| 35 bool invalid_store() const { | |
| 36 return sync_process_state_->invalid_store(); | |
| 37 } | |
| 38 | |
| 39 bool syncer_stuck() const { | |
| 40 return sync_process_state_->syncer_stuck(); | |
| 41 } | |
| 42 | |
| 43 void set_syncer_stuck(const bool val) { | |
| 44 sync_process_state_->set_syncer_stuck(val); | |
| 45 } | |
| 46 | |
| 47 bool syncing() const { | |
| 48 return sync_process_state_->syncing(); | |
| 49 } | |
| 50 | |
| 51 void set_syncing(const bool val) { | |
| 52 sync_process_state_->set_syncing(val); | |
| 53 } | |
| 54 | |
| 55 bool IsShareUsable() const { | |
| 56 return sync_process_state_->IsShareUsable(); | |
| 57 } | |
| 58 | |
| 59 // During initial sync these two members can be used to measure sync | |
| 60 // progress. | |
| 61 int64 current_sync_timestamp() const { | |
| 62 return sync_process_state_->current_sync_timestamp(); | |
| 63 } | |
| 64 | |
| 65 void set_current_sync_timestamp(const int64 val) { | |
| 66 sync_process_state_->set_current_sync_timestamp(val); | |
| 67 } | |
| 68 | |
| 69 int64 num_server_changes_remaining() const { | |
| 70 return sync_process_state_->num_server_changes_remaining(); | |
| 71 } | |
| 72 | |
| 73 void set_num_server_changes_remaining(const int64 val) { | |
| 74 sync_process_state_->set_num_server_changes_remaining(val); | |
| 75 } | |
| 76 | |
| 77 int64 unsynced_count() const { | |
| 78 return sync_cycle_state_->unsynced_count(); | |
| 79 } | |
| 80 | |
| 81 int conflicting_updates() const { | |
| 82 return sync_process_state_->conflicting_updates(); | |
| 83 } | |
| 84 | |
| 85 int conflicting_commits() const { | |
| 86 return sync_process_state_->conflicting_commits(); | |
| 87 } | |
| 88 | |
| 89 void set_conflicting_commits(const int val) { | |
| 90 sync_process_state_->set_conflicting_commits(val); | |
| 91 } | |
| 92 | |
| 93 // WEIRD COUNTER manipulation functions. | |
| 94 int consecutive_problem_get_updates() const { | |
| 95 return sync_process_state_->consecutive_problem_get_updates(); | |
| 96 } | |
| 97 | |
| 98 void increment_consecutive_problem_get_updates() { | |
| 99 sync_process_state_->increment_consecutive_problem_get_updates(); | |
| 100 } | |
| 101 | |
| 102 void zero_consecutive_problem_get_updates() { | |
| 103 sync_process_state_->zero_consecutive_problem_get_updates(); | |
| 104 } | |
| 105 | |
| 106 int consecutive_problem_commits() const { | |
| 107 return sync_process_state_->consecutive_problem_commits(); | |
| 108 } | |
| 109 | |
| 110 void increment_consecutive_problem_commits() { | |
| 111 sync_process_state_->increment_consecutive_problem_commits(); | |
| 112 } | |
| 113 | |
| 114 void zero_consecutive_problem_commits() { | |
| 115 sync_process_state_->zero_consecutive_problem_commits(); | |
| 116 } | |
| 117 | |
| 118 int consecutive_transient_error_commits() const { | |
| 119 return sync_process_state_->consecutive_transient_error_commits(); | |
| 120 } | |
| 121 | |
| 122 void increment_consecutive_transient_error_commits_by(int value) { | |
| 123 sync_process_state_->increment_consecutive_transient_error_commits_by( | |
| 124 value); | |
| 125 } | |
| 126 | |
| 127 void zero_consecutive_transient_error_commits() { | |
| 128 sync_process_state_->zero_consecutive_transient_error_commits(); | |
| 129 } | |
| 130 | |
| 131 int consecutive_errors() const { | |
| 132 return sync_process_state_->consecutive_errors(); | |
| 133 } | |
| 134 | |
| 135 void increment_consecutive_errors() { | |
| 136 increment_consecutive_errors_by(1); | |
| 137 } | |
| 138 | |
| 139 void increment_consecutive_errors_by(int value) { | |
| 140 sync_process_state_->increment_consecutive_errors_by(value); | |
| 141 } | |
| 142 | |
| 143 void zero_consecutive_errors() { | |
| 144 sync_process_state_->zero_consecutive_errors(); | |
| 145 } | |
| 146 | |
| 147 int successful_commits() const { | |
| 148 return sync_process_state_->successful_commits(); | |
| 149 } | |
| 150 | |
| 151 void increment_successful_commits() { | |
| 152 sync_process_state_->increment_successful_commits(); | |
| 153 } | |
| 154 | |
| 155 void zero_successful_commits() { | |
| 156 sync_process_state_->zero_successful_commits(); | |
| 157 } | |
| 158 // End WEIRD COUNTER manipulation functions. | |
| 159 | |
| 160 bool over_quota() const { return sync_cycle_state_->over_quota(); } | |
| 161 | |
| 162 void AuthFailed() { sync_process_state_->AuthFailed(); } | |
| 163 | |
| 164 // Returns true if this object has been modified since last SetClean() call. | |
| 165 bool IsDirty() const { | |
| 166 return sync_cycle_state_->IsDirty() || sync_process_state_->IsDirty(); | |
| 167 } | |
| 168 | |
| 169 // Returns true if auth status has been modified since last SetClean() call. | |
| 170 bool IsAuthDirty() const { return sync_process_state_->IsAuthDirty(); } | |
| 171 | |
| 172 // Call to tell this status object that its new state has been seen. | |
| 173 void SetClean() { | |
| 174 sync_process_state_->SetClean(); | |
| 175 sync_cycle_state_->SetClean(); | |
| 176 } | |
| 177 | |
| 178 // Call to tell this status object that its auth state has been seen. | |
| 179 void SetAuthClean() { sync_process_state_->SetAuthClean(); } | |
| 180 | |
| 181 void DumpStatusInfo() const { | |
| 182 LOG(INFO) << "Dumping status info: " << (IsDirty() ? "DIRTY" : "CLEAN"); | |
| 183 | |
| 184 LOG(INFO) << "invalid store = " << invalid_store(); | |
| 185 LOG(INFO) << "syncer_stuck = " << syncer_stuck(); | |
| 186 LOG(INFO) << "syncing = " << syncing(); | |
| 187 LOG(INFO) << "over_quota = " << over_quota(); | |
| 188 | |
| 189 LOG(INFO) << "current_sync_timestamp = " << current_sync_timestamp(); | |
| 190 LOG(INFO) << "num_server_changes_remaining = " | |
| 191 << num_server_changes_remaining(); | |
| 192 LOG(INFO) << "unsynced_count = " << unsynced_count(); | |
| 193 LOG(INFO) << "conflicting_updates = " << conflicting_updates(); | |
| 194 LOG(INFO) << "conflicting_commits = " << conflicting_commits(); | |
| 195 | |
| 196 LOG(INFO) << "consecutive_problem_get_updates = " | |
| 197 << consecutive_problem_get_updates(); | |
| 198 LOG(INFO) << "consecutive_problem_commits = " | |
| 199 << consecutive_problem_commits(); | |
| 200 LOG(INFO) << "consecutive_transient_error_commits = " | |
| 201 << consecutive_transient_error_commits(); | |
| 202 LOG(INFO) << "consecutive_errors = " << consecutive_errors(); | |
| 203 LOG(INFO) << "successful_commits = " << successful_commits(); | |
| 204 } | |
| 205 | |
| 206 private: | |
| 207 SyncCycleState* sync_cycle_state_; | |
| 208 SyncProcessState* sync_process_state_; | |
| 209 }; | |
| 210 | |
| 211 } // namespace browser_sync | |
| 212 | |
| 213 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_STATUS_H_ | |
| OLD | NEW |