| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // An instance of this class is basically our notion of a "sync client" for | 25 // An instance of this class is basically our notion of a "sync client" for |
| 26 // automation purposes. It harnesses the ProfileSyncService member of the | 26 // automation purposes. It harnesses the ProfileSyncService member of the |
| 27 // profile passed to it on construction and automates certain things like setup | 27 // profile passed to it on construction and automates certain things like setup |
| 28 // and authentication. It provides ways to "wait" adequate periods of time for | 28 // and authentication. It provides ways to "wait" adequate periods of time for |
| 29 // several clients to get to the same state. | 29 // several clients to get to the same state. |
| 30 class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { | 30 class ProfileSyncServiceHarness : public ProfileSyncServiceObserver { |
| 31 public: | 31 public: |
| 32 ProfileSyncServiceHarness(Profile* profile, | 32 ProfileSyncServiceHarness(Profile* profile, |
| 33 const std::string& username, | 33 const std::string& username, |
| 34 const std::string& password, | 34 const std::string& password); |
| 35 int id); | |
| 36 | 35 |
| 37 virtual ~ProfileSyncServiceHarness() {} | 36 virtual ~ProfileSyncServiceHarness() {} |
| 38 | 37 |
| 39 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a | 38 // Creates a ProfileSyncServiceHarness object and attaches it to |profile|, a |
| 40 // profile that is assumed to have been signed into sync in the past. Caller | 39 // profile that is assumed to have been signed into sync in the past. Caller |
| 41 // takes ownership. | 40 // takes ownership. |
| 42 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile); | 41 static ProfileSyncServiceHarness* CreateAndAttach(Profile* profile); |
| 43 | 42 |
| 44 // Sets the GAIA credentials with which to sign in to sync. | 43 // Sets the GAIA credentials with which to sign in to sync. |
| 45 void SetCredentials(const std::string& username, const std::string& password); | 44 void SetCredentials(const std::string& username, const std::string& password); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, | 212 bool AwaitStatusChangeWithTimeout(int timeout_milliseconds, |
| 214 const std::string& reason); | 213 const std::string& reason); |
| 215 | 214 |
| 216 // Returns true if the sync client has no unsynced items. | 215 // Returns true if the sync client has no unsynced items. |
| 217 bool IsSynced(); | 216 bool IsSynced(); |
| 218 | 217 |
| 219 // Returns true if this client has downloaded all the items that the | 218 // Returns true if this client has downloaded all the items that the |
| 220 // other client has. | 219 // other client has. |
| 221 bool MatchesOtherClient(ProfileSyncServiceHarness* partner); | 220 bool MatchesOtherClient(ProfileSyncServiceHarness* partner); |
| 222 | 221 |
| 223 // Logs message with relevant info about client's sync state (if available). | 222 // Returns a string with relevant info about client's sync state (if |
| 224 // |log_level| denotes the VLOG level. | 223 // available). Useful for logging. |
| 225 void LogClientInfo(const std::string& message, int log_level); | 224 std::string GetClientInfo(); |
| 226 | 225 |
| 227 // Gets the current progress indicator of the current sync session | 226 // Gets the current progress indicator of the current sync session |
| 228 // for a particular datatype. | 227 // for a particular datatype. |
| 229 std::string GetUpdatedTimestamp(syncable::ModelType model_type); | 228 std::string GetUpdatedTimestamp(syncable::ModelType model_type); |
| 230 | 229 |
| 231 // Gets detailed status from |service_| in pretty-printable form. | 230 // Gets detailed status from |service_| in pretty-printable form. |
| 232 std::string GetServiceStatus(); | 231 std::string GetServiceStatus(); |
| 233 | 232 |
| 234 // When in WAITING_FOR_ENCRYPTION state, we check to see if this type is now | 233 // When in WAITING_FOR_ENCRYPTION state, we check to see if this type is now |
| 235 // encrypted to determine if we're done. | 234 // encrypted to determine if we're done. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 246 ProfileSyncService* service_; | 245 ProfileSyncService* service_; |
| 247 | 246 |
| 248 // The harness of the client whose update progress marker we're expecting | 247 // The harness of the client whose update progress marker we're expecting |
| 249 // eventually match. | 248 // eventually match. |
| 250 ProfileSyncServiceHarness* timestamp_match_partner_; | 249 ProfileSyncServiceHarness* timestamp_match_partner_; |
| 251 | 250 |
| 252 // Credentials used for GAIA authentication. | 251 // Credentials used for GAIA authentication. |
| 253 std::string username_; | 252 std::string username_; |
| 254 std::string password_; | 253 std::string password_; |
| 255 | 254 |
| 256 // Client ID, used for logging purposes. | 255 // Used for logging. |
| 257 int id_; | 256 const std::string profile_debug_name_; |
| 258 | 257 |
| 259 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); | 258 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceHarness); |
| 260 }; | 259 }; |
| 261 | 260 |
| 262 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ | 261 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_HARNESS_H_ |
| OLD | NEW |