Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| 9 SyncError::SyncError() { | |
| 10 } | |
| 11 | |
| 12 SyncError::SyncError(const tracked_objects::Location& location, | |
| 13 const std::string& message, | |
| 14 syncable::ModelType type) | |
| 15 : location_(new tracked_objects::Location(location)), | |
| 16 message_(message), | |
| 17 type_(type) { | |
| 18 print_log_error(); | |
| 19 } | |
| 20 | |
| 21 SyncError::SyncError(const SyncError& rhs) { | |
| 22 location_.reset(new tracked_objects::Location(rhs.location())); | |
| 23 message_ = rhs.message(); | |
| 24 type_ = rhs.type(); | |
| 25 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.
| |
| 26 } | |
| 27 | |
| 28 void SyncError::reset(const tracked_objects::Location& location, | |
| 29 const std::string& message, | |
| 30 syncable::ModelType type) { | |
| 31 location_.reset(new tracked_objects::Location(location)); | |
| 32 message_ = message; | |
| 33 type_ = type; | |
| 34 print_log_error(); | |
| 35 } | |
| 36 | |
| 37 bool SyncError::is_set() const { | |
| 38 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.
| |
| 39 } | |
| 40 | |
| 41 const tracked_objects::Location& SyncError::location() const { | |
| 42 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.
| |
| 43 } | |
| 44 | |
| 45 const std::string& SyncError::message() const { | |
| 46 DCHECK(is_set()); | |
| 47 return message_; | |
| 48 } | |
| 49 | |
| 50 const syncable::ModelType SyncError::type() const { | |
| 51 DCHECK(is_set()); | |
| 52 return type_; | |
| 53 } | |
| 54 | |
| 55 void SyncError::print_log_error() const { | |
| 56 LAZY_STREAM(logging::LogMessage(location_->file_name(), | |
| 57 location_->line_number(), | |
| 58 ERROR).stream(), | |
| 59 LOG_IS_ON(ERROR)) | |
| 60 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; | |
| 61 } | |
| OLD | NEW |