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

Side by Side 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: Rebase and really 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
26
27 void SyncError::Reset(const tracked_objects::Location& location,
28 const std::string& message,
29 syncable::ModelType type) {
30 location_.reset(new tracked_objects::Location(location));
31 message_ = message;
32 type_ = type;
33 print_log_error();
34 }
35
36 bool SyncError::IsInitialized() const {
37 return location_.get() != NULL;
38 }
39
40 const tracked_objects::Location& SyncError::location() const {
41 CHECK(IsInitialized());
42 return *location_;
43 }
44
45 const std::string& SyncError::message() const {
46 DCHECK(IsInitialized());
47 return message_;
48 }
49
50 const syncable::ModelType SyncError::type() const {
51 DCHECK(IsInitialized());
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698