OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 case FULLY_SYNCED: { | 281 case FULLY_SYNCED: { |
282 // The client is online and fully synced. There is nothing to do. | 282 // The client is online and fully synced. There is nothing to do. |
283 LogClientInfo("FULLY_SYNCED"); | 283 LogClientInfo("FULLY_SYNCED"); |
284 break; | 284 break; |
285 } | 285 } |
286 case SYNC_DISABLED: { | 286 case SYNC_DISABLED: { |
287 // Syncing is disabled for the client. There is nothing to do. | 287 // Syncing is disabled for the client. There is nothing to do. |
288 LogClientInfo("SYNC_DISABLED"); | 288 LogClientInfo("SYNC_DISABLED"); |
289 break; | 289 break; |
290 } | 290 } |
291 case WAITING_FOR_ENCRYPTION: { | |
292 // Sync has finished encrypting the datatypes. There is nothing to do. | |
Raghu Simha
2011/02/14 05:29:52
This seems wrong. Just because you're in RunStateC
Nicolas Zea
2011/02/14 21:18:41
Done.
| |
293 LogClientInfo("WAITING_FOR_ENCRYPTION"); | |
294 SignalStateCompleteWithNextState(FULLY_SYNCED); | |
295 break; | |
296 } | |
291 default: | 297 default: |
292 // Invalid state during observer callback which may be triggered by other | 298 // Invalid state during observer callback which may be triggered by other |
293 // classes using the the UI message loop. Defer to their handling. | 299 // classes using the the UI message loop. Defer to their handling. |
294 break; | 300 break; |
295 } | 301 } |
296 return original_wait_state != wait_state_; | 302 return original_wait_state != wait_state_; |
297 } | 303 } |
298 | 304 |
299 void ProfileSyncServiceHarness::OnStateChanged() { | 305 void ProfileSyncServiceHarness::OnStateChanged() { |
300 RunStateChangeMachine(); | 306 RunStateChangeMachine(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); | 596 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); |
591 } else { | 597 } else { |
592 VLOG(1) << "Client " << id_ << ": " << message | 598 VLOG(1) << "Client " << id_ << ": " << message |
593 << ": Sync session snapshot not available."; | 599 << ": Sync session snapshot not available."; |
594 } | 600 } |
595 } else { | 601 } else { |
596 VLOG(1) << "Client " << id_ << ": " << message | 602 VLOG(1) << "Client " << id_ << ": " << message |
597 << ": Sync service not available."; | 603 << ": Sync service not available."; |
598 } | 604 } |
599 } | 605 } |
606 | |
607 bool ProfileSyncServiceHarness::EnableEncryptionForType( | |
608 syncable::ModelType type) { | |
609 syncable::ModelTypeSet encrypted_types; | |
610 service_->GetEncryptedDataTypes(&encrypted_types); | |
611 encrypted_types.insert(type); | |
612 service_->EncryptDataTypes(encrypted_types); | |
613 | |
614 // Wait some time to let the enryption finish. | |
615 std::string reason = "Waiting for encryption."; | |
616 wait_state_ = WAITING_FOR_ENCRYPTION; | |
617 if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason)) { | |
618 LOG(ERROR) << "Did not receive EncryptionComplete notification after" | |
619 << kLiveSyncOperationTimeoutMs / 1000 | |
620 << " seconds."; | |
621 return false; | |
622 } | |
623 | |
624 syncable::ModelTypeSet newly_encrypted_types; | |
625 service_->GetEncryptedDataTypes(&newly_encrypted_types); | |
626 if (newly_encrypted_types != encrypted_types) { | |
627 return false; | |
628 } | |
Raghu Simha
2011/02/14 05:29:52
The above block seems to be doing the same as IsTy
Nicolas Zea
2011/02/14 21:18:41
Done.
| |
629 | |
630 return true; | |
631 } | |
632 | |
633 bool ProfileSyncServiceHarness::IsTypeEncrypted(syncable::ModelType type) { | |
634 syncable::ModelTypeSet encrypted_types; | |
635 service_->GetEncryptedDataTypes(&encrypted_types); | |
636 if (encrypted_types.count(type) == 0) { | |
637 return false; | |
638 } | |
639 return true; | |
640 } | |
OLD | NEW |