OLD | NEW |
| (Empty) |
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 COMPONENTS_SYNC_API_SYNC_MERGE_RESULT_H_ | |
6 #define COMPONENTS_SYNC_API_SYNC_MERGE_RESULT_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "components/sync/api/sync_error.h" | |
11 #include "components/sync/base/model_type.h" | |
12 | |
13 namespace syncer { | |
14 | |
15 // A model-type-specific view of a sync merge. This class encapsulates the | |
16 // state before and after the merge as well as the deltas and any error that | |
17 // occurred. | |
18 // Note: This class only tracks one side of the merge. In other words, if built | |
19 // by the local SyncableService, all values correspond to the local state before | |
20 // and after merging, and the delta's applied to that state. Sync's change | |
21 // processor will create a separate merge result. | |
22 class SyncMergeResult { | |
23 public: | |
24 // Initialize an empty merge result for model type |type|. | |
25 explicit SyncMergeResult(ModelType type); | |
26 SyncMergeResult(const SyncMergeResult& other); | |
27 ~SyncMergeResult(); | |
28 | |
29 // Default copy and assign welcome. | |
30 | |
31 // Setters. | |
32 // Note: if |error.IsSet()| is true, |error.type()| must match model_type_ | |
33 void set_error(SyncError error); | |
34 void set_num_items_before_association(int num_items_before_association); | |
35 void set_num_items_after_association(int num_items_after_association); | |
36 void set_num_items_added(int num_items_added); | |
37 void set_num_items_deleted(int num_items_deleted); | |
38 void set_num_items_modified(int num_items_modified); | |
39 void set_pre_association_version(int64_t version); | |
40 | |
41 // Getters. | |
42 ModelType model_type() const; | |
43 SyncError error() const; | |
44 int num_items_before_association() const; | |
45 int num_items_after_association() const; | |
46 int num_items_added() const; | |
47 int num_items_deleted() const; | |
48 int num_items_modified() const; | |
49 int64_t pre_association_version() const; | |
50 | |
51 private: | |
52 // Make |this| into a copy of |other|. | |
53 void CopyFrom(const SyncMergeResult& other); | |
54 | |
55 // The datatype that was associated. | |
56 ModelType model_type_; | |
57 | |
58 // The error encountered during association. Unset if no error was | |
59 // encountered. | |
60 SyncError error_; | |
61 | |
62 // The state of the world before association. | |
63 int num_items_before_association_; | |
64 | |
65 // The state of the world after association. | |
66 int num_items_after_association_; | |
67 | |
68 // The changes that took place during association. In a correctly working | |
69 // system these should be the deltas between before and after. | |
70 int num_items_added_; | |
71 int num_items_deleted_; | |
72 int num_items_modified_; | |
73 | |
74 // Version of model before association. | |
75 int64_t pre_association_version_; | |
76 }; | |
77 | |
78 } // namespace syncer | |
79 | |
80 #endif // COMPONENTS_SYNC_API_SYNC_MERGE_RESULT_H_ | |
OLD | NEW |