15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef SYNC_ENGINE_SYNCER_TYPES_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define SYNC_ENGINE_SYNCER_TYPES_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The intent of this is to keep all shared data types and enums for the syncer
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// in a single place without having dependencies between other files.
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace syncer {
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum UpdateAttemptResponse {
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Update was applied or safely ignored.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SUCCESS,
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The conditions described by the following enum values are not mutually
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // exclusive.  The list has been ordered according to priority in the case of
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // overlap, with highest priority first.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // For example, in the case where an item had both the IS_UNSYCNED and
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // IS_UNAPPLIED_UPDATE flags set (CONFLICT_SIMPLE), and a SERVER_PARENT_ID
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // that, if applied, would cause a directory loop (CONFLICT_HIERARCHY), and
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // specifics that we can't decrypt right now (CONFLICT_ENCRYPTION), the
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // UpdateApplicator would return CONFLICT_ENCRYPTION when attempting to
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // process the item.
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We do not attempt to resolve CONFLICT_HIERARCHY or CONFLICT_ENCRYPTION
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // items.  We will leave these updates unapplied and wait for the server
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // to send us newer updates that will resolve the conflict.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // We were unable to decrypt/encrypt this server data. As such, we can't make
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // forward progress on this node, but because the passphrase may not arrive
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // until later we don't want to get the syncer stuck. See UpdateApplicator
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // for how this is handled.
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CONFLICT_ENCRYPTION,
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These are some updates that, if applied, would violate the tree's
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invariants.  Examples of this include the server adding children to locally
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // deleted directories and directory moves that would create loops.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CONFLICT_HIERARCHY,
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This indicates that item was modified both remotely (IS_UNAPPLIED_UPDATE)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and locally (IS_UNSYNCED).  We use the ConflictResolver to decide which of
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the changes should take priority, or if we can possibly merge the data.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CONFLICT_SIMPLE
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Different results from the verify phase will yield different methods of
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// processing in the ProcessUpdates phase. The SKIP result means the entry
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// doesn't go to the ProcessUpdates phase.
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum VerifyResult {
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_FAIL,
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_SUCCESS,
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_UNDELETE,
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_SKIP,
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_UNDECIDED
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum VerifyCommitResult {
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_UNSYNCABLE,
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  VERIFY_OK,
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace syncer
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // SYNC_ENGINE_SYNCER_TYPES_H_
67