| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/internal_api/all_status.h" | 5 #include "chrome/browser/sync/internal_api/all_status.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/port.h" | 10 #include "base/port.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 ++status.useless_sync_cycles; | 91 ++status.useless_sync_cycles; |
| 92 } else { | 92 } else { |
| 93 ++status.useful_sync_cycles; | 93 ++status.useful_sync_cycles; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 return status; | 96 return status; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void AllStatus::CalcStatusChanges() { | 99 void AllStatus::CalcStatusChanges() { |
| 100 const bool unsynced_changes = status_.unsynced_count > 0; | 100 const bool unsynced_changes = status_.unsynced_count > 0; |
| 101 const bool online = status_.authenticated && | 101 // TODO(rlarocque): Hard-coding online to true is a hack that patches over |
| 102 status_.server_reachable && status_.server_up; | 102 // crbug.com/112229, and limits the fallout from some ServerConnectionManager |
| 103 // changes. We will be making more drastic changes to the summary value in |
| 104 // the near future. See crbug.com/98346. |
| 105 const bool online = true; |
| 103 if (online) { | 106 if (online) { |
| 104 if (status_.syncing) | 107 if (status_.syncing) |
| 105 status_.summary = sync_api::SyncManager::Status::SYNCING; | 108 status_.summary = sync_api::SyncManager::Status::SYNCING; |
| 106 else | 109 else |
| 107 status_.summary = sync_api::SyncManager::Status::READY; | 110 status_.summary = sync_api::SyncManager::Status::READY; |
| 108 } else if (!status_.initial_sync_ended) { | 111 } else if (!status_.initial_sync_ended) { |
| 109 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNUSABLE; | 112 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNUSABLE; |
| 110 } else if (unsynced_changes) { | 113 } else if (unsynced_changes) { |
| 111 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNSYNCED; | 114 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNSYNCED; |
| 112 } else { | 115 } else { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 130 case SyncEngineEvent::ACTIONABLE_ERROR: | 133 case SyncEngineEvent::ACTIONABLE_ERROR: |
| 131 status_ = CreateBlankStatus(); | 134 status_ = CreateBlankStatus(); |
| 132 status_.sync_protocol_error = event.snapshot->errors.sync_protocol_error; | 135 status_.sync_protocol_error = event.snapshot->errors.sync_protocol_error; |
| 133 break; | 136 break; |
| 134 default: | 137 default: |
| 135 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened; | 138 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened; |
| 136 break; | 139 break; |
| 137 } | 140 } |
| 138 } | 141 } |
| 139 | 142 |
| 140 void AllStatus::HandleServerConnectionEvent( | |
| 141 const ServerConnectionEvent& event) { | |
| 142 ScopedStatusLock lock(this); | |
| 143 status_.server_up = IsGoodReplyFromServer(event.connection_code); | |
| 144 status_.server_reachable = event.server_reachable; | |
| 145 | |
| 146 if (event.connection_code == HttpResponse::SERVER_CONNECTION_OK) { | |
| 147 status_.authenticated = true; | |
| 148 } else { | |
| 149 status_.authenticated = false; | |
| 150 } | |
| 151 } | |
| 152 | |
| 153 sync_api::SyncManager::Status AllStatus::status() const { | 143 sync_api::SyncManager::Status AllStatus::status() const { |
| 154 base::AutoLock lock(mutex_); | 144 base::AutoLock lock(mutex_); |
| 155 return status_; | 145 return status_; |
| 156 } | 146 } |
| 157 | 147 |
| 158 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) { | 148 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) { |
| 159 ScopedStatusLock lock(this); | 149 ScopedStatusLock lock(this); |
| 160 status_.notifications_enabled = notifications_enabled; | 150 status_.notifications_enabled = notifications_enabled; |
| 161 } | 151 } |
| 162 | 152 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 189 : allstatus_(allstatus) { | 179 : allstatus_(allstatus) { |
| 190 allstatus->mutex_.Acquire(); | 180 allstatus->mutex_.Acquire(); |
| 191 } | 181 } |
| 192 | 182 |
| 193 ScopedStatusLock::~ScopedStatusLock() { | 183 ScopedStatusLock::~ScopedStatusLock() { |
| 194 allstatus_->CalcStatusChanges(); | 184 allstatus_->CalcStatusChanges(); |
| 195 allstatus_->mutex_.Release(); | 185 allstatus_->mutex_.Release(); |
| 196 } | 186 } |
| 197 | 187 |
| 198 } // namespace browser_sync | 188 } // namespace browser_sync |
| OLD | NEW |