sync_merge_result.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef SYNC_API_SYNC_MERGE_RESULT_H_ 6#define SYNC_API_SYNC_MERGE_RESULT_H_ 7 8#include "sync/api/sync_error.h" 9#include "sync/base/sync_export.h" 10#include "sync/internal_api/public/base/model_type.h" 11 12namespace syncer { 13 14// A model-type-specific view of a sync merge. This class encapsulates the 15// state before and after the merge as well as the deltas and any error that 16// occurred. 17// Note: This class only tracks one side of the merge. In other words, if built 18// by the local SyncableService, all values correspond to the local state before 19// and after merging, and the delta's applied to that state. Sync's change 20// processor will create a separate merge result. 21class SYNC_EXPORT SyncMergeResult { 22 public: 23 // Initialize an empty merge result for model type |type|. 24 explicit SyncMergeResult(ModelType type); 25 ~SyncMergeResult(); 26 27 // Default copy and assign welcome. 28 29 // Setters. 30 // Note: if |error.IsSet()| is true, |error.type()| must match model_type_ 31 void set_error(SyncError error); 32 void set_num_items_before_association(int num_items_before_association); 33 void set_num_items_after_association(int num_items_after_association); 34 void set_num_items_added(int num_items_added); 35 void set_num_items_deleted(int num_items_deleted); 36 void set_num_items_modified(int num_items_modified); 37 38 // Getters. 39 ModelType model_type() const; 40 SyncError error() const; 41 int num_items_before_association() const; 42 int num_items_after_association() const; 43 int num_items_added() const; 44 int num_items_deleted() const; 45 int num_items_modified() const; 46 47 private: 48 // Make |this| into a copy of |other|. 49 void CopyFrom(const SyncMergeResult& other); 50 51 // The datatype that was associated. 52 ModelType model_type_; 53 54 // The error encountered during association. Unset if no error was 55 // encountered. 56 SyncError error_; 57 58 // The state of the world before association. 59 int num_items_before_association_; 60 61 // The state of the world after association. 62 int num_items_after_association_; 63 64 // The changes that took place during association. In a correctly working 65 // system these should be the deltas between before and after. 66 int num_items_added_; 67 int num_items_deleted_; 68 int num_items_modified_; 69}; 70 71} // namespace syncer 72 73#endif // SYNC_API_SYNC_MERGE_RESULT_H_ 74