diff options
author | zea <zea@chromium.org> | 2014-08-28 13:39:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-28 20:40:23 +0000 |
commit | f9897b672e260fc23f50b6f35dab786450bd852d (patch) | |
tree | 59bc2c55e431f8739dd91a7cb3dc70161d4f4865 /components/sync_driver/data_type_status_table.h | |
parent | 56a2306889606b08d2adce13b466dffa541175db (diff) | |
download | chromium_src-f9897b672e260fc23f50b6f35dab786450bd852d.zip chromium_src-f9897b672e260fc23f50b6f35dab786450bd852d.tar.gz chromium_src-f9897b672e260fc23f50b6f35dab786450bd852d.tar.bz2 |
[Sync] Rename FailedDataTypesHandler -> DataTypeStatusTable
Simple rename patch, in preparation for making the DataTypeStatusTable
copy-able and having it track more than just errors.
BUG=368834
Review URL: https://codereview.chromium.org/513543004
Cr-Commit-Position: refs/heads/master@{#292453}
Diffstat (limited to 'components/sync_driver/data_type_status_table.h')
-rw-r--r-- | components/sync_driver/data_type_status_table.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/components/sync_driver/data_type_status_table.h b/components/sync_driver/data_type_status_table.h new file mode 100644 index 0000000..f3bb19a --- /dev/null +++ b/components/sync_driver/data_type_status_table.h @@ -0,0 +1,99 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ +#define COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ + +#include <string> + +#include "components/sync_driver/data_type_manager.h" + +namespace sync_driver { + +// Class to keep track of data types that have encountered an error during sync. +class DataTypeStatusTable { + public: + typedef std::map<syncer::ModelType, syncer::SyncError> TypeErrorMap; + + explicit DataTypeStatusTable(); + ~DataTypeStatusTable(); + + // Copy and assign welcome. + + // Update the failed datatypes. Types will be added to their corresponding + // error map based on their |error_type()|. + bool UpdateFailedDataTypes(const TypeErrorMap& errors); + + // Resets the current set of data type errors. + void Reset(); + + // Resets the set of types with cryptographer errors. + void ResetCryptoErrors(); + + // Resets those persistence errors that intersect with |purged_types|. + void ResetPersistenceErrorsFrom(syncer::ModelTypeSet purged_types); + + // Removes |type| from the data_type_errors_ set. Returns true if the type + // was removed from the error set, false if the type did not have a data type + // error to begin with. + bool ResetDataTypeErrorFor(syncer::ModelType type); + + // Removes |type| from the unread_errors_ set. Returns true if the type + // was removed from the error set, false if the type did not have an unready + // error to begin with. + bool ResetUnreadyErrorFor(syncer::ModelType type); + + // Returns a list of all the errors this class has recorded. + TypeErrorMap GetAllErrors() const; + + // Returns all types with failure errors. This includes, fatal, crypto, and + // unready types.` + syncer::ModelTypeSet GetFailedTypes() const; + + // Returns the types that are failing due to unrecoverable or datatype errors. + syncer::ModelTypeSet GetFatalErrorTypes() const; + + // Returns the types that are failing due to cryptographer errors. + syncer::ModelTypeSet GetCryptoErrorTypes() const; + + // Returns the types that are failing due to persistence errors. + syncer::ModelTypeSet GetPersistenceErrorTypes() const; + + // Returns the types that cannot be configured due to not being ready. + syncer::ModelTypeSet GetUnreadyErrorTypes() const; + + // Returns the types that triggered the unrecoverable error. + syncer::ModelTypeSet GetUnrecoverableErrorTypes() const; + + // Returns the current unrecoverable error, if there is one. + syncer::SyncError GetUnrecoverableError() const; + + private: + // Returns true if there are any types with errors. + bool AnyFailedDataType() const; + + // The current unrecoverable errors. Only one unrecoverable error can be + // active at a time, but it may apply to more than one type. + TypeErrorMap unrecoverable_errors_; + + // List of data types that failed due to runtime errors and should be + // disabled. These are different from unrecoverable_errors_ in that + // ResetDataTypeError can remove them from this list. + TypeErrorMap data_type_errors_; + + // List of data types that failed due to the cryptographer not being ready. + TypeErrorMap crypto_errors_; + + // List of data types that failed because sync did not persist the newest + // version of their data. + TypeErrorMap persistence_errors_; + + // List of data types that could not start due to not being ready. These can + // be marked as ready by calling ResetUnreadyErrorFor(..). + TypeErrorMap unready_errors_; +}; + +} // namespace sync_driver + +#endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_STATUS_TABLE_H_ |