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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_
10 #include "chrome/browser/sync/glue/data_type_manager.h"
12 namespace browser_sync {
14 // Class to keep track of data types that have encountered an error during sync.
15 class FailedDataTypesHandler {
17 typedef std::map<syncer::ModelType, syncer::SyncError> TypeErrorMap;
19 explicit FailedDataTypesHandler();
20 ~FailedDataTypesHandler();
22 // Update the failed datatypes. Types will be added to their corresponding
23 // error map based on their |error_type()|.
24 bool UpdateFailedDataTypes(const TypeErrorMap& errors);
26 // Resets the current set of data type errors.
29 // Resets the set of types with cryptographer errors.
30 void ResetCryptoErrors();
32 // Resets those persistence errors that intersect with |purged_types|.
33 void ResetPersistenceErrorsFrom(syncer::ModelTypeSet purged_types);
35 // Returns a list of all the errors this class has recorded.
36 TypeErrorMap GetAllErrors() const;
38 // Returns all types with errors.
39 syncer::ModelTypeSet GetFailedTypes() const;
41 // Returns the types that are failing due to startup or runtime errors.
42 syncer::ModelTypeSet GetFatalErrorTypes() const;
44 // Returns the types that are failing due to cryptographer errors.
45 syncer::ModelTypeSet GetCryptoErrorTypes() const;
47 // Returns the types that are failing due to persistence errors.
48 syncer::ModelTypeSet GetPersistenceErrorTypes() const;
51 // Returns true if there are any types with errors.
52 bool AnyFailedDataType() const;
54 // List of data types that failed at startup due to association errors or
55 // runtime due to data type errors.
56 TypeErrorMap fatal_errors_;
58 // List of data types that failed due to the cryptographer not being ready.
59 TypeErrorMap crypto_errors_;
61 // List of data type that failed because sync did not persist the newest
62 // version of their data.
63 TypeErrorMap persistence_errors_;
65 DISALLOW_COPY_AND_ASSIGN(FailedDataTypesHandler);
68 } // namespace browser_sync
70 #endif // CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_