• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_
7 
8 #include <string>
9 
10 #include "chrome/browser/sync/glue/data_type_manager.h"
11 
12 namespace browser_sync {
13 
14 // Class to keep track of data types that have encountered an error during sync.
15 class FailedDataTypesHandler {
16  public:
17   typedef std::map<syncer::ModelType, syncer::SyncError> TypeErrorMap;
18 
19   explicit FailedDataTypesHandler();
20   ~FailedDataTypesHandler();
21 
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);
25 
26   // Resets the current set of data type errors.
27   void Reset();
28 
29   // Resets the set of types with cryptographer errors.
30   void ResetCryptoErrors();
31 
32   // Resets those persistence errors that intersect with |purged_types|.
33   void ResetPersistenceErrorsFrom(syncer::ModelTypeSet purged_types);
34 
35   // Returns a list of all the errors this class has recorded.
36   TypeErrorMap GetAllErrors() const;
37 
38   // Returns all types with errors.
39   syncer::ModelTypeSet GetFailedTypes() const;
40 
41   // Returns the types that are failing due to startup or runtime errors.
42   syncer::ModelTypeSet GetFatalErrorTypes() const;
43 
44   // Returns the types that are failing due to cryptographer errors.
45   syncer::ModelTypeSet GetCryptoErrorTypes() const;
46 
47   // Returns the types that are failing due to persistence errors.
48   syncer::ModelTypeSet GetPersistenceErrorTypes() const;
49 
50  private:
51   // Returns true if there are any types with errors.
52   bool AnyFailedDataType() const;
53 
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_;
57 
58   // List of data types that failed due to the cryptographer not being ready.
59   TypeErrorMap crypto_errors_;
60 
61   // List of data type that failed because sync did not persist the newest
62   // version of their data.
63   TypeErrorMap persistence_errors_;
64 
65   DISALLOW_COPY_AND_ASSIGN(FailedDataTypesHandler);
66 };
67 
68 }  // namespace browser_sync
69 
70 #endif  // CHROME_BROWSER_SYNC_GLUE_FAILED_DATA_TYPES_HANDLER_H_
71