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

Side by Side Diff: sync/tools/sync_client.cc

Issue 629733002: replace OVERRIDE and FINAL with override and final in sync/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « sync/tools/null_invalidation_state_tracker.h ('k') | sync/tools/sync_listen_notifications.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <cstddef> 5 #include <cstddef>
6 #include <cstdio> 6 #include <cstdio>
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 virtual ~MyTestURLRequestContext() {} 82 virtual ~MyTestURLRequestContext() {}
83 }; 83 };
84 84
85 class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter { 85 class MyTestURLRequestContextGetter : public net::TestURLRequestContextGetter {
86 public: 86 public:
87 explicit MyTestURLRequestContextGetter( 87 explicit MyTestURLRequestContextGetter(
88 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 88 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
89 : TestURLRequestContextGetter(io_task_runner) {} 89 : TestURLRequestContextGetter(io_task_runner) {}
90 90
91 virtual net::TestURLRequestContext* GetURLRequestContext() OVERRIDE { 91 virtual net::TestURLRequestContext* GetURLRequestContext() override {
92 // Construct |context_| lazily so it gets constructed on the right 92 // Construct |context_| lazily so it gets constructed on the right
93 // thread (the IO thread). 93 // thread (the IO thread).
94 if (!context_) 94 if (!context_)
95 context_.reset(new MyTestURLRequestContext()); 95 context_.reset(new MyTestURLRequestContext());
96 return context_.get(); 96 return context_.get();
97 } 97 }
98 98
99 private: 99 private:
100 virtual ~MyTestURLRequestContextGetter() {} 100 virtual ~MyTestURLRequestContextGetter() {}
101 101
102 scoped_ptr<MyTestURLRequestContext> context_; 102 scoped_ptr<MyTestURLRequestContext> context_;
103 }; 103 };
104 104
105 // TODO(akalin): Use system encryptor once it's moved to sync/. 105 // TODO(akalin): Use system encryptor once it's moved to sync/.
106 class NullEncryptor : public Encryptor { 106 class NullEncryptor : public Encryptor {
107 public: 107 public:
108 virtual ~NullEncryptor() {} 108 virtual ~NullEncryptor() {}
109 109
110 virtual bool EncryptString(const std::string& plaintext, 110 virtual bool EncryptString(const std::string& plaintext,
111 std::string* ciphertext) OVERRIDE { 111 std::string* ciphertext) override {
112 *ciphertext = plaintext; 112 *ciphertext = plaintext;
113 return true; 113 return true;
114 } 114 }
115 115
116 virtual bool DecryptString(const std::string& ciphertext, 116 virtual bool DecryptString(const std::string& ciphertext,
117 std::string* plaintext) OVERRIDE { 117 std::string* plaintext) override {
118 *plaintext = ciphertext; 118 *plaintext = ciphertext;
119 return true; 119 return true;
120 } 120 }
121 }; 121 };
122 122
123 std::string ValueToString(const base::Value& value) { 123 std::string ValueToString(const base::Value& value) {
124 std::string str; 124 std::string str;
125 base::JSONWriter::Write(&value, &str); 125 base::JSONWriter::Write(&value, &str);
126 return str; 126 return str;
127 } 127 }
128 128
129 class LoggingChangeDelegate : public SyncManager::ChangeDelegate { 129 class LoggingChangeDelegate : public SyncManager::ChangeDelegate {
130 public: 130 public:
131 virtual ~LoggingChangeDelegate() {} 131 virtual ~LoggingChangeDelegate() {}
132 132
133 virtual void OnChangesApplied( 133 virtual void OnChangesApplied(
134 ModelType model_type, 134 ModelType model_type,
135 int64 model_version, 135 int64 model_version,
136 const BaseTransaction* trans, 136 const BaseTransaction* trans,
137 const ImmutableChangeRecordList& changes) OVERRIDE { 137 const ImmutableChangeRecordList& changes) override {
138 LOG(INFO) << "Changes applied for " 138 LOG(INFO) << "Changes applied for "
139 << ModelTypeToString(model_type); 139 << ModelTypeToString(model_type);
140 size_t i = 1; 140 size_t i = 1;
141 size_t change_count = changes.Get().size(); 141 size_t change_count = changes.Get().size();
142 for (ChangeRecordList::const_iterator it = 142 for (ChangeRecordList::const_iterator it =
143 changes.Get().begin(); it != changes.Get().end(); ++it) { 143 changes.Get().begin(); it != changes.Get().end(); ++it) {
144 scoped_ptr<base::DictionaryValue> change_value(it->ToValue()); 144 scoped_ptr<base::DictionaryValue> change_value(it->ToValue());
145 LOG(INFO) << "Change (" << i << "/" << change_count << "): " 145 LOG(INFO) << "Change (" << i << "/" << change_count << "): "
146 << ValueToString(*change_value); 146 << ValueToString(*change_value);
147 if (it->action != ChangeRecord::ACTION_DELETE) { 147 if (it->action != ChangeRecord::ACTION_DELETE) {
148 ReadNode node(trans); 148 ReadNode node(trans);
149 CHECK_EQ(node.InitByIdLookup(it->id), BaseNode::INIT_OK); 149 CHECK_EQ(node.InitByIdLookup(it->id), BaseNode::INIT_OK);
150 scoped_ptr<base::DictionaryValue> details(node.ToValue()); 150 scoped_ptr<base::DictionaryValue> details(node.ToValue());
151 VLOG(1) << "Details: " << ValueToString(*details); 151 VLOG(1) << "Details: " << ValueToString(*details);
152 } 152 }
153 ++i; 153 ++i;
154 } 154 }
155 } 155 }
156 156
157 virtual void OnChangesComplete(ModelType model_type) OVERRIDE { 157 virtual void OnChangesComplete(ModelType model_type) override {
158 LOG(INFO) << "Changes complete for " 158 LOG(INFO) << "Changes complete for "
159 << ModelTypeToString(model_type); 159 << ModelTypeToString(model_type);
160 } 160 }
161 }; 161 };
162 162
163 class LoggingUnrecoverableErrorHandler 163 class LoggingUnrecoverableErrorHandler
164 : public UnrecoverableErrorHandler { 164 : public UnrecoverableErrorHandler {
165 public: 165 public:
166 virtual ~LoggingUnrecoverableErrorHandler() {} 166 virtual ~LoggingUnrecoverableErrorHandler() {}
167 167
168 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here, 168 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
169 const std::string& message) OVERRIDE { 169 const std::string& message) override {
170 if (LOG_IS_ON(ERROR)) { 170 if (LOG_IS_ON(ERROR)) {
171 logging::LogMessage(from_here.file_name(), from_here.line_number(), 171 logging::LogMessage(from_here.file_name(), from_here.line_number(),
172 logging::LOG_ERROR).stream() 172 logging::LOG_ERROR).stream()
173 << message; 173 << message;
174 } 174 }
175 } 175 }
176 }; 176 };
177 177
178 class LoggingJsEventHandler 178 class LoggingJsEventHandler
179 : public JsEventHandler, 179 : public JsEventHandler,
180 public base::SupportsWeakPtr<LoggingJsEventHandler> { 180 public base::SupportsWeakPtr<LoggingJsEventHandler> {
181 public: 181 public:
182 virtual ~LoggingJsEventHandler() {} 182 virtual ~LoggingJsEventHandler() {}
183 183
184 virtual void HandleJsEvent( 184 virtual void HandleJsEvent(
185 const std::string& name, 185 const std::string& name,
186 const JsEventDetails& details) OVERRIDE { 186 const JsEventDetails& details) override {
187 VLOG(1) << name << ": " << details.ToString(); 187 VLOG(1) << name << ": " << details.ToString();
188 } 188 }
189 }; 189 };
190 190
191 class InvalidationAdapter : public syncer::InvalidationInterface { 191 class InvalidationAdapter : public syncer::InvalidationInterface {
192 public: 192 public:
193 explicit InvalidationAdapter(const syncer::Invalidation& invalidation) 193 explicit InvalidationAdapter(const syncer::Invalidation& invalidation)
194 : invalidation_(invalidation) {} 194 : invalidation_(invalidation) {}
195 virtual ~InvalidationAdapter() {} 195 virtual ~InvalidationAdapter() {}
196 196
197 virtual bool IsUnknownVersion() const OVERRIDE { 197 virtual bool IsUnknownVersion() const override {
198 return invalidation_.is_unknown_version(); 198 return invalidation_.is_unknown_version();
199 } 199 }
200 200
201 virtual const std::string& GetPayload() const OVERRIDE { 201 virtual const std::string& GetPayload() const override {
202 return invalidation_.payload(); 202 return invalidation_.payload();
203 } 203 }
204 204
205 virtual int64 GetVersion() const OVERRIDE { 205 virtual int64 GetVersion() const override {
206 return invalidation_.version(); 206 return invalidation_.version();
207 } 207 }
208 208
209 virtual void Acknowledge() OVERRIDE { 209 virtual void Acknowledge() override {
210 invalidation_.Acknowledge(); 210 invalidation_.Acknowledge();
211 } 211 }
212 212
213 virtual void Drop() OVERRIDE { 213 virtual void Drop() override {
214 invalidation_.Drop(); 214 invalidation_.Drop();
215 } 215 }
216 216
217 private: 217 private:
218 syncer::Invalidation invalidation_; 218 syncer::Invalidation invalidation_;
219 }; 219 };
220 220
221 class InvalidatorShim : public InvalidationHandler { 221 class InvalidatorShim : public InvalidationHandler {
222 public: 222 public:
223 explicit InvalidatorShim(SyncManager* sync_manager) 223 explicit InvalidatorShim(SyncManager* sync_manager)
224 : sync_manager_(sync_manager) {} 224 : sync_manager_(sync_manager) {}
225 225
226 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE { 226 virtual void OnInvalidatorStateChange(InvalidatorState state) override {
227 sync_manager_->SetInvalidatorEnabled(state == INVALIDATIONS_ENABLED); 227 sync_manager_->SetInvalidatorEnabled(state == INVALIDATIONS_ENABLED);
228 } 228 }
229 229
230 virtual void OnIncomingInvalidation( 230 virtual void OnIncomingInvalidation(
231 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE { 231 const ObjectIdInvalidationMap& invalidation_map) override {
232 syncer::ObjectIdSet ids = invalidation_map.GetObjectIds(); 232 syncer::ObjectIdSet ids = invalidation_map.GetObjectIds();
233 for (syncer::ObjectIdSet::const_iterator ids_it = ids.begin(); 233 for (syncer::ObjectIdSet::const_iterator ids_it = ids.begin();
234 ids_it != ids.end(); 234 ids_it != ids.end();
235 ++ids_it) { 235 ++ids_it) {
236 syncer::ModelType type; 236 syncer::ModelType type;
237 if (!NotificationTypeToRealModelType(ids_it->name(), &type)) { 237 if (!NotificationTypeToRealModelType(ids_it->name(), &type)) {
238 DLOG(WARNING) << "Notification has invalid id: " 238 DLOG(WARNING) << "Notification has invalid id: "
239 << syncer::ObjectIdToString(*ids_it); 239 << syncer::ObjectIdToString(*ids_it);
240 } else { 240 } else {
241 syncer::SingleObjectInvalidationSet invalidation_set = 241 syncer::SingleObjectInvalidationSet invalidation_set =
242 invalidation_map.ForObject(*ids_it); 242 invalidation_map.ForObject(*ids_it);
243 for (syncer::SingleObjectInvalidationSet::const_iterator inv_it = 243 for (syncer::SingleObjectInvalidationSet::const_iterator inv_it =
244 invalidation_set.begin(); 244 invalidation_set.begin();
245 inv_it != invalidation_set.end(); 245 inv_it != invalidation_set.end();
246 ++inv_it) { 246 ++inv_it) {
247 scoped_ptr<syncer::InvalidationInterface> inv_adapter( 247 scoped_ptr<syncer::InvalidationInterface> inv_adapter(
248 new InvalidationAdapter(*inv_it)); 248 new InvalidationAdapter(*inv_it));
249 sync_manager_->OnIncomingInvalidation(type, inv_adapter.Pass()); 249 sync_manager_->OnIncomingInvalidation(type, inv_adapter.Pass());
250 } 250 }
251 } 251 }
252 } 252 }
253 } 253 }
254 254
255 virtual std::string GetOwnerName() const OVERRIDE { 255 virtual std::string GetOwnerName() const override {
256 return "InvalidatorShim"; 256 return "InvalidatorShim";
257 } 257 }
258 258
259 private: 259 private:
260 SyncManager* sync_manager_; 260 SyncManager* sync_manager_;
261 }; 261 };
262 262
263 void LogUnrecoverableErrorContext() { 263 void LogUnrecoverableErrorContext() {
264 base::debug::StackTrace().Print(); 264 base::debug::StackTrace().Print();
265 } 265 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 io_thread.Stop(); 464 io_thread.Stop();
465 return 0; 465 return 0;
466 } 466 }
467 467
468 } // namespace 468 } // namespace
469 } // namespace syncer 469 } // namespace syncer
470 470
471 int main(int argc, char* argv[]) { 471 int main(int argc, char* argv[]) {
472 return syncer::SyncClientMain(argc, argv); 472 return syncer::SyncClientMain(argc, argv);
473 } 473 }
OLDNEW
« no previous file with comments | « sync/tools/null_invalidation_state_tracker.h ('k') | sync/tools/sync_listen_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698