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/tracked.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "chrome/browser/sync/syncable/model_type.h" | |
14 | |
15 // Sync errors are used for debug purposes and handled internally and/or | |
16 // exposed through Chrome's "about:sync" internal page. They are considered | |
17 // unrecoverable for the datatype creating them, and should only be used as | |
18 // such. | |
19 // This class is copy-friendly and thread-safe. | |
20 class SyncError { | |
21 public: | |
22 // Default constructor refers to "no error", and is_set() will return false. | |
23 SyncError(); | |
24 | |
25 // Create a new Sync error triggered by datatype |type| with debug message | |
26 // |message| from the specified location. | |
27 SyncError(const tracked_objects::Location& location, | |
28 const std::string& message, | |
29 syncable::ModelType type); | |
30 | |
31 // Copy-constructor. | |
32 SyncError(const SyncError& rhs); | |
33 | |
34 // Reset the error to a new error. | |
35 // May be called irrespective of whether is_set() is true. | |
36 void reset(const tracked_objects::Location& location, | |
akalin
2011/07/20 23:43:05
reset -> Reset
Nicolas Zea
2011/07/21 20:09:50
Done.
| |
37 const std::string& message, | |
38 syncable::ModelType type); | |
39 | |
40 // Whether this is a valid error or not. | |
41 bool is_set() const; | |
akalin
2011/07/20 23:43:05
is_set -> IsSet()
Consider IsInitialized()
Nicolas Zea
2011/07/21 20:09:50
Done.
| |
42 | |
43 // These must only be called if is_set() is true. | |
44 const tracked_objects::Location& location() const; | |
45 const std::string& message() const; | |
46 const syncable::ModelType type() const; | |
47 private: | |
48 void print_log_error() const; | |
49 | |
50 scoped_ptr<tracked_objects::Location> location_; | |
akalin
2011/07/20 23:43:05
Comment that you use a scoped_ptr because Location
Nicolas Zea
2011/07/21 20:09:50
Done.
| |
51 std::string message_; | |
52 syncable::ModelType type_; | |
53 }; | |
54 | |
55 #endif // CHROME_BROWSER_SYNC_API_SYNC_ERROR_H_ | |
OLD | NEW |