OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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_API_SYNC_ERROR_H_ | |
6 #define CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chrome/browser/sync/syncable/model_type.h" | |
13 | |
14 namespace tracked_objects { | |
15 class Location; | |
16 } | |
akalin
2011/07/22 00:10:05
} // namespace tracked_objects
Nicolas Zea
2011/07/25 20:57:28
Done.
| |
17 | |
18 // Sync errors are used for debug purposes and handled internally and/or | |
19 // exposed through Chrome's "about:sync" internal page. They are considered | |
20 // unrecoverable for the datatype creating them, and should only be used as | |
21 // such. | |
22 // This class is copy-friendly and thread-safe. | |
23 class SyncError { | |
24 public: | |
25 // Default constructor refers to "no error", and IsInitialized() will return | |
akalin
2011/07/22 00:10:05
I wonder if it would be better to have all the fun
Nicolas Zea
2011/07/25 20:57:28
Yeah, I like that better. Done.
| |
26 // false. | |
27 SyncError(); | |
28 | |
29 // Create a new Sync error triggered by datatype |type| with debug message | |
30 // |message| from the specified location. | |
31 SyncError(const tracked_objects::Location& location, | |
32 const std::string& message, | |
33 syncable::ModelType type); | |
34 | |
35 // Copy and assign via deep copy. | |
36 SyncError(const SyncError& other); | |
37 SyncError& operator=(const SyncError& other); | |
38 | |
39 // Reset the error to a new error. | |
40 // May be called irrespective of whether is_set() is true. | |
akalin
2011/07/22 00:10:05
is_set -> IsInitialized()
Nicolas Zea
2011/07/25 20:57:28
Done.
| |
41 void Reset(const tracked_objects::Location& location, | |
42 const std::string& message, | |
43 syncable::ModelType type); | |
44 | |
45 // Whether this is a valid error or not. | |
46 bool IsInitialized() const; | |
47 | |
48 // These must only be called if is_set() is true. | |
49 const tracked_objects::Location& location() const; | |
50 const std::string& message() const; | |
51 const syncable::ModelType type() const; | |
52 | |
53 private: | |
54 // Print error information to log. | |
55 void PrintLogError() const; | |
56 | |
57 // Scoped_ptr is necessary because Location objects aren't assignable. | |
akalin
2011/07/22 00:10:05
Scoped -> scoped
Nicolas Zea
2011/07/25 20:57:28
Done.
| |
58 scoped_ptr<tracked_objects::Location> location_; | |
59 std::string message_; | |
60 syncable::ModelType type_; | |
61 }; | |
62 | |
63 #endif // CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_ | |
OLD | NEW |