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

Side by Side Diff: chrome/browser/sync/api/sync_error.cc

Issue 7497014: Revert 94128 - [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/api/sync_error.h ('k') | chrome/browser/sync/api/sync_error_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "chrome/browser/sync/api/sync_error.h"
6
7 #include "base/logging.h"
8 #include "base/tracked.h"
9
10 SyncError::SyncError() {
11 Clear();
12 }
13
14 SyncError::SyncError(const tracked_objects::Location& location,
15 const std::string& message,
16 syncable::ModelType type) {
17 Init(location, message, type);
18 PrintLogError();
19 }
20
21 SyncError::SyncError(const SyncError& other) {
22 Copy(other);
23 }
24
25 SyncError& SyncError::operator=(const SyncError& other) {
26 if (this == &other) {
27 return *this;
28 }
29 Copy(other);
30 return *this;
31 }
32
33 void SyncError::Copy(const SyncError& other) {
34 if (other.IsSet()) {
35 Init(other.location(),
36 other.message(),
37 other.type());
38 } else {
39 Clear();
40 }
41 }
42
43 void SyncError::Clear() {
44 location_.reset();
45 message_ = std::string();
46 type_ = syncable::UNSPECIFIED;
47 }
48
49 void SyncError::Reset(const tracked_objects::Location& location,
50 const std::string& message,
51 syncable::ModelType type) {
52 Init(location, message, type);
53 PrintLogError();
54 }
55
56 void SyncError::Init(const tracked_objects::Location& location,
57 const std::string& message,
58 syncable::ModelType type) {
59 location_.reset(new tracked_objects::Location(location));
60 message_ = message;
61 type_ = type;
62 }
63
64 bool SyncError::IsSet() const {
65 return location_.get() != NULL;
66 }
67
68 const tracked_objects::Location& SyncError::location() const {
69 CHECK(IsSet());
70 return *location_;
71 }
72
73 const std::string& SyncError::message() const {
74 CHECK(IsSet());
75 return message_;
76 }
77
78 const syncable::ModelType SyncError::type() const {
79 CHECK(IsSet());
80 return type_;
81 }
82
83 void SyncError::PrintLogError() const {
84 LAZY_STREAM(logging::LogMessage(location_->file_name(),
85 location_->line_number(),
86 logging::LOG_ERROR).stream(),
87 LOG_IS_ON(ERROR))
88 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_;
89 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/api/sync_error.h ('k') | chrome/browser/sync/api/sync_error_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698