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

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

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 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
« no previous file with comments | « sync/test/engine/syncer_command_test.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/base64.h" 10 #include "base/base64.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 std::string str; 148 std::string str;
149 base::JSONWriter::Write(&value, &str); 149 base::JSONWriter::Write(&value, &str);
150 return str; 150 return str;
151 } 151 }
152 152
153 class LoggingChangeDelegate : public syncer::SyncManager::ChangeDelegate { 153 class LoggingChangeDelegate : public syncer::SyncManager::ChangeDelegate {
154 public: 154 public:
155 virtual ~LoggingChangeDelegate() {} 155 virtual ~LoggingChangeDelegate() {}
156 156
157 virtual void OnChangesApplied( 157 virtual void OnChangesApplied(
158 syncable::ModelType model_type, 158 syncer::ModelType model_type,
159 const syncer::BaseTransaction* trans, 159 const syncer::BaseTransaction* trans,
160 const syncer::ImmutableChangeRecordList& changes) OVERRIDE { 160 const syncer::ImmutableChangeRecordList& changes) OVERRIDE {
161 LOG(INFO) << "Changes applied for " 161 LOG(INFO) << "Changes applied for "
162 << syncable::ModelTypeToString(model_type); 162 << syncer::ModelTypeToString(model_type);
163 size_t i = 1; 163 size_t i = 1;
164 size_t change_count = changes.Get().size(); 164 size_t change_count = changes.Get().size();
165 for (syncer::ChangeRecordList::const_iterator it = 165 for (syncer::ChangeRecordList::const_iterator it =
166 changes.Get().begin(); it != changes.Get().end(); ++it) { 166 changes.Get().begin(); it != changes.Get().end(); ++it) {
167 scoped_ptr<base::DictionaryValue> change_value(it->ToValue()); 167 scoped_ptr<base::DictionaryValue> change_value(it->ToValue());
168 LOG(INFO) << "Change (" << i << "/" << change_count << "): " 168 LOG(INFO) << "Change (" << i << "/" << change_count << "): "
169 << ValueToString(*change_value); 169 << ValueToString(*change_value);
170 if (it->action != syncer::ChangeRecord::ACTION_DELETE) { 170 if (it->action != syncer::ChangeRecord::ACTION_DELETE) {
171 syncer::ReadNode node(trans); 171 syncer::ReadNode node(trans);
172 CHECK_EQ(node.InitByIdLookup(it->id), syncer::BaseNode::INIT_OK); 172 CHECK_EQ(node.InitByIdLookup(it->id), syncer::BaseNode::INIT_OK);
173 scoped_ptr<base::DictionaryValue> details(node.GetDetailsAsValue()); 173 scoped_ptr<base::DictionaryValue> details(node.GetDetailsAsValue());
174 VLOG(1) << "Details: " << ValueToString(*details); 174 VLOG(1) << "Details: " << ValueToString(*details);
175 } 175 }
176 ++i; 176 ++i;
177 } 177 }
178 } 178 }
179 179
180 virtual void OnChangesComplete(syncable::ModelType model_type) OVERRIDE { 180 virtual void OnChangesComplete(syncer::ModelType model_type) OVERRIDE {
181 LOG(INFO) << "Changes complete for " 181 LOG(INFO) << "Changes complete for "
182 << syncable::ModelTypeToString(model_type); 182 << syncer::ModelTypeToString(model_type);
183 } 183 }
184 }; 184 };
185 185
186 class LoggingUnrecoverableErrorHandler 186 class LoggingUnrecoverableErrorHandler
187 : public syncer::UnrecoverableErrorHandler { 187 : public syncer::UnrecoverableErrorHandler {
188 public: 188 public:
189 virtual ~LoggingUnrecoverableErrorHandler() {} 189 virtual ~LoggingUnrecoverableErrorHandler() {}
190 190
191 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here, 191 virtual void OnUnrecoverableError(const tracked_objects::Location& from_here,
192 const std::string& message) OVERRIDE { 192 const std::string& message) OVERRIDE {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 NullInvalidationStateTracker null_invalidation_state_tracker; 307 NullInvalidationStateTracker null_invalidation_state_tracker;
308 syncer::SyncNotifierFactory sync_notifier_factory( 308 syncer::SyncNotifierFactory sync_notifier_factory(
309 notifier_options, kClientInfo, 309 notifier_options, kClientInfo,
310 null_invalidation_state_tracker.AsWeakPtr()); 310 null_invalidation_state_tracker.AsWeakPtr());
311 311
312 // Set up database directory for the syncer. 312 // Set up database directory for the syncer.
313 ScopedTempDir database_dir; 313 ScopedTempDir database_dir;
314 CHECK(database_dir.CreateUniqueTempDir()); 314 CHECK(database_dir.CreateUniqueTempDir());
315 315
316 // Set up model type parameters. 316 // Set up model type parameters.
317 const syncable::ModelTypeSet model_types = syncable::ModelTypeSet::All(); 317 const syncer::ModelTypeSet model_types = syncer::ModelTypeSet::All();
318 syncer::ModelSafeRoutingInfo routing_info; 318 syncer::ModelSafeRoutingInfo routing_info;
319 for (syncable::ModelTypeSet::Iterator it = model_types.First(); 319 for (syncer::ModelTypeSet::Iterator it = model_types.First();
320 it.Good(); it.Inc()) { 320 it.Good(); it.Inc()) {
321 routing_info[it.Get()] = syncer::GROUP_PASSIVE; 321 routing_info[it.Get()] = syncer::GROUP_PASSIVE;
322 } 322 }
323 scoped_refptr<syncer::PassiveModelWorker> passive_model_safe_worker = 323 scoped_refptr<syncer::PassiveModelWorker> passive_model_safe_worker =
324 new syncer::PassiveModelWorker(&sync_loop); 324 new syncer::PassiveModelWorker(&sync_loop);
325 std::vector<syncer::ModelSafeWorker*> workers; 325 std::vector<syncer::ModelSafeWorker*> workers;
326 workers.push_back(passive_model_safe_worker.get()); 326 workers.push_back(passive_model_safe_worker.get());
327 327
328 // Set up sync manager. 328 // Set up sync manager.
329 syncer::SyncManager sync_manager("sync_client manager"); 329 syncer::SyncManager sync_manager("sync_client manager");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // TODO(akalin): We have pass in model parameters multiple times. 369 // TODO(akalin): We have pass in model parameters multiple times.
370 // Organize handling of model types. 370 // Organize handling of model types.
371 sync_manager.UpdateEnabledTypes(model_types); 371 sync_manager.UpdateEnabledTypes(model_types);
372 sync_manager.StartSyncingNormally(routing_info); 372 sync_manager.StartSyncingNormally(routing_info);
373 373
374 sync_loop.Run(); 374 sync_loop.Run();
375 375
376 io_thread.Stop(); 376 io_thread.Stop();
377 return 0; 377 return 0;
378 } 378 }
OLDNEW
« no previous file with comments | « sync/test/engine/syncer_command_test.h ('k') | sync/tools/sync_listen_notifications.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698