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 #include "base/tracked.h" | |
| 9 | |
| 10 SyncError::SyncError() { | |
| 11 } | |
| 12 | |
| 13 SyncError::SyncError(const tracked_objects::Location& location, | |
| 14 const std::string& message, | |
| 15 syncable::ModelType type) | |
| 16 : 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.
| |
| 17 message_(message), | |
| 18 type_(type) { | |
| 19 PrintLogError(); | |
| 20 } | |
| 21 | |
| 22 SyncError::SyncError(const SyncError& other) { | |
| 23 *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.
| |
| 24 } | |
| 25 | |
| 26 SyncError& SyncError::operator=(const SyncError& other) { | |
| 27 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.
| |
| 28 NOTREACHED(); | |
| 29 return *this; | |
| 30 } | |
| 31 location_.reset(new tracked_objects::Location(other.location())); | |
| 32 message_ = other.message(); | |
| 33 type_ = other.type(); | |
| 34 return *this; | |
| 35 } | |
| 36 | |
| 37 void SyncError::Reset(const tracked_objects::Location& location, | |
| 38 const std::string& message, | |
| 39 syncable::ModelType type) { | |
| 40 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.
| |
| 41 message_ = message; | |
| 42 type_ = type; | |
| 43 PrintLogError(); | |
| 44 } | |
| 45 | |
| 46 bool SyncError::IsInitialized() const { | |
| 47 return location_.get() != NULL; | |
| 48 } | |
| 49 | |
| 50 const tracked_objects::Location& SyncError::location() const { | |
| 51 CHECK(IsInitialized()); | |
| 52 return *location_; | |
| 53 } | |
| 54 | |
| 55 const std::string& SyncError::message() const { | |
| 56 CHECK(IsInitialized()); | |
| 57 return message_; | |
| 58 } | |
| 59 | |
| 60 const syncable::ModelType SyncError::type() const { | |
| 61 CHECK(IsInitialized()); | |
| 62 return type_; | |
| 63 } | |
| 64 | |
| 65 void SyncError::PrintLogError() const { | |
| 66 LAZY_STREAM(logging::LogMessage(location_->file_name(), | |
| 67 location_->line_number(), | |
| 68 logging::LOG_ERROR).stream(), | |
| 69 LOG_IS_ON(ERROR)) | |
| 70 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; | |
| 71 } | |
| OLD | NEW |