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 | 15 |
16 namespace browser_sync { | 16 namespace browser_sync { |
17 | 17 |
18 static const sync_api::SyncManager::Status init_status = | 18 static const sync_api::SyncManager::Status init_status = |
19 { sync_api::SyncManager::Status::OFFLINE }; | 19 { sync_api::SyncManager::Status::OFFLINE }; |
20 | 20 |
21 AllStatus::AllStatus() : status_(init_status) { | 21 AllStatus::AllStatus() : status_(init_status) { |
22 status_.initial_sync_ended = true; | 22 status_.initial_sync_ended = true; |
23 status_.notifications_enabled = false; | 23 status_.notifications_enabled = false; |
| 24 status_.cryptographer_ready = false; |
| 25 status_.encrypt_everything = false; |
24 } | 26 } |
25 | 27 |
26 AllStatus::~AllStatus() { | 28 AllStatus::~AllStatus() { |
27 } | 29 } |
28 | 30 |
29 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { | 31 sync_api::SyncManager::Status AllStatus::CreateBlankStatus() const { |
30 // Status is initialized with the previous status value. Variables | 32 // Status is initialized with the previous status value. Variables |
31 // whose values accumulate (e.g. lifetime counters like updates_received) | 33 // whose values accumulate (e.g. lifetime counters like updates_received) |
32 // are not to be cleared here. | 34 // are not to be cleared here. |
33 sync_api::SyncManager::Status status = status_; | 35 sync_api::SyncManager::Status status = status_; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void AllStatus::IncrementNotifiableCommits() { | 160 void AllStatus::IncrementNotifiableCommits() { |
159 ScopedStatusLock lock(this); | 161 ScopedStatusLock lock(this); |
160 ++status_.notifiable_commits; | 162 ++status_.notifiable_commits; |
161 } | 163 } |
162 | 164 |
163 void AllStatus::IncrementNotificationsReceived() { | 165 void AllStatus::IncrementNotificationsReceived() { |
164 ScopedStatusLock lock(this); | 166 ScopedStatusLock lock(this); |
165 ++status_.notifications_received; | 167 ++status_.notifications_received; |
166 } | 168 } |
167 | 169 |
| 170 void AllStatus::SetEncryptEverything(bool everything) { |
| 171 ScopedStatusLock lock(this); |
| 172 status_.encrypt_everything = everything; |
| 173 } |
| 174 |
| 175 void AllStatus::SetCryptographerReady(bool ready) { |
| 176 ScopedStatusLock lock(this); |
| 177 status_.cryptographer_ready = ready; |
| 178 } |
| 179 |
168 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) | 180 ScopedStatusLock::ScopedStatusLock(AllStatus* allstatus) |
169 : allstatus_(allstatus) { | 181 : allstatus_(allstatus) { |
170 allstatus->mutex_.Acquire(); | 182 allstatus->mutex_.Acquire(); |
171 } | 183 } |
172 | 184 |
173 ScopedStatusLock::~ScopedStatusLock() { | 185 ScopedStatusLock::~ScopedStatusLock() { |
174 allstatus_->CalcStatusChanges(); | 186 allstatus_->CalcStatusChanges(); |
175 allstatus_->mutex_.Release(); | 187 allstatus_->mutex_.Release(); |
176 } | 188 } |
177 | 189 |
178 } // namespace browser_sync | 190 } // namespace browser_sync |
OLD | NEW |