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

Side by Side Diff: chrome/browser/sync/api/sync_error.cc

Issue 7978044: Sync/Valgrind: Add gmock printers for SyncChange, SyncData, SyncError. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years, 3 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/api/sync_error.h" 5 #include "chrome/browser/sync/api/sync_error.h"
6 6
7 #include <iostream>
akalin 2011/09/22 01:24:56 iostream -> ostream (former introduces a static in
James Hawkins 2011/09/22 02:50:29 Done.
8 #include <sstream>
9
7 #include "base/logging.h" 10 #include "base/logging.h"
8 #include "base/tracked.h" 11 #include "base/tracked.h"
12 #include "chrome/browser/sync/syncable/model_type.h"
9 13
10 SyncError::SyncError() { 14 SyncError::SyncError() {
11 Clear(); 15 Clear();
12 } 16 }
13 17
14 SyncError::SyncError(const tracked_objects::Location& location, 18 SyncError::SyncError(const tracked_objects::Location& location,
15 const std::string& message, 19 const std::string& message,
16 syncable::ModelType type) { 20 syncable::ModelType type) {
17 Init(location, message, type); 21 Init(location, message, type);
18 PrintLogError(); 22 PrintLogError();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const std::string& SyncError::message() const { 80 const std::string& SyncError::message() const {
77 CHECK(IsSet()); 81 CHECK(IsSet());
78 return message_; 82 return message_;
79 } 83 }
80 84
81 syncable::ModelType SyncError::type() const { 85 syncable::ModelType SyncError::type() const {
82 CHECK(IsSet()); 86 CHECK(IsSet());
83 return type_; 87 return type_;
84 } 88 }
85 89
90 std::string SyncError::ToString() const {
91 std::string out;
92 std::stringstream ss(out, std::stringstream::in);
akalin 2011/09/22 01:24:56 You don't really need a stringstream, do you? Jus
James Hawkins 2011/09/22 02:50:29 I don't print IsSet() anymore, so I changed it bac
93 ss <<
94 "{" << location_->ToString() <<
akalin 2011/09/22 01:24:56 type() and message() CHECK IsSet(). Suggest: if
James Hawkins 2011/09/22 02:50:29 Done.
95 ", " << IsSet() <<
96 ", " << syncable::ModelTypeToString(type()) <<
97 ", " << message() <<
98 "}";
99 return out;
100 }
101
86 void SyncError::PrintLogError() const { 102 void SyncError::PrintLogError() const {
87 LAZY_STREAM(logging::LogMessage(location_->file_name(), 103 LAZY_STREAM(logging::LogMessage(location_->file_name(),
88 location_->line_number(), 104 location_->line_number(),
89 logging::LOG_ERROR).stream(), 105 logging::LOG_ERROR).stream(),
90 LOG_IS_ON(ERROR)) 106 LOG_IS_ON(ERROR))
91 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_; 107 << syncable::ModelTypeToString(type_) << " Sync Error: " << message_;
92 } 108 }
109
110 void PrintTo(const SyncError& sync_error, std::ostream* os) {
111 *os << sync_error.ToString();
112 }
OLDNEW
« chrome/browser/sync/api/sync_data.cc ('K') | « chrome/browser/sync/api/sync_error.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698