| 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 // If the type whose encryption we are waiting for is now complete, there |
| 293 // is nothing to do. |
| 294 LogClientInfo("WAITING_FOR_ENCRYPTION"); |
| 295 if (IsTypeEncrypted(waiting_for_encryption_type_)) |
| 296 SignalStateCompleteWithNextState(FULLY_SYNCED); |
| 297 break; |
| 298 } |
| 291 default: | 299 default: |
| 292 // Invalid state during observer callback which may be triggered by other | 300 // Invalid state during observer callback which may be triggered by other |
| 293 // classes using the the UI message loop. Defer to their handling. | 301 // classes using the the UI message loop. Defer to their handling. |
| 294 break; | 302 break; |
| 295 } | 303 } |
| 296 return original_wait_state != wait_state_; | 304 return original_wait_state != wait_state_; |
| 297 } | 305 } |
| 298 | 306 |
| 299 void ProfileSyncServiceHarness::OnStateChanged() { | 307 void ProfileSyncServiceHarness::OnStateChanged() { |
| 300 RunStateChangeMachine(); | 308 RunStateChangeMachine(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); | 598 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); |
| 591 } else { | 599 } else { |
| 592 VLOG(1) << "Client " << id_ << ": " << message | 600 VLOG(1) << "Client " << id_ << ": " << message |
| 593 << ": Sync session snapshot not available."; | 601 << ": Sync session snapshot not available."; |
| 594 } | 602 } |
| 595 } else { | 603 } else { |
| 596 VLOG(1) << "Client " << id_ << ": " << message | 604 VLOG(1) << "Client " << id_ << ": " << message |
| 597 << ": Sync service not available."; | 605 << ": Sync service not available."; |
| 598 } | 606 } |
| 599 } | 607 } |
| 608 |
| 609 bool ProfileSyncServiceHarness::EnableEncryptionForType( |
| 610 syncable::ModelType type) { |
| 611 syncable::ModelTypeSet encrypted_types; |
| 612 service_->GetEncryptedDataTypes(&encrypted_types); |
| 613 encrypted_types.insert(type); |
| 614 service_->EncryptDataTypes(encrypted_types); |
| 615 |
| 616 // Wait some time to let the enryption finish. |
| 617 std::string reason = "Waiting for encryption."; |
| 618 wait_state_ = WAITING_FOR_ENCRYPTION; |
| 619 waiting_for_encryption_type_ = type; |
| 620 if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason)) { |
| 621 LOG(ERROR) << "Did not receive EncryptionComplete notification after" |
| 622 << kLiveSyncOperationTimeoutMs / 1000 |
| 623 << " seconds."; |
| 624 return false; |
| 625 } |
| 626 |
| 627 return IsTypeEncrypted(type); |
| 628 } |
| 629 |
| 630 bool ProfileSyncServiceHarness::IsTypeEncrypted(syncable::ModelType type) { |
| 631 syncable::ModelTypeSet encrypted_types; |
| 632 service_->GetEncryptedDataTypes(&encrypted_types); |
| 633 if (encrypted_types.count(type) == 0) { |
| 634 return false; |
| 635 } |
| 636 return true; |
| 637 } |
| OLD | NEW |