Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/sync/profile_sync_service_harness.cc

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <iterator> 8 #include <iterator>
9 #include <ostream> 9 #include <ostream>
10 #include <set> 10 #include <set>
(...skipping 10 matching lines...) Expand all
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/message_loop.h" 22 #include "base/message_loop.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/signin/signin_manager.h" 24 #include "chrome/browser/signin/signin_manager.h"
25 #include "chrome/browser/sync/glue/data_type_controller.h" 25 #include "chrome/browser/sync/glue/data_type_controller.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h" 26 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/browser/sync/sync_ui_util.h" 27 #include "chrome/browser/sync/sync_ui_util.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
30 30
31 using csync::sessions::SyncSessionSnapshot; 31 using syncer::sessions::SyncSessionSnapshot;
32 32
33 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. 33 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed.
34 // The amount of time for which we wait for a live sync operation to complete. 34 // The amount of time for which we wait for a live sync operation to complete.
35 static const int kLiveSyncOperationTimeoutMs = 45000; 35 static const int kLiveSyncOperationTimeoutMs = 45000;
36 36
37 // The amount of time we wait for test cases that verify exponential backoff. 37 // The amount of time we wait for test cases that verify exponential backoff.
38 static const int kExponentialBackoffVerificationTimeoutMs = 60000; 38 static const int kExponentialBackoffVerificationTimeoutMs = 60000;
39 39
40 // Simple class to implement a timeout using PostDelayedTask. If it is not 40 // Simple class to implement a timeout using PostDelayedTask. If it is not
41 // aborted before picked up by a message queue, then it asserts with the message 41 // aborted before picked up by a message queue, then it asserts with the message
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 break; 279 break;
280 } 280 }
281 case WAITING_FOR_INITIAL_SYNC: { 281 case WAITING_FOR_INITIAL_SYNC: {
282 DVLOG(1) << GetClientInfoString("WAITING_FOR_INITIAL_SYNC"); 282 DVLOG(1) << GetClientInfoString("WAITING_FOR_INITIAL_SYNC");
283 if (IsFullySynced()) { 283 if (IsFullySynced()) {
284 // The first sync cycle is now complete. We can start running tests. 284 // The first sync cycle is now complete. We can start running tests.
285 SignalStateCompleteWithNextState(FULLY_SYNCED); 285 SignalStateCompleteWithNextState(FULLY_SYNCED);
286 break; 286 break;
287 } 287 }
288 if (service()->passphrase_required_reason() == 288 if (service()->passphrase_required_reason() ==
289 csync::REASON_DECRYPTION) { 289 syncer::REASON_DECRYPTION) {
290 // A passphrase is required for decryption and we don't have it. Do not 290 // A passphrase is required for decryption and we don't have it. Do not
291 // wait any more. 291 // wait any more.
292 SignalStateCompleteWithNextState(SET_PASSPHRASE_FAILED); 292 SignalStateCompleteWithNextState(SET_PASSPHRASE_FAILED);
293 break; 293 break;
294 } 294 }
295 break; 295 break;
296 } 296 }
297 case WAITING_FOR_FULL_SYNC: { 297 case WAITING_FOR_FULL_SYNC: {
298 DVLOG(1) << GetClientInfoString("WAITING_FOR_FULL_SYNC"); 298 DVLOG(1) << GetClientInfoString("WAITING_FOR_FULL_SYNC");
299 if (IsFullySynced()) { 299 if (IsFullySynced()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DVLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_FINISH"); 392 DVLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_FINISH");
393 if (!HasPendingBackendMigration()) { 393 if (!HasPendingBackendMigration()) {
394 // Done migrating. 394 // Done migrating.
395 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); 395 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING);
396 } 396 }
397 break; 397 break;
398 } 398 }
399 case WAITING_FOR_ACTIONABLE_ERROR: { 399 case WAITING_FOR_ACTIONABLE_ERROR: {
400 DVLOG(1) << GetClientInfoString("WAITING_FOR_ACTIONABLE_ERROR"); 400 DVLOG(1) << GetClientInfoString("WAITING_FOR_ACTIONABLE_ERROR");
401 ProfileSyncService::Status status = GetStatus(); 401 ProfileSyncService::Status status = GetStatus();
402 if (status.sync_protocol_error.action != csync::UNKNOWN_ACTION && 402 if (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION &&
403 service_->HasUnrecoverableError() == true) { 403 service_->HasUnrecoverableError() == true) {
404 // An actionable error has been detected. 404 // An actionable error has been detected.
405 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); 405 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING);
406 } 406 }
407 break; 407 break;
408 } 408 }
409 case SET_PASSPHRASE_FAILED: { 409 case SET_PASSPHRASE_FAILED: {
410 // A passphrase is required for decryption. There is nothing the sync 410 // A passphrase is required for decryption. There is nothing the sync
411 // client can do until SetDecryptionPassphrase() is called. 411 // client can do until SetDecryptionPassphrase() is called.
412 DVLOG(1) << GetClientInfoString("SET_PASSPHRASE_FAILED"); 412 DVLOG(1) << GetClientInfoString("SET_PASSPHRASE_FAILED");
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); 590 const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
591 retry_verifier_.Initialize(snap); 591 retry_verifier_.Initialize(snap);
592 wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION; 592 wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION;
593 AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs, 593 AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs,
594 "Verify Exponential backoff"); 594 "Verify Exponential backoff");
595 return (retry_verifier_.Succeeded()); 595 return (retry_verifier_.Succeeded());
596 } 596 }
597 597
598 bool ProfileSyncServiceHarness::AwaitActionableError() { 598 bool ProfileSyncServiceHarness::AwaitActionableError() {
599 ProfileSyncService::Status status = GetStatus(); 599 ProfileSyncService::Status status = GetStatus();
600 CHECK(status.sync_protocol_error.action == csync::UNKNOWN_ACTION); 600 CHECK(status.sync_protocol_error.action == syncer::UNKNOWN_ACTION);
601 wait_state_ = WAITING_FOR_ACTIONABLE_ERROR; 601 wait_state_ = WAITING_FOR_ACTIONABLE_ERROR;
602 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, 602 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs,
603 "Waiting for actionable error"); 603 "Waiting for actionable error");
604 status = GetStatus(); 604 status = GetStatus();
605 return (status.sync_protocol_error.action != csync::UNKNOWN_ACTION && 605 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION &&
606 service_->HasUnrecoverableError()); 606 service_->HasUnrecoverableError());
607 } 607 }
608 608
609 bool ProfileSyncServiceHarness::AwaitMigration( 609 bool ProfileSyncServiceHarness::AwaitMigration(
610 syncable::ModelTypeSet expected_migrated_types) { 610 syncable::ModelTypeSet expected_migrated_types) {
611 DVLOG(1) << GetClientInfoString("AwaitMigration"); 611 DVLOG(1) << GetClientInfoString("AwaitMigration");
612 DVLOG(1) << profile_debug_name_ << ": waiting until migration is done for " 612 DVLOG(1) << profile_debug_name_ << ": waiting until migration is done for "
613 << syncable::ModelTypeSetToString(expected_migrated_types); 613 << syncable::ModelTypeSetToString(expected_migrated_types);
614 while (true) { 614 while (true) {
615 bool migration_finished = migrated_types_.HasAll(expected_migrated_types); 615 bool migration_finished = migrated_types_.HasAll(expected_migrated_types);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 bool ProfileSyncServiceHarness::IsFullySynced() { 789 bool ProfileSyncServiceHarness::IsFullySynced() {
790 if (service() == NULL) { 790 if (service() == NULL) {
791 DVLOG(1) << GetClientInfoString("IsFullySynced: false"); 791 DVLOG(1) << GetClientInfoString("IsFullySynced: false");
792 return false; 792 return false;
793 } 793 }
794 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); 794 const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
795 // If we didn't try to commit anything in the previous cycle, there's a 795 // If we didn't try to commit anything in the previous cycle, there's a
796 // good chance that we're now fully up to date. 796 // good chance that we're now fully up to date.
797 bool is_fully_synced = 797 bool is_fully_synced =
798 snap.model_neutral_state().num_successful_commits == 0 798 snap.model_neutral_state().num_successful_commits == 0
799 && snap.model_neutral_state().commit_result == csync::SYNCER_OK 799 && snap.model_neutral_state().commit_result == syncer::SYNCER_OK
800 && IsDataSyncedImpl(snap); 800 && IsDataSyncedImpl(snap);
801 801
802 DVLOG(1) << GetClientInfoString( 802 DVLOG(1) << GetClientInfoString(
803 is_fully_synced ? "IsFullySynced: true" : "IsFullySynced: false"); 803 is_fully_synced ? "IsFullySynced: true" : "IsFullySynced: false");
804 return is_fully_synced; 804 return is_fully_synced;
805 } 805 }
806 806
807 bool ProfileSyncServiceHarness::HasPendingBackendMigration() { 807 bool ProfileSyncServiceHarness::HasPendingBackendMigration() {
808 browser_sync::BackendMigrator* migrator = 808 browser_sync::BackendMigrator* migrator =
809 service()->GetBackendMigratorForTest(); 809 service()->GetBackendMigratorForTest();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 if (service()) { 995 if (service()) {
996 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); 996 const SyncSessionSnapshot& snap = GetLastSessionSnapshot();
997 const ProfileSyncService::Status& status = GetStatus(); 997 const ProfileSyncService::Status& status = GetStatus();
998 // Capture select info from the sync session snapshot and syncer status. 998 // Capture select info from the sync session snapshot and syncer status.
999 os << "has_more_to_sync: " 999 os << "has_more_to_sync: "
1000 << snap.has_more_to_sync() 1000 << snap.has_more_to_sync()
1001 << ", has_unsynced_items: " 1001 << ", has_unsynced_items: "
1002 << (service()->sync_initialized() ? service()->HasUnsyncedItems() : 0) 1002 << (service()->sync_initialized() ? service()->HasUnsyncedItems() : 0)
1003 << ", did_commit: " 1003 << ", did_commit: "
1004 << (snap.model_neutral_state().num_successful_commits == 0 && 1004 << (snap.model_neutral_state().num_successful_commits == 0 &&
1005 snap.model_neutral_state().commit_result == csync::SYNCER_OK) 1005 snap.model_neutral_state().commit_result == syncer::SYNCER_OK)
1006 << ", encryption conflicts: " 1006 << ", encryption conflicts: "
1007 << snap.num_encryption_conflicts() 1007 << snap.num_encryption_conflicts()
1008 << ", hierarchy conflicts: " 1008 << ", hierarchy conflicts: "
1009 << snap.num_hierarchy_conflicts() 1009 << snap.num_hierarchy_conflicts()
1010 << ", simple conflicts: " 1010 << ", simple conflicts: "
1011 << snap.num_simple_conflicts() 1011 << snap.num_simple_conflicts()
1012 << ", server conflicts: " 1012 << ", server conflicts: "
1013 << snap.num_server_conflicts() 1013 << snap.num_server_conflicts()
1014 << ", num_updates_downloaded : " 1014 << ", num_updates_downloaded : "
1015 << snap.model_neutral_state().num_updates_downloaded_total 1015 << snap.model_neutral_state().num_updates_downloaded_total
1016 << ", passphrase_required_reason: " 1016 << ", passphrase_required_reason: "
1017 << csync::PassphraseRequiredReasonToString( 1017 << syncer::PassphraseRequiredReasonToString(
1018 service()->passphrase_required_reason()) 1018 service()->passphrase_required_reason())
1019 << ", notifications_enabled: " 1019 << ", notifications_enabled: "
1020 << status.notifications_enabled 1020 << status.notifications_enabled
1021 << ", service_is_pushing_changes: " 1021 << ", service_is_pushing_changes: "
1022 << ServiceIsPushingChanges() 1022 << ServiceIsPushingChanges()
1023 << ", has_pending_backend_migration: " 1023 << ", has_pending_backend_migration: "
1024 << HasPendingBackendMigration(); 1024 << HasPendingBackendMigration();
1025 } else { 1025 } else {
1026 os << "Sync service not available"; 1026 os << "Sync service not available";
1027 } 1027 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1108
1109 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1109 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1110 DictionaryValue value; 1110 DictionaryValue value;
1111 sync_ui_util::ConstructAboutInformation(service_, &value); 1111 sync_ui_util::ConstructAboutInformation(service_, &value);
1112 std::string service_status; 1112 std::string service_status;
1113 base::JSONWriter::WriteWithOptions(&value, 1113 base::JSONWriter::WriteWithOptions(&value,
1114 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1114 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1115 &service_status); 1115 &service_status);
1116 return service_status; 1116 return service_status;
1117 } 1117 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.h ('k') | chrome/browser/sync/profile_sync_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698