Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 11 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 12 #include "chrome/browser/sync/protocol/service_constants.h" | 12 #include "chrome/browser/sync/protocol/service_constants.h" |
| 13 #include "chrome/browser/sync/sessions/session_state.h" | 13 #include "chrome/browser/sync/sessions/session_state.h" |
| 14 #include "chrome/browser/sync/syncable/directory_manager.h" | 14 #include "chrome/browser/sync/syncable/directory_manager.h" |
| 15 #include "chrome/browser/sync/syncable/model_type.h" | |
| 15 | 16 |
| 16 namespace browser_sync { | 17 namespace browser_sync { |
| 17 | 18 |
| 18 static const sync_api::SyncManager::Status init_status = | 19 AllStatus::AllStatus() { |
| 19 { sync_api::SyncManager::Status::OFFLINE }; | 20 status_.summary = sync_api::SyncManager::Status::OFFLINE; |
| 20 | |
| 21 AllStatus::AllStatus() : status_(init_status) { | |
| 22 status_.initial_sync_ended = true; | 21 status_.initial_sync_ended = true; |
| 23 status_.notifications_enabled = false; | 22 status_.notifications_enabled = false; |
| 23 status_.cryptographer_ready = false; | |
|
akalin
2011/08/04 01:14:48
crypto has pending keys?
Nicolas Zea
2011/08/04 01:27:52
Done.
| |
| 24 } | 24 } |
| 25 | 25 |
| 26 AllStatus::~AllStatus() { | 26 AllStatus::~AllStatus() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { | 29 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { |
| 30 // Status is initialized with the previous status value. Variables | 30 // Status is initialized with the previous status value. Variables |
| 31 // whose values accumulate (e.g. lifetime counters like updates_received) | 31 // whose values accumulate (e.g. lifetime counters like updates_received) |
| 32 // are not to be cleared here. | 32 // are not to be cleared here. |
| 33 sync_api::SyncManager::Status status = status_; | 33 sync_api::SyncManager::Status status = status_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 void AllStatus::IncrementNotifiableCommits() { | 158 void AllStatus::IncrementNotifiableCommits() { |
| 159 ScopedStatusLock lock(this); | 159 ScopedStatusLock lock(this); |
| 160 ++status_.notifiable_commits; | 160 ++status_.notifiable_commits; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void AllStatus::IncrementNotificationsReceived() { | 163 void AllStatus::IncrementNotificationsReceived() { |
| 164 ScopedStatusLock lock(this); | 164 ScopedStatusLock lock(this); |
| 165 ++status_.notifications_received; | 165 ++status_.notifications_received; |
| 166 } | 166 } |
| 167 | 167 |
| 168 void AllStatus::SetEncryptedTypes(const syncable::ModelTypeSet& types) { | |
| 169 std::string encrypted_types = syncable::ModelTypeSetToString(types); | |
| 170 ScopedStatusLock lock(this); | |
| 171 status_.encrypted_types = encrypted_types; | |
| 172 } | |
| 173 | |
| 174 void AllStatus::SetCryptographerReady(bool ready) { | |
| 175 ScopedStatusLock lock(this); | |
| 176 status_.cryptographer_ready = ready; | |
| 177 } | |
| 178 | |
| 179 void AllStatus::SetCryptoHasPendingKeys(bool has_pending_keys) { | |
| 180 ScopedStatusLock lock(this); | |
| 181 status_.crypto_has_pending_keys = has_pending_keys; | |
| 182 } | |
| 183 | |
| 168 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) | 184 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) |
| 169 : allstatus_(allstatus) { | 185 : allstatus_(allstatus) { |
| 170 allstatus->mutex_.Acquire(); | 186 allstatus->mutex_.Acquire(); |
| 171 } | 187 } |
| 172 | 188 |
| 173 ScopedStatusLock::~ScopedStatusLock() { | 189 ScopedStatusLock::~ScopedStatusLock() { |
| 174 allstatus_->CalcStatusChanges(); | 190 allstatus_->CalcStatusChanges(); |
| 175 allstatus_->mutex_.Release(); | 191 allstatus_->mutex_.Release(); |
| 176 } | 192 } |
| 177 | 193 |
| 178 } // namespace browser_sync | 194 } // namespace browser_sync |
| OLD | NEW |