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/engine/all_status.h" | 5 #include "chrome/browser/sync/engine/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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 ++status.useless_sync_cycles; | 89 ++status.useless_sync_cycles; |
90 } else { | 90 } else { |
91 ++status.useful_sync_cycles; | 91 ++status.useful_sync_cycles; |
92 } | 92 } |
93 } | 93 } |
94 return status; | 94 return status; |
95 } | 95 } |
96 | 96 |
97 void AllStatus::CalcStatusChanges() { | 97 void AllStatus::CalcStatusChanges() { |
98 const bool unsynced_changes = status_.unsynced_count > 0; | 98 const bool unsynced_changes = status_.unsynced_count > 0; |
99 const bool online = status_.authenticated && | 99 // TODO(rlarocque): AllStatus currently has no way to inquire about the |
100 status_.server_reachable && status_.server_up; | 100 // SyncScheduler's backoff state. We should fix that, then use it to update |
101 // the 'offline' state here. However, it's important to keep in mind that | |
102 // there really is no such thing as offline according to our SyncScheduler. | |
103 // The exponential backoff never gives up. | |
104 const bool online = true; | |
lipalani1
2012/02/22 18:28:50
This does not look right?
Basically only the firs
| |
101 if (online) { | 105 if (online) { |
102 if (status_.syncing) | 106 if (status_.syncing) |
103 status_.summary = sync_api::SyncManager::Status::SYNCING; | 107 status_.summary = sync_api::SyncManager::Status::SYNCING; |
104 else | 108 else |
105 status_.summary = sync_api::SyncManager::Status::READY; | 109 status_.summary = sync_api::SyncManager::Status::READY; |
106 } else if (!status_.initial_sync_ended) { | 110 } else if (!status_.initial_sync_ended) { |
107 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNUSABLE; | 111 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNUSABLE; |
108 } else if (unsynced_changes) { | 112 } else if (unsynced_changes) { |
109 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNSYNCED; | 113 status_.summary = sync_api::SyncManager::Status::OFFLINE_UNSYNCED; |
110 } else { | 114 } else { |
(...skipping 17 matching lines...) Expand all Loading... | |
128 case SyncEngineEvent::ACTIONABLE_ERROR: | 132 case SyncEngineEvent::ACTIONABLE_ERROR: |
129 status_ = CreateBlankStatus(); | 133 status_ = CreateBlankStatus(); |
130 status_.sync_protocol_error = event.snapshot->errors.sync_protocol_error; | 134 status_.sync_protocol_error = event.snapshot->errors.sync_protocol_error; |
131 break; | 135 break; |
132 default: | 136 default: |
133 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened; | 137 LOG(ERROR) << "Unrecognized Syncer Event: " << event.what_happened; |
134 break; | 138 break; |
135 } | 139 } |
136 } | 140 } |
137 | 141 |
138 void AllStatus::HandleServerConnectionEvent( | |
139 const ServerConnectionEvent& event) { | |
140 ScopedStatusLock lock(this); | |
141 status_.server_up = IsGoodReplyFromServer(event.connection_code); | |
142 status_.server_reachable = event.server_reachable; | |
143 | |
144 if (event.connection_code == HttpResponse::SERVER_CONNECTION_OK) { | |
145 status_.authenticated = true; | |
146 } else { | |
147 status_.authenticated = false; | |
148 } | |
149 } | |
150 | |
151 sync_api::SyncManager::Status AllStatus::status() const { | 142 sync_api::SyncManager::Status AllStatus::status() const { |
152 base::AutoLock lock(mutex_); | 143 base::AutoLock lock(mutex_); |
153 return status_; | 144 return status_; |
154 } | 145 } |
155 | 146 |
156 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) { | 147 void AllStatus::SetNotificationsEnabled(bool notifications_enabled) { |
157 ScopedStatusLock lock(this); | 148 ScopedStatusLock lock(this); |
158 status_.notifications_enabled = notifications_enabled; | 149 status_.notifications_enabled = notifications_enabled; |
159 } | 150 } |
160 | 151 |
(...skipping 26 matching lines...) Expand all Loading... | |
187 : allstatus_(allstatus) { | 178 : allstatus_(allstatus) { |
188 allstatus->mutex_.Acquire(); | 179 allstatus->mutex_.Acquire(); |
189 } | 180 } |
190 | 181 |
191 ScopedStatusLock::~ScopedStatusLock() { | 182 ScopedStatusLock::~ScopedStatusLock() { |
192 allstatus_->CalcStatusChanges(); | 183 allstatus_->CalcStatusChanges(); |
193 allstatus_->mutex_.Release(); | 184 allstatus_->mutex_.Release(); |
194 } | 185 } |
195 | 186 |
196 } // namespace browser_sync | 187 } // namespace browser_sync |
OLD | NEW |