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