| 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());
|
| + return message_;
|
| +}
|
| +
|
| +const syncable::ModelType SyncError::type() const {
|
| + DCHECK(IsInitialized());
|
| + 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_;
|
| +}
|
|
|