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

Unified Diff: chrome/browser/sync/api/sync_error.cc

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix compile 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 side-by-side diff with in-line comments
Download patch
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..e4d5a25f4ecf9e417c5a2b2df98fc22cf6476284
--- /dev/null
+++ b/chrome/browser/sync/api/sync_error.cc
@@ -0,0 +1,61 @@
+// 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"
+
+SyncError::SyncError() {
+}
+
+SyncError::SyncError(const tracked_objects::Location& location,
+ const std::string& message,
+ syncable::ModelType type)
+ : location_(new tracked_objects::Location(location)),
+ message_(message),
+ type_(type) {
+ print_log_error();
+}
+
+SyncError::SyncError(const SyncError& rhs) {
+ location_.reset(new tracked_objects::Location(rhs.location()));
+ message_ = rhs.message();
+ type_ = rhs.type();
+}
+
+void SyncError::Reset(const tracked_objects::Location& location,
+ const std::string& message,
+ syncable::ModelType type) {
+ location_.reset(new tracked_objects::Location(location));
+ message_ = message;
+ type_ = type;
+ print_log_error();
+}
+
+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 {
+ DCHECK(IsInitialized());
akalin 2011/07/21 23:03:53 should probably be a CHECK, too, for consistency
Nicolas Zea 2011/07/21 23:43:26 Done.
+ return message_;
+}
+
+const syncable::ModelType SyncError::type() const {
+ DCHECK(IsInitialized());
akalin 2011/07/21 23:03:53 here too
Nicolas Zea 2011/07/21 23:43:26 Done.
+ return type_;
+}
+
+void SyncError::print_log_error() const {
+ LAZY_STREAM(logging::LogMessage(location_->file_name(),
+ location_->line_number(),
+ ERROR).stream(),
akalin 2011/07/21 23:03:53 how does this work? I think you need to do loggin
Nicolas Zea 2011/07/21 23:43:26 ERROR is a macro from logging.h that turns into 0.
+ LOG_IS_ON(ERROR))
+ << syncable::ModelTypeToString(type_) << " Sync Error: " << message_;
+}

Powered by Google App Engine
This is Rietveld 408576698