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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 GoogleServiceAuthError::SERVICE_ERROR || | 47 GoogleServiceAuthError::SERVICE_ERROR || |
48 service->GetAuthError().state() == | 48 service->GetAuthError().state() == |
49 GoogleServiceAuthError::REQUEST_CANCELED; | 49 GoogleServiceAuthError::REQUEST_CANCELED; |
50 } | 50 } |
51 | 51 |
52 class BackendInitializeChecker : public SingleClientStatusChangeChecker { | 52 class BackendInitializeChecker : public SingleClientStatusChangeChecker { |
53 public: | 53 public: |
54 explicit BackendInitializeChecker(ProfileSyncService* service) | 54 explicit BackendInitializeChecker(ProfileSyncService* service) |
55 : SingleClientStatusChangeChecker(service) {} | 55 : SingleClientStatusChangeChecker(service) {} |
56 | 56 |
57 virtual bool IsExitConditionSatisfied() OVERRIDE { | 57 virtual bool IsExitConditionSatisfied() override { |
58 if (service()->backend_mode() != ProfileSyncService::SYNC) | 58 if (service()->backend_mode() != ProfileSyncService::SYNC) |
59 return false; | 59 return false; |
60 if (service()->backend_initialized()) | 60 if (service()->backend_initialized()) |
61 return true; | 61 return true; |
62 // Backend initialization is blocked by an auth error. | 62 // Backend initialization is blocked by an auth error. |
63 if (HasAuthError(service())) | 63 if (HasAuthError(service())) |
64 return true; | 64 return true; |
65 // Backend initialization is blocked by a failure to fetch Oauth2 tokens. | 65 // Backend initialization is blocked by a failure to fetch Oauth2 tokens. |
66 if (service()->IsRetryingAccessTokenFetchForTest()) | 66 if (service()->IsRetryingAccessTokenFetchForTest()) |
67 return true; | 67 return true; |
68 // Still waiting on backend initialization. | 68 // Still waiting on backend initialization. |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 virtual std::string GetDebugMessage() const OVERRIDE { | 72 virtual std::string GetDebugMessage() const override { |
73 return "Backend Initialize"; | 73 return "Backend Initialize"; |
74 } | 74 } |
75 }; | 75 }; |
76 | 76 |
77 class SyncSetupChecker : public SingleClientStatusChangeChecker { | 77 class SyncSetupChecker : public SingleClientStatusChangeChecker { |
78 public: | 78 public: |
79 explicit SyncSetupChecker(ProfileSyncService* service) | 79 explicit SyncSetupChecker(ProfileSyncService* service) |
80 : SingleClientStatusChangeChecker(service) {} | 80 : SingleClientStatusChangeChecker(service) {} |
81 | 81 |
82 virtual bool IsExitConditionSatisfied() OVERRIDE { | 82 virtual bool IsExitConditionSatisfied() override { |
83 if (!service()->SyncActive()) | 83 if (!service()->SyncActive()) |
84 return false; | 84 return false; |
85 if (service()->ConfigurationDone()) | 85 if (service()->ConfigurationDone()) |
86 return true; | 86 return true; |
87 // Sync is blocked because a custom passphrase is required. | 87 // Sync is blocked because a custom passphrase is required. |
88 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) | 88 if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) |
89 return true; | 89 return true; |
90 // Sync is blocked by an auth error. | 90 // Sync is blocked by an auth error. |
91 if (HasAuthError(service())) | 91 if (HasAuthError(service())) |
92 return true; | 92 return true; |
93 // Still waiting on sync setup. | 93 // Still waiting on sync setup. |
94 return false; | 94 return false; |
95 } | 95 } |
96 | 96 |
97 virtual std::string GetDebugMessage() const OVERRIDE { | 97 virtual std::string GetDebugMessage() const override { |
98 return "Sync Setup"; | 98 return "Sync Setup"; |
99 } | 99 } |
100 }; | 100 }; |
101 | 101 |
102 bool AwaitSyncSetupCompletion(ProfileSyncService* service) { | 102 bool AwaitSyncSetupCompletion(ProfileSyncService* service) { |
103 SyncSetupChecker checker(service); | 103 SyncSetupChecker checker(service); |
104 checker.Wait(); | 104 checker.Wait(); |
105 return !checker.TimedOut(); | 105 return !checker.TimedOut(); |
106 } | 106 } |
107 | 107 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 450 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
451 scoped_ptr<base::DictionaryValue> value( | 451 scoped_ptr<base::DictionaryValue> value( |
452 sync_ui_util::ConstructAboutInformation(service())); | 452 sync_ui_util::ConstructAboutInformation(service())); |
453 std::string service_status; | 453 std::string service_status; |
454 base::JSONWriter::WriteWithOptions(value.get(), | 454 base::JSONWriter::WriteWithOptions(value.get(), |
455 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 455 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
456 &service_status); | 456 &service_status); |
457 return service_status; | 457 return service_status; |
458 } | 458 } |
OLD | NEW |