OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/integration/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/test/integration/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 <sstream> | 10 #include <sstream> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 std::string GetDebugMessage() const override { return "Backend Initialize"; } | 73 std::string GetDebugMessage() const override { return "Backend Initialize"; } |
74 }; | 74 }; |
75 | 75 |
76 class SyncSetupChecker : public SingleClientStatusChangeChecker { | 76 class SyncSetupChecker : public SingleClientStatusChangeChecker { |
77 public: | 77 public: |
78 explicit SyncSetupChecker(ProfileSyncService* service) | 78 explicit SyncSetupChecker(ProfileSyncService* service) |
79 : SingleClientStatusChangeChecker(service) {} | 79 : SingleClientStatusChangeChecker(service) {} |
80 | 80 |
81 bool IsExitConditionSatisfied() override { | 81 bool IsExitConditionSatisfied() override { |
82 if (!service()->SyncActive()) | 82 if (!service()->IsSyncActive()) |
83 return false; | 83 return false; |
84 if (service()->ConfigurationDone()) | 84 if (service()->ConfigurationDone()) |
85 return true; | 85 return true; |
86 // Sync is blocked because a custom passphrase is required. | 86 // Sync is blocked because a custom passphrase is required. |
87 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) | 87 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) |
88 return true; | 88 return true; |
89 // Sync is blocked by an auth error. | 89 // Sync is blocked by an auth error. |
90 if (HasAuthError(service())) | 90 if (HasAuthError(service())) |
91 return true; | 91 return true; |
92 // Still waiting on sync setup. | 92 // Still waiting on sync setup. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 !service()->HasSyncSetupCompleted(); | 306 !service()->HasSyncSetupCompleted(); |
307 } | 307 } |
308 | 308 |
309 void ProfileSyncServiceHarness::FinishSyncSetup() { | 309 void ProfileSyncServiceHarness::FinishSyncSetup() { |
310 service()->SetSetupInProgress(false); | 310 service()->SetSetupInProgress(false); |
311 service()->SetSyncSetupCompleted(); | 311 service()->SetSyncSetupCompleted(); |
312 } | 312 } |
313 | 313 |
314 SyncSessionSnapshot ProfileSyncServiceHarness::GetLastSessionSnapshot() const { | 314 SyncSessionSnapshot ProfileSyncServiceHarness::GetLastSessionSnapshot() const { |
315 DCHECK(service() != NULL) << "Sync service has not yet been set up."; | 315 DCHECK(service() != NULL) << "Sync service has not yet been set up."; |
316 if (service()->SyncActive()) { | 316 if (service()->IsSyncActive()) { |
317 return service()->GetLastSessionSnapshot(); | 317 return service()->GetLastSessionSnapshot(); |
318 } | 318 } |
319 return SyncSessionSnapshot(); | 319 return SyncSessionSnapshot(); |
320 } | 320 } |
321 | 321 |
322 bool ProfileSyncServiceHarness::EnableSyncForDatatype( | 322 bool ProfileSyncServiceHarness::EnableSyncForDatatype( |
323 syncer::ModelType datatype) { | 323 syncer::ModelType datatype) { |
324 DVLOG(1) << GetClientInfoString( | 324 DVLOG(1) << GetClientInfoString( |
325 "EnableSyncForDatatype(" | 325 "EnableSyncForDatatype(" |
326 + std::string(syncer::ModelTypeToString(datatype)) + ")"); | 326 + std::string(syncer::ModelTypeToString(datatype)) + ")"); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 std::string ProfileSyncServiceHarness::GetClientInfoString( | 429 std::string ProfileSyncServiceHarness::GetClientInfoString( |
430 const std::string& message) const { | 430 const std::string& message) const { |
431 std::stringstream os; | 431 std::stringstream os; |
432 os << profile_debug_name_ << ": " << message << ": "; | 432 os << profile_debug_name_ << ": " << message << ": "; |
433 if (service()) { | 433 if (service()) { |
434 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); | 434 const SyncSessionSnapshot& snap = GetLastSessionSnapshot(); |
435 ProfileSyncService::Status status; | 435 ProfileSyncService::Status status; |
436 service()->QueryDetailedSyncStatus(&status); | 436 service()->QueryDetailedSyncStatus(&status); |
437 // Capture select info from the sync session snapshot and syncer status. | 437 // Capture select info from the sync session snapshot and syncer status. |
438 os << ", has_unsynced_items: " | 438 os << ", has_unsynced_items: " |
439 << (service()->SyncActive() ? service()->HasUnsyncedItems() : 0) | 439 << (service()->IsSyncActive() ? service()->HasUnsyncedItems() : 0) |
440 << ", did_commit: " | 440 << ", did_commit: " |
441 << (snap.model_neutral_state().num_successful_commits == 0 && | 441 << (snap.model_neutral_state().num_successful_commits == 0 && |
442 snap.model_neutral_state().commit_result == syncer::SYNCER_OK) | 442 snap.model_neutral_state().commit_result == syncer::SYNCER_OK) |
443 << ", encryption conflicts: " | 443 << ", encryption conflicts: " |
444 << snap.num_encryption_conflicts() | 444 << snap.num_encryption_conflicts() |
445 << ", hierarchy conflicts: " | 445 << ", hierarchy conflicts: " |
446 << snap.num_hierarchy_conflicts() | 446 << snap.num_hierarchy_conflicts() |
447 << ", server conflicts: " | 447 << ", server conflicts: " |
448 << snap.num_server_conflicts() | 448 << snap.num_server_conflicts() |
449 << ", num_updates_downloaded : " | 449 << ", num_updates_downloaded : " |
450 << snap.model_neutral_state().num_updates_downloaded_total | 450 << snap.model_neutral_state().num_updates_downloaded_total |
451 << ", passphrase_required_reason: " | 451 << ", passphrase_required_reason: " |
452 << syncer::PassphraseRequiredReasonToString( | 452 << syncer::PassphraseRequiredReasonToString( |
453 service()->passphrase_required_reason()) | 453 service()->passphrase_required_reason()) |
454 << ", notifications_enabled: " | 454 << ", notifications_enabled: " |
455 << status.notifications_enabled | 455 << status.notifications_enabled |
456 << ", service_is_active: " | 456 << ", service_is_active: " |
457 << service()->SyncActive(); | 457 << service()->IsSyncActive(); |
458 } else { | 458 } else { |
459 os << "Sync service not available"; | 459 os << "Sync service not available"; |
460 } | 460 } |
461 return os.str(); | 461 return os.str(); |
462 } | 462 } |
463 | 463 |
464 bool ProfileSyncServiceHarness::IsTypePreferred(syncer::ModelType type) { | 464 bool ProfileSyncServiceHarness::IsTypePreferred(syncer::ModelType type) { |
465 return service()->GetPreferredDataTypes().Has(type); | 465 return service()->GetPreferredDataTypes().Has(type); |
466 } | 466 } |
467 | 467 |
468 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 468 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
469 scoped_ptr<base::DictionaryValue> value( | 469 scoped_ptr<base::DictionaryValue> value( |
470 sync_ui_util::ConstructAboutInformation(service())); | 470 sync_ui_util::ConstructAboutInformation(service())); |
471 std::string service_status; | 471 std::string service_status; |
472 base::JSONWriter::WriteWithOptions( | 472 base::JSONWriter::WriteWithOptions( |
473 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); | 473 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &service_status); |
474 return service_status; | 474 return service_status; |
475 } | 475 } |
OLD | NEW |