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 
7 #include <memory>
8 #include <string>
9 
10 #include "base/values.h"
11 #include "components/sync/base/model_type.h"
12 
13 namespace syncer {
14 
15 enum SyncProtocolErrorType {
16   // Success case.
17   SYNC_SUCCESS,
18 
19   // Birthday does not match that of the server.
20   NOT_MY_BIRTHDAY,
21 
22   // Server is busy. Try later.
23   THROTTLED,
24 
25   // Clear user data is being currently executed by the server.
26   CLEAR_PENDING,
27 
28   // Server cannot service the request now.
29   TRANSIENT_ERROR,
30 
31   // Indicates the datatypes have been migrated and the client should resync
32   // them to get the latest progress markers.
33   MIGRATION_DONE,
34 
35   // An administrator disabled sync for this domain.
36   DISABLED_BY_ADMIN,
37 
38   // Some of servers are busy. Try later with busy servers.
39   PARTIAL_FAILURE,
40 
41   // Returned when server detects that this client's data is obsolete. Client
42   // should reset local data and restart syncing.
43   CLIENT_DATA_OBSOLETE,
44 
45   // Returned when the server detects that the encryption state (Nigori,
46   // keystore keys) has been reset/overridden, which means the local
47   // Nigori-related state is obsolete and should be cleared.
48   ENCRYPTION_OBSOLETE,
49 
50   // The default value.
51   UNKNOWN_ERROR
52 };
53 
54 enum ClientAction {
55   // Upgrade the client to latest version.
56   UPGRADE_CLIENT,
57 
58   // Wipe this client of any sync data.
59   DISABLE_SYNC_ON_CLIENT,
60 
61   // Account is disabled by admin. Stop sync, clear prefs and show message on
62   // settings page that account is disabled.
63   STOP_SYNC_FOR_DISABLED_ACCOUNT,
64 
65   // Generated in response to CLIENT_DATA_OBSOLETE error. ProfileSyncService
66   // should stop sync engine, delete the data and restart sync engine.
67   RESET_LOCAL_SYNC_DATA,
68 
69   // The default. No action.
70   UNKNOWN_ACTION
71 };
72 
73 struct SyncProtocolError {
74   SyncProtocolErrorType error_type;
75   std::string error_description;
76   ClientAction action;
77   ModelTypeSet error_data_types;
78   SyncProtocolError();
79   SyncProtocolError(const SyncProtocolError& other);
80   ~SyncProtocolError();
81   std::unique_ptr<base::DictionaryValue> ToValue() const;
82 };
83 
84 const char* GetSyncErrorTypeString(SyncProtocolErrorType type);
85 const char* GetClientActionString(ClientAction action);
86 
87 }  // namespace syncer
88 
89 #endif  // COMPONENTS_SYNC_PROTOCOL_SYNC_PROTOCOL_ERROR_H_
90