sync_protocol_error.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_PROTOCOL_SYNC_PROTOCOL_ERROR_H_
  5. #define COMPONENTS_SYNC_PROTOCOL_SYNC_PROTOCOL_ERROR_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/values.h"
  9. #include "components/sync/base/model_type.h"
  10. namespace syncer {
  11. enum SyncProtocolErrorType {
  12. // Success case.
  13. SYNC_SUCCESS,
  14. // Birthday does not match that of the server.
  15. NOT_MY_BIRTHDAY,
  16. // Server is busy. Try later.
  17. THROTTLED,
  18. // Clear user data is being currently executed by the server.
  19. CLEAR_PENDING,
  20. // Server cannot service the request now.
  21. TRANSIENT_ERROR,
  22. // Indicates the datatypes have been migrated and the client should resync
  23. // them to get the latest progress markers.
  24. MIGRATION_DONE,
  25. // An administrator disabled sync for this domain.
  26. DISABLED_BY_ADMIN,
  27. // Some of servers are busy. Try later with busy servers.
  28. PARTIAL_FAILURE,
  29. // Returned when server detects that this client's data is obsolete. Client
  30. // should reset local data and restart syncing.
  31. CLIENT_DATA_OBSOLETE,
  32. // Returned when the server detects that the encryption state (Nigori,
  33. // keystore keys) has been reset/overridden, which means the local
  34. // Nigori-related state is obsolete and should be cleared.
  35. ENCRYPTION_OBSOLETE,
  36. // The default value.
  37. UNKNOWN_ERROR
  38. };
  39. enum ClientAction {
  40. // Upgrade the client to latest version.
  41. UPGRADE_CLIENT,
  42. // Wipe this client of any sync data.
  43. DISABLE_SYNC_ON_CLIENT,
  44. // Account is disabled by admin. Stop sync, clear prefs and show message on
  45. // settings page that account is disabled.
  46. STOP_SYNC_FOR_DISABLED_ACCOUNT,
  47. // Generated in response to CLIENT_DATA_OBSOLETE error. SyncServiceImpl
  48. // should stop sync engine, delete the data and restart sync engine.
  49. RESET_LOCAL_SYNC_DATA,
  50. // The default. No action.
  51. UNKNOWN_ACTION
  52. };
  53. struct SyncProtocolError {
  54. SyncProtocolErrorType error_type;
  55. std::string error_description;
  56. ClientAction action;
  57. ModelTypeSet error_data_types;
  58. SyncProtocolError();
  59. SyncProtocolError(const SyncProtocolError& other);
  60. ~SyncProtocolError();
  61. std::unique_ptr<base::DictionaryValue> ToValue() const;
  62. };
  63. const char* GetSyncErrorTypeString(SyncProtocolErrorType type);
  64. const char* GetClientActionString(ClientAction action);
  65. } // namespace syncer
  66. #endif // COMPONENTS_SYNC_PROTOCOL_SYNC_PROTOCOL_ERROR_H_