Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: sync/api/sync_error.h

Issue 388003002: Sync: Display non-severe errors on about:sync in gray color rather than red. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 SYNC_API_SYNC_ERROR_H_ 5 #ifndef SYNC_API_SYNC_ERROR_H_
6 #define SYNC_API_SYNC_ERROR_H_ 6 #define SYNC_API_SYNC_ERROR_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 10
11 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "sync/base/sync_export.h" 13 #include "sync/base/sync_export.h"
13 #include "sync/internal_api/public/base/model_type.h" 14 #include "sync/internal_api/public/base/model_type.h"
14 15
15 namespace tracked_objects { 16 namespace tracked_objects {
16 class Location; 17 class Location;
17 } // namespace tracked_objects 18 } // namespace tracked_objects
18 19
19 namespace syncer { 20 namespace syncer {
20 21
(...skipping 10 matching lines...) Expand all
31 UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered, and 32 UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered, and
32 // sync should be disabled and purged completely. 33 // sync should be disabled and purged completely.
33 DATATYPE_ERROR, // A datatype error was encountered, and the datatype 34 DATATYPE_ERROR, // A datatype error was encountered, and the datatype
34 // should be disabled and purged completely. Note that 35 // should be disabled and purged completely. Note that
35 // datatype errors may be reset, triggering a 36 // datatype errors may be reset, triggering a
36 // re-enable. 37 // re-enable.
37 PERSISTENCE_ERROR, // A persistence error was detected, and the 38 PERSISTENCE_ERROR, // A persistence error was detected, and the
38 // datataype should be associated after a sync update. 39 // datataype should be associated after a sync update.
39 CRYPTO_ERROR, // A cryptographer error was detected, and the 40 CRYPTO_ERROR, // A cryptographer error was detected, and the
40 // datatype should be associated after it is resolved. 41 // datatype should be associated after it is resolved.
41 UNREADY_ERROR, // The type is not ready to start yet, so should be 42 UNREADY_ERROR, // A datatype is not ready to start yet, so should be
42 // neither purged nor enabled until it is ready. 43 // neither purged nor enabled until it is ready.
44 DATATYPE_POLICY_ERROR // A datatype should be disabled and purged due
45 // to configuration constraints.
43 }; 46 };
44 47
45 // Default constructor refers to "no error", and IsSet() will return false. 48 // Default constructor refers to "no error", and IsSet() will return false.
46 SyncError(); 49 SyncError();
47 50
48 // Create a new Sync error of type |error_type| triggered by |model_type| 51 // Create a new Sync error of type |error_type| triggered by |model_type|
49 // from the specified location. IsSet() will return true afterward. Will 52 // from the specified location. IsSet() will return true afterward. Will
50 // create and print an error specific message to LOG(ERROR). 53 // create and print an error specific message to LOG(ERROR).
51 SyncError(const tracked_objects::Location& location, 54 SyncError(const tracked_objects::Location& location,
52 ErrorType error_type, 55 ErrorType error_type,
(...skipping 15 matching lines...) Expand all
68 ModelType type); 71 ModelType type);
69 72
70 // Whether this is a valid error or not. 73 // Whether this is a valid error or not.
71 bool IsSet() const; 74 bool IsSet() const;
72 75
73 // These must only be called if IsSet() is true. 76 // These must only be called if IsSet() is true.
74 const tracked_objects::Location& location() const; 77 const tracked_objects::Location& location() const;
75 const std::string& message() const; 78 const std::string& message() const;
76 ModelType model_type() const; 79 ModelType model_type() const;
77 ErrorType error_type() const; 80 ErrorType error_type() const;
81 // Error severity for logging and UI purposes.
82 logging::LogSeverity severity() const;
83 // Type specific message prefix.
84 std::string type_message_prefix() const;
78 85
79 // Returns empty string is IsSet() is false. 86 // Returns empty string is IsSet() is false.
80 std::string ToString() const; 87 std::string ToString() const;
81 private: 88 private:
82 // Print error information to log. 89 // Print error information to log.
83 void PrintLogError() const; 90 void PrintLogError() const;
84 91
85 // Make a copy of a SyncError. If other.IsSet() == false, this->IsSet() will 92 // Make a copy of a SyncError. If other.IsSet() == false, this->IsSet() will
86 // now return false. 93 // now return false.
87 void Copy(const SyncError& other); 94 void Copy(const SyncError& other);
88 95
89 // Initialize the local error data with the specified error data. After this 96 // Initialize the local error data with the specified error data. After this
90 // is called, IsSet() will return true. 97 // is called, IsSet() will return true.
91 void Init(const tracked_objects::Location& location, 98 void Init(const tracked_objects::Location& location,
92 const std::string& message, 99 const std::string& message,
93 ModelType model_type, 100 ModelType model_type,
94 ErrorType error_type); 101 ErrorType error_type);
95 102
96 // Reset the error to it's default (unset) values. 103 // Reset the error to it's default (unset) values.
97 void Clear(); 104 void Clear();
98 105
106
Nicolas Zea 2014/07/14 17:36:02 nit: remove extra newline
stanisc 2014/07/15 16:10:01 Done.
99 // scoped_ptr is necessary because Location objects aren't assignable. 107 // scoped_ptr is necessary because Location objects aren't assignable.
100 scoped_ptr<tracked_objects::Location> location_; 108 scoped_ptr<tracked_objects::Location> location_;
101 std::string message_; 109 std::string message_;
102 ModelType model_type_; 110 ModelType model_type_;
103 ErrorType error_type_; 111 ErrorType error_type_;
104 }; 112 };
105 113
106 // gmock printer helper. 114 // gmock printer helper.
107 SYNC_EXPORT void PrintTo(const SyncError& sync_error, std::ostream* os); 115 SYNC_EXPORT void PrintTo(const SyncError& sync_error, std::ostream* os);
108 116
109 } // namespace syncer 117 } // namespace syncer
110 118
111 #endif // SYNC_API_SYNC_ERROR_H_ 119 #endif // SYNC_API_SYNC_ERROR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698