| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_MODEL_MODEL_ERROR_H_ | 5 #ifndef COMPONENTS_SYNC_MODEL_MODEL_ERROR_H_ |
| 6 #define COMPONENTS_SYNC_MODEL_MODEL_ERROR_H_ | 6 #define COMPONENTS_SYNC_MODEL_MODEL_ERROR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 namespace syncer { |
| 14 | 14 |
| 15 // A minimal error object for use by USS model type code. | 15 // A minimal error object for use by USS model type code. |
| 16 class ModelError { | 16 class ModelError { |
| 17 public: | 17 public: |
| 18 // Creates an un-set error object (indicating an operation was successful). | |
| 19 ModelError(); | |
| 20 | |
| 21 // Creates a set error object with the given location and message. | 18 // Creates a set error object with the given location and message. |
| 22 ModelError(const tracked_objects::Location& location, | 19 ModelError(const tracked_objects::Location& location, |
| 23 const std::string& message); | 20 const std::string& message); |
| 24 | 21 |
| 25 ~ModelError(); | 22 ~ModelError(); |
| 26 | 23 |
| 27 // Whether this object represents an actual error. | |
| 28 bool IsSet() const; | |
| 29 | |
| 30 // The location of the error this object represents. Can only be called if the | 24 // The location of the error this object represents. Can only be called if the |
| 31 // error is set. | 25 // error is set. |
| 32 const tracked_objects::Location& location() const; | 26 const tracked_objects::Location& location() const; |
| 33 | 27 |
| 34 // The message explaining the error this object represents. Can only be called | 28 // The message explaining the error this object represents. Can only be called |
| 35 // if the error is set. | 29 // if the error is set. |
| 36 const std::string& message() const; | 30 const std::string& message() const; |
| 37 | 31 |
| 38 private: | 32 private: |
| 39 bool is_set_; | |
| 40 tracked_objects::Location location_; | 33 tracked_objects::Location location_; |
| 41 std::string message_; | 34 std::string message_; |
| 42 }; | 35 }; |
| 43 | 36 |
| 44 // Typedef for a simple error handler callback. | 37 // Typedef for a simple error handler callback. |
| 45 using ModelErrorHandler = base::RepeatingCallback<void(const ModelError&)>; | 38 using ModelErrorHandler = base::RepeatingCallback<void(const ModelError&)>; |
| 46 | 39 |
| 47 } // namespace syncer | 40 } // namespace syncer |
| 48 | 41 |
| 49 #endif // COMPONENTS_SYNC_MODEL_MODEL_ERROR_H_ | 42 #endif // COMPONENTS_SYNC_MODEL_MODEL_ERROR_H_ |
| OLD | NEW |