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 |
| 8 // having to worry about this class. |
| 9 // |
| 10 // The UI will request that we fill this struct so it can show the current |
| 11 // sync 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 class SyncerSession; |
| 25 |
| 26 class SyncerStatus { |
| 27 public: |
| 28 explicit SyncerStatus(SyncCycleState* cycle_state, SyncProcessState* state) |
| 29 : sync_process_state_(state), |
| 30 sync_cycle_state_(cycle_state){} |
| 31 explicit SyncerStatus(SyncerSession* s); |
| 32 ~SyncerStatus(); |
| 33 |
| 34 bool invalid_store() const { |
| 35 return sync_process_state_->invalid_store(); |
| 36 } |
| 37 |
| 38 void set_invalid_store(const bool val) { |
| 39 sync_process_state_->set_invalid_store(val); |
| 40 } |
| 41 |
| 42 bool syncer_stuck() const { |
| 43 return sync_process_state_->syncer_stuck(); |
| 44 } |
| 45 |
| 46 void set_syncer_stuck(const bool val) { |
| 47 sync_process_state_->set_syncer_stuck(val); |
| 48 } |
| 49 |
| 50 bool syncing() const { |
| 51 return sync_process_state_->syncing(); |
| 52 } |
| 53 |
| 54 void set_syncing(const bool val) { |
| 55 sync_process_state_->set_syncing(val); |
| 56 } |
| 57 |
| 58 bool IsShareUsable() const { |
| 59 return sync_process_state_->IsShareUsable(); |
| 60 } |
| 61 |
| 62 // During initial sync these two members can be used to |
| 63 // measure sync progress. |
| 64 int64 current_sync_timestamp() const { |
| 65 return sync_process_state_->current_sync_timestamp(); |
| 66 } |
| 67 |
| 68 void set_current_sync_timestamp(const int64 val) { |
| 69 sync_process_state_->set_current_sync_timestamp(val); |
| 70 } |
| 71 |
| 72 int64 servers_latest_timestamp() const { |
| 73 return sync_process_state_->servers_latest_timestamp(); |
| 74 } |
| 75 |
| 76 void set_servers_latest_timestamp(const int64 val) { |
| 77 sync_process_state_->set_servers_latest_timestamp(val); |
| 78 } |
| 79 |
| 80 int64 unsynced_count() const { |
| 81 return sync_cycle_state_->unsynced_count(); |
| 82 } |
| 83 |
| 84 int conflicting_updates() const { |
| 85 return sync_process_state_->conflicting_updates(); |
| 86 } |
| 87 |
| 88 int conflicting_commits() const { |
| 89 return sync_process_state_->conflicting_commits(); |
| 90 } |
| 91 |
| 92 void set_conflicting_commits(const int val) { |
| 93 sync_process_state_->set_conflicting_commits(val); |
| 94 } |
| 95 |
| 96 int BlockedItemsSize() const { |
| 97 return sync_process_state_->BlockedItemsSize(); |
| 98 } |
| 99 |
| 100 // derive from sync_process_state blocked_item_ids_ |
| 101 int stalled_updates() const { |
| 102 return sync_process_state_->BlockedItemsSize(); |
| 103 } |
| 104 |
| 105 // in sync_process_state |
| 106 int error_commits() const { |
| 107 return sync_process_state_->error_commits(); |
| 108 } |
| 109 |
| 110 void set_error_commits(const int val) { |
| 111 sync_process_state_->set_error_commits(val); |
| 112 } |
| 113 |
| 114 // WEIRD COUNTER manipulation functions |
| 115 int consecutive_problem_get_updates() const { |
| 116 return sync_process_state_->consecutive_problem_get_updates(); |
| 117 } |
| 118 |
| 119 void increment_consecutive_problem_get_updates() { |
| 120 sync_process_state_->increment_consecutive_problem_get_updates(); |
| 121 } |
| 122 |
| 123 void zero_consecutive_problem_get_updates() { |
| 124 sync_process_state_->zero_consecutive_problem_get_updates(); |
| 125 } |
| 126 |
| 127 int consecutive_problem_commits() const { |
| 128 return sync_process_state_->consecutive_problem_commits(); |
| 129 } |
| 130 |
| 131 void increment_consecutive_problem_commits() { |
| 132 sync_process_state_->increment_consecutive_problem_commits(); |
| 133 } |
| 134 |
| 135 void zero_consecutive_problem_commits() { |
| 136 sync_process_state_->zero_consecutive_problem_commits(); |
| 137 } |
| 138 |
| 139 int consecutive_transient_error_commits() const { |
| 140 return sync_process_state_->consecutive_transient_error_commits(); |
| 141 } |
| 142 |
| 143 void increment_consecutive_transient_error_commits_by(int value) { |
| 144 sync_process_state_->increment_consecutive_transient_error_commits_by( |
| 145 value); |
| 146 } |
| 147 |
| 148 void zero_consecutive_transient_error_commits() { |
| 149 sync_process_state_->zero_consecutive_transient_error_commits(); |
| 150 } |
| 151 |
| 152 int consecutive_errors() const { |
| 153 return sync_process_state_->consecutive_errors(); |
| 154 } |
| 155 |
| 156 void increment_consecutive_errors() { |
| 157 increment_consecutive_errors_by(1); |
| 158 } |
| 159 |
| 160 void increment_consecutive_errors_by(int value) { |
| 161 sync_process_state_->increment_consecutive_errors_by(value); |
| 162 } |
| 163 |
| 164 void zero_consecutive_errors() { |
| 165 sync_process_state_->zero_consecutive_errors(); |
| 166 } |
| 167 |
| 168 int successful_commits() const { |
| 169 return sync_process_state_->successful_commits(); |
| 170 } |
| 171 |
| 172 void increment_successful_commits() { |
| 173 sync_process_state_->increment_successful_commits(); |
| 174 } |
| 175 |
| 176 void zero_successful_commits() { |
| 177 sync_process_state_->zero_successful_commits(); |
| 178 } |
| 179 // end WEIRD COUNTER manipulation functions |
| 180 |
| 181 bool over_quota() const { return sync_cycle_state_->over_quota(); } |
| 182 |
| 183 // Methods for managing error rate tracking in sync_process_state |
| 184 void TallyNewError() { |
| 185 sync_process_state_->TallyNewError(); |
| 186 } |
| 187 |
| 188 void TallyBigNewError() { |
| 189 sync_process_state_->TallyBigNewError(); |
| 190 } |
| 191 |
| 192 void ForgetOldError() { |
| 193 sync_process_state_->ForgetOldError(); |
| 194 } |
| 195 |
| 196 void CheckErrorRateTooHigh() { |
| 197 sync_process_state_->CheckErrorRateTooHigh(); |
| 198 } |
| 199 |
| 200 void AuthFailed() { sync_process_state_->AuthFailed(); } |
| 201 |
| 202 void AuthSucceeded() { sync_process_state_->AuthSucceeded(); } |
| 203 |
| 204 // Returns true if this object has been modified since last SetClean() call |
| 205 bool IsDirty() const { |
| 206 return sync_cycle_state_->IsDirty() || sync_process_state_->IsDirty(); |
| 207 } |
| 208 |
| 209 // Returns true if auth status has been modified since last SetClean() call |
| 210 bool IsAuthDirty() const { return sync_process_state_->IsAuthDirty(); } |
| 211 |
| 212 // Call to tell this status object that its new state has been seen |
| 213 void SetClean() { |
| 214 sync_process_state_->SetClean(); |
| 215 sync_cycle_state_->SetClean(); |
| 216 } |
| 217 |
| 218 // Call to tell this status object that its auth state has been seen |
| 219 void SetAuthClean() { sync_process_state_->SetAuthClean(); } |
| 220 |
| 221 void DumpStatusInfo() const { |
| 222 LOG(INFO) << "Dumping status info: " << (IsDirty() ? "DIRTY" : "CLEAN"); |
| 223 |
| 224 LOG(INFO) << "invalid store = " << invalid_store(); |
| 225 LOG(INFO) << "syncer_stuck = " << syncer_stuck(); |
| 226 LOG(INFO) << "syncing = " << syncing(); |
| 227 LOG(INFO) << "over_quota = " << over_quota(); |
| 228 |
| 229 LOG(INFO) << "current_sync_timestamp = " << current_sync_timestamp(); |
| 230 LOG(INFO) << "servers_latest_timestamp = " << servers_latest_timestamp(); |
| 231 LOG(INFO) << "unsynced_count = " << unsynced_count(); |
| 232 LOG(INFO) << "conflicting_updates = " << conflicting_updates(); |
| 233 LOG(INFO) << "conflicting_commits = " << conflicting_commits(); |
| 234 LOG(INFO) << "BlockedItemsSize = " << BlockedItemsSize(); |
| 235 LOG(INFO) << "stalled_updates = " << stalled_updates(); |
| 236 LOG(INFO) << "error_commits = " << error_commits(); |
| 237 |
| 238 LOG(INFO) << "consecutive_problem_get_updates = " |
| 239 << consecutive_problem_get_updates(); |
| 240 LOG(INFO) << "consecutive_problem_commits = " |
| 241 << consecutive_problem_commits(); |
| 242 LOG(INFO) << "consecutive_transient_error_commits = " |
| 243 << consecutive_transient_error_commits(); |
| 244 LOG(INFO) << "consecutive_errors = " << consecutive_errors(); |
| 245 LOG(INFO) << "successful_commits = " << successful_commits(); |
| 246 } |
| 247 |
| 248 private: |
| 249 |
| 250 SyncCycleState *sync_cycle_state_; |
| 251 SyncProcessState *sync_process_state_; |
| 252 |
| 253 }; |
| 254 } // namespace browser_sync |
| 255 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_STATUS_H_ |
OLD | NEW |