OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ |
6 #define COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "components/sync/api/sync_error.h" | 11 #include "components/sync/api/sync_error.h" |
12 #include "components/sync/base/model_type.h" | 12 #include "components/sync/base/model_type.h" |
13 | 13 |
14 namespace sync_driver { | 14 namespace syncer { |
15 | 15 |
16 // Class to keep track of data types that have encountered an error during sync. | 16 // Class to keep track of data types that have encountered an error during sync. |
17 class DataTypeStatusTable { | 17 class DataTypeStatusTable { |
18 public: | 18 public: |
19 typedef std::map<syncer::ModelType, syncer::SyncError> TypeErrorMap; | 19 typedef std::map<ModelType, SyncError> TypeErrorMap; |
20 | 20 |
21 DataTypeStatusTable(); | 21 DataTypeStatusTable(); |
22 DataTypeStatusTable(const DataTypeStatusTable& other); | 22 DataTypeStatusTable(const DataTypeStatusTable& other); |
23 ~DataTypeStatusTable(); | 23 ~DataTypeStatusTable(); |
24 | 24 |
25 // Copy and assign welcome. | 25 // Copy and assign welcome. |
26 | 26 |
27 // Update the failed datatypes. Types will be added to their corresponding | 27 // Update the failed datatypes. Types will be added to their corresponding |
28 // error map based on their |error_type()|. | 28 // error map based on their |error_type()|. |
29 void UpdateFailedDataTypes(const TypeErrorMap& errors); | 29 void UpdateFailedDataTypes(const TypeErrorMap& errors); |
30 | 30 |
31 // Resets the current set of data type errors. | 31 // Resets the current set of data type errors. |
32 void Reset(); | 32 void Reset(); |
33 | 33 |
34 // Resets the set of types with cryptographer errors. | 34 // Resets the set of types with cryptographer errors. |
35 void ResetCryptoErrors(); | 35 void ResetCryptoErrors(); |
36 | 36 |
37 // Resets those persistence errors that intersect with |purged_types|. | 37 // Resets those persistence errors that intersect with |purged_types|. |
38 void ResetPersistenceErrorsFrom(syncer::ModelTypeSet purged_types); | 38 void ResetPersistenceErrorsFrom(ModelTypeSet purged_types); |
39 | 39 |
40 // Removes |type| from the data_type_errors_ set. Returns true if the type | 40 // Removes |type| from the data_type_errors_ set. Returns true if the type |
41 // was removed from the error set, false if the type did not have a data type | 41 // was removed from the error set, false if the type did not have a data type |
42 // error to begin with. | 42 // error to begin with. |
43 bool ResetDataTypeErrorFor(syncer::ModelType type); | 43 bool ResetDataTypeErrorFor(ModelType type); |
44 | 44 |
45 // Removes |type| from the unread_errors_ set. Returns true if the type | 45 // Removes |type| from the unread_errors_ set. Returns true if the type |
46 // was removed from the error set, false if the type did not have an unready | 46 // was removed from the error set, false if the type did not have an unready |
47 // error to begin with. | 47 // error to begin with. |
48 bool ResetUnreadyErrorFor(syncer::ModelType type); | 48 bool ResetUnreadyErrorFor(ModelType type); |
49 | 49 |
50 // Returns a list of all the errors this class has recorded. | 50 // Returns a list of all the errors this class has recorded. |
51 TypeErrorMap GetAllErrors() const; | 51 TypeErrorMap GetAllErrors() const; |
52 | 52 |
53 // Returns all types with failure errors. This includes, fatal, crypto, and | 53 // Returns all types with failure errors. This includes, fatal, crypto, and |
54 // unready types.` | 54 // unready types.` |
55 syncer::ModelTypeSet GetFailedTypes() const; | 55 ModelTypeSet GetFailedTypes() const; |
56 | 56 |
57 // Returns the types that are failing due to unrecoverable or datatype errors. | 57 // Returns the types that are failing due to unrecoverable or datatype errors. |
58 syncer::ModelTypeSet GetFatalErrorTypes() const; | 58 ModelTypeSet GetFatalErrorTypes() const; |
59 | 59 |
60 // Returns the types that are failing due to cryptographer errors. | 60 // Returns the types that are failing due to cryptographer errors. |
61 syncer::ModelTypeSet GetCryptoErrorTypes() const; | 61 ModelTypeSet GetCryptoErrorTypes() const; |
62 | 62 |
63 // Returns the types that are failing due to persistence errors. | 63 // Returns the types that are failing due to persistence errors. |
64 syncer::ModelTypeSet GetPersistenceErrorTypes() const; | 64 ModelTypeSet GetPersistenceErrorTypes() const; |
65 | 65 |
66 // Returns the types that cannot be configured due to not being ready. | 66 // Returns the types that cannot be configured due to not being ready. |
67 syncer::ModelTypeSet GetUnreadyErrorTypes() const; | 67 ModelTypeSet GetUnreadyErrorTypes() const; |
68 | 68 |
69 // Returns the types that triggered the unrecoverable error. | 69 // Returns the types that triggered the unrecoverable error. |
70 syncer::ModelTypeSet GetUnrecoverableErrorTypes() const; | 70 ModelTypeSet GetUnrecoverableErrorTypes() const; |
71 | 71 |
72 // Returns the current unrecoverable error, if there is one. | 72 // Returns the current unrecoverable error, if there is one. |
73 syncer::SyncError GetUnrecoverableError() const; | 73 SyncError GetUnrecoverableError() const; |
74 | 74 |
75 private: | 75 private: |
76 // The current unrecoverable errors. Only one unrecoverable error can be | 76 // The current unrecoverable errors. Only one unrecoverable error can be |
77 // active at a time, but it may apply to more than one type. | 77 // active at a time, but it may apply to more than one type. |
78 TypeErrorMap unrecoverable_errors_; | 78 TypeErrorMap unrecoverable_errors_; |
79 | 79 |
80 // List of data types that failed due to runtime errors and should be | 80 // List of data types that failed due to runtime errors and should be |
81 // disabled. These are different from unrecoverable_errors_ in that | 81 // disabled. These are different from unrecoverable_errors_ in that |
82 // ResetDataTypeError can remove them from this list. | 82 // ResetDataTypeError can remove them from this list. |
83 TypeErrorMap data_type_errors_; | 83 TypeErrorMap data_type_errors_; |
84 | 84 |
85 // List of data types that failed due to the cryptographer not being ready. | 85 // List of data types that failed due to the cryptographer not being ready. |
86 TypeErrorMap crypto_errors_; | 86 TypeErrorMap crypto_errors_; |
87 | 87 |
88 // List of data types that failed because sync did not persist the newest | 88 // List of data types that failed because sync did not persist the newest |
89 // version of their data. | 89 // version of their data. |
90 TypeErrorMap persistence_errors_; | 90 TypeErrorMap persistence_errors_; |
91 | 91 |
92 // List of data types that could not start due to not being ready. These can | 92 // List of data types that could not start due to not being ready. These can |
93 // be marked as ready by calling ResetUnreadyErrorFor(..). | 93 // be marked as ready by calling ResetUnreadyErrorFor(..). |
94 TypeErrorMap unready_errors_; | 94 TypeErrorMap unready_errors_; |
95 }; | 95 }; |
96 | 96 |
97 } // namespace sync_driver | 97 } // namespace syncer |
98 | 98 |
99 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ | 99 #endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ |
OLD | NEW |