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

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

Issue 7461098: Reland 87645 with clang fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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() {
26 }
27
28 SyncError& SyncError::operator=(const SyncError& other) {
29 if (this == &other) {
30 return *this;
31 }
32 Copy(other);
33 return *this;
34 }
35
36 void SyncError::Copy(const SyncError& other) {
37 if (other.IsSet()) {
38 Init(other.location(),
39 other.message(),
40 other.type());
41 } else {
42 Clear();
43 }
44 }
45
46 void SyncError::Clear() {
47 location_.reset();
48 message_ = std::string();
49 type_ = syncable::UNSPECIFIED;
50 }
51
52 void SyncError::Reset(const tracked_objects::Location& location,
53 const std::string& message,
54 syncable::ModelType type) {
55 Init(location, message, type);
56 PrintLogError();
57 }
58
59 void SyncError::Init(const tracked_objects::Location& location,
60 const std::string& message,
61 syncable::ModelType type) {
62 location_.reset(new tracked_objects::Location(location));
63 message_ = message;
64 type_ = type;
65 }
66
67 bool SyncError::IsSet() const {
68 return location_.get() != NULL;
69 }
70
71 const tracked_objects::Location& SyncError::location() const {
72 CHECK(IsSet());
73 return *location_;
74 }
75
76 const std::string& SyncError::message() const {
77 CHECK(IsSet());
78 return message_;
79 }
80
81 syncable::ModelType SyncError::type() const {
82 CHECK(IsSet());
83 return type_;
84 }
85
86 void SyncError::PrintLogError() const {
87 LAZY_STREAM(logging::LogMessage(location_->file_name(),
88 location_->line_number(),
89 logging::LOG_ERROR).stream(),
90 LOG_IS_ON(ERROR))
91 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_;
92 }
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