Index: chrome/browser/sync/api/sync_error.cc |
diff --git a/chrome/browser/sync/api/sync_error.cc b/chrome/browser/sync/api/sync_error.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ed7ba69305c42d1c6bfeb823e158b6b57e56a26a |
--- /dev/null |
+++ b/chrome/browser/sync/api/sync_error.cc |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/sync/api/sync_error.h" |
+ |
+#include "base/logging.h" |
+#include "base/tracked.h" |
+ |
+SyncError::SyncError() { |
+} |
+ |
+SyncError::SyncError(const tracked_objects::Location& location, |
+ const std::string& message, |
+ syncable::ModelType type) |
+ : location_(new tracked_objects::Location(location)), |
akalin
2011/07/22 00:10:05
I think we can omit the initializer list and just
Nicolas Zea
2011/07/25 20:57:28
Done.
|
+ message_(message), |
+ type_(type) { |
+ PrintLogError(); |
+} |
+ |
+SyncError::SyncError(const SyncError& other) { |
+ *this = other; |
akalin
2011/07/22 00:10:05
Create a private member fn Copy(const SyncError&)
Nicolas Zea
2011/07/25 20:57:28
Done.
|
+} |
+ |
+SyncError& SyncError::operator=(const SyncError& other) { |
+ if (this == &other) { |
akalin
2011/07/22 00:10:05
Self-assignment should be legal for operator=. Ju
Nicolas Zea
2011/07/25 20:57:28
Done.
|
+ NOTREACHED(); |
+ return *this; |
+ } |
+ location_.reset(new tracked_objects::Location(other.location())); |
+ message_ = other.message(); |
+ type_ = other.type(); |
+ return *this; |
+} |
+ |
+void SyncError::Reset(const tracked_objects::Location& location, |
+ const std::string& message, |
+ syncable::ModelType type) { |
+ location_.reset(new tracked_objects::Location(location)); |
akalin
2011/07/22 00:10:05
decomp everything but the PrintLogError() into pri
Nicolas Zea
2011/07/25 20:57:28
Done.
|
+ message_ = message; |
+ type_ = type; |
+ PrintLogError(); |
+} |
+ |
+bool SyncError::IsInitialized() const { |
+ return location_.get() != NULL; |
+} |
+ |
+const tracked_objects::Location& SyncError::location() const { |
+ CHECK(IsInitialized()); |
+ return *location_; |
+} |
+ |
+const std::string& SyncError::message() const { |
+ CHECK(IsInitialized()); |
+ return message_; |
+} |
+ |
+const syncable::ModelType SyncError::type() const { |
+ CHECK(IsInitialized()); |
+ return type_; |
+} |
+ |
+void SyncError::PrintLogError() const { |
+ LAZY_STREAM(logging::LogMessage(location_->file_name(), |
+ location_->line_number(), |
+ logging::LOG_ERROR).stream(), |
+ LOG_IS_ON(ERROR)) |
+ << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; |
+} |