From 5852edc1b6eab234b9e048c41dd0d664ae7fc747 Mon Sep 17 00:00:00 2001 From: "nick@chromium.org" Date: Thu, 10 Sep 2009 06:05:27 +0000 Subject: Initial commit of sync engine code to browser/sync. The code is not built on any platform yet. That will arrive as a subsequent checkin. This is an implementation of the interface exposed earlier through syncapi.h. It is the client side of a sync protocol that lets users sync their browser data (currently, just bookmarks) with their Google Account. Table of contents: browser/sync/ protocol - The protocol definition, and other definitions necessary to connect to the service. syncable/ - defines a data model for syncable objects, and provides a sqlite-based backing store for this model. engine/ - includes the core sync logic, including commiting changes to the server, downloading changes from the server, resolving conflicts, other parts of the sync algorithm. engine/net - parts of the sync engine focused on the business of talking to the server. Some of this is binds a generic "server connection" interface to a concrete implementation provided by Chromium. notifier - the part of the syncer focused on the business of sending and receiving xmpp notifications. Notifications are used instead of polling to achieve very low latency change propagation. util - not necessarily sync specific utility code. Much of this is scaffolding which should either be replaced by, or merged with, the utility code in base/. BUG=none TEST=this code includes its own suite of unit tests. Review URL: http://codereview.chromium.org/194065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25850 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/sync/engine/update_applicator.h | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 chrome/browser/sync/engine/update_applicator.h (limited to 'chrome/browser/sync/engine/update_applicator.h') diff --git a/chrome/browser/sync/engine/update_applicator.h b/chrome/browser/sync/engine/update_applicator.h new file mode 100644 index 0000000..3d500171 --- /dev/null +++ b/chrome/browser/sync/engine/update_applicator.h @@ -0,0 +1,61 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// An UpdateApplicator is used to iterate over a number of unapplied +// updates, applying them to the client using the given syncer session. +// +// UpdateApplicator might resemble an iterator, but it actually keeps retrying +// failed updates until no remaining updates can be successfully applied. + +#ifndef CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ +#define CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ + +#include +#include + +#include "base/basictypes.h" +#include "base/port.h" + +namespace syncable { +class Id; +class WriteTransaction; +} // namespace syncable + +namespace browser_sync { + +class SyncerSession; + +class UpdateApplicator { + public: + typedef std::vector::iterator vi64iter; + + UpdateApplicator(SyncerSession* session, const vi64iter& begin, + const vi64iter& end); + // returns true if there's more we can do. + bool AttemptOneApplication(syncable::WriteTransaction* trans); + // return true if we've applied all updates. + bool AllUpdatesApplied() const; + + // This class does not automatically save its progress into the + // SyncerSession -- to get that to happen, call this method after + // update application is finished (i.e., when AttemptOneAllocation + // stops returning true). + void SaveProgressIntoSessionState(); + + private: + SyncerSession* const session_; + vi64iter const begin_; + vi64iter end_; + vi64iter pointer_; + bool progress_; + + // Track the result of the various items. + std::vector conflicting_ids_; + std::vector blocked_ids_; + std::vector successful_ids_; +}; + +} // namespace browser_sync + +#endif // CHROME_BROWSER_SYNC_ENGINE_UPDATE_APPLICATOR_H_ -- cgit v1.1