Chromium Code Reviews| 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..ce5c2a631f651a7b77a647607c54089d8e95d4b0 |
| --- /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(); |
| + print_log_error(); |
|
akalin
2011/07/20 23:43:05
Hmm so an error message will be logged every time
Nicolas Zea
2011/07/21 20:09:50
Done.
|
| +} |
| + |
| +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::is_set() const { |
| + return (bool)location_.get(); |
|
akalin
2011/07/20 23:43:05
i think this will still trigger a warning on Win.
Nicolas Zea
2011/07/21 20:09:50
Done.
|
| +} |
| + |
| +const tracked_objects::Location& SyncError::location() const { |
| + return *location_; |
|
akalin
2011/07/20 23:43:05
DCHECK(is_set()) here, too? Probably should be a
Nicolas Zea
2011/07/21 20:09:50
Done.
|
| +} |
| + |
| +const std::string& SyncError::message() const { |
| + DCHECK(is_set()); |
| + return message_; |
| +} |
| + |
| +const syncable::ModelType SyncError::type() const { |
| + DCHECK(is_set()); |
| + return type_; |
| +} |
| + |
| +void SyncError::print_log_error() const { |
| + LAZY_STREAM(logging::LogMessage(location_->file_name(), |
| + location_->line_number(), |
| + ERROR).stream(), |
| + LOG_IS_ON(ERROR)) |
| + << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; |
| +} |