Chromium Code Reviews| Index: sync/api/sync_error.h |
| diff --git a/sync/api/sync_error.h b/sync/api/sync_error.h |
| index e9ca0f60825c0893cf63c86cf4a8a523762cb1c0..d2508b83eb41233f7b7743e9acd4faa965d853d7 100644 |
| --- a/sync/api/sync_error.h |
| +++ b/sync/api/sync_error.h |
| @@ -19,21 +19,41 @@ class Location; |
| namespace syncer { |
| // Sync errors are used for debug purposes and handled internally and/or |
| -// exposed through Chrome's "about:sync" internal page. They are considered |
| -// unrecoverable for the datatype creating them, and should only be used as |
| -// such. |
| +// exposed through Chrome's "about:sync" internal page. |
| // This class is copy-friendly and thread-safe. |
| class SYNC_EXPORT SyncError { |
| public: |
| + // Error types are used to distinguish general datatype errors (which result |
| + // in the datatype being disabled) from actionable sync errors (which might |
| + // have more complicated results). |
| + enum ErrorType { |
| + UNSET, // No error. |
| + UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered, and |
| + // sync should be disabled completely. |
| + DATATYPE_ERROR, // A datatype error was encountered, and the datatype |
| + // should be disabled. |
| + PERSISTENCE_ERROR, // A persistence error was detected, and the |
| + // datataype should be associated after a sync update. |
| + CRYPTO_ERROR, // A cryptographer error was detected, and the |
| + // datatype should be associated after it is resolved. |
| + }; |
| + |
| // Default constructor refers to "no error", and IsSet() will return false. |
| SyncError(); |
| - // Create a new Sync error triggered by datatype |type| with debug message |
| - // |message| from the specified location. IsSet() will return true. |
| - // Will print the new error to LOG(ERROR). |
| + // Create a new Sync datatype error triggered by |model_type| with debug |
| + // message |message| from the specified location. IsSet() will return true |
| + // afterward. Will print the new error to LOG(ERROR). |
| SyncError(const tracked_objects::Location& location, |
| const std::string& message, |
| - ModelType type); |
| + ModelType model_type); |
| + |
| + // Create a new Sync error of type |error_type| triggered by |model_type| |
|
haitaol1
2013/06/10 22:47:56
Why don't combine these two constructors?
Nicolas Zea
2013/06/20 18:31:33
This constructor autogenerates the message, to I t
haitaol1
2013/06/20 20:35:51
I'm not sure how useful the auto-generated message
Nicolas Zea
2013/07/01 21:46:21
Done.
|
| + // from the specified location. IsSet() will return true afterward. Will |
| + // create and print an error specific message to LOG(ERROR). |
| + SyncError(const tracked_objects::Location& location, |
| + ErrorType error_type, |
| + ModelType model_type); |
| // Copy and assign via deep copy. |
| SyncError(const SyncError& other); |
| @@ -41,8 +61,9 @@ class SYNC_EXPORT SyncError { |
| ~SyncError(); |
| - // Reset the current error to a new error. May be called irrespective of |
| - // whether IsSet() is true. After this is called, IsSet() will return true. |
| + // Reset the current error to a new datatype error. May be called |
| + // irrespective of whether IsSet() is true. After this is called, IsSet() |
| + // will return true. |
| // Will print the new error to LOG(ERROR). |
| void Reset(const tracked_objects::Location& location, |
| const std::string& message, |
| @@ -54,7 +75,8 @@ class SYNC_EXPORT SyncError { |
| // These must only be called if IsSet() is true. |
| const tracked_objects::Location& location() const; |
| const std::string& message() const; |
| - ModelType type() const; |
| + ModelType model_type() const; |
| + ErrorType error_type() const; |
| // Returns empty string is IsSet() is false. |
| std::string ToString() const; |
| @@ -70,7 +92,8 @@ class SYNC_EXPORT SyncError { |
| // is called, IsSet() will return true. |
| void Init(const tracked_objects::Location& location, |
| const std::string& message, |
| - ModelType type); |
| + ModelType model_type, |
| + ErrorType error_type); |
| // Reset the error to it's default (unset) values. |
| void Clear(); |
| @@ -78,7 +101,8 @@ class SYNC_EXPORT SyncError { |
| // scoped_ptr is necessary because Location objects aren't assignable. |
| scoped_ptr<tracked_objects::Location> location_; |
| std::string message_; |
| - ModelType type_; |
| + ModelType model_type_; |
| + ErrorType error_type_; |
| }; |
| // gmock printer helper. |