| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_DATA_H_ | 5 #ifndef SYNC_API_SYNC_DATA_H_ |
| 6 #define SYNC_API_SYNC_DATA_H_ | 6 #define SYNC_API_SYNC_DATA_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // The sync tag must be a string unique to this datatype and is used as a node | 34 // The sync tag must be a string unique to this datatype and is used as a node |
| 35 // identifier server-side. | 35 // identifier server-side. |
| 36 // For deletes: |datatype| must specify the datatype who node is being | 36 // For deletes: |datatype| must specify the datatype who node is being |
| 37 // deleted. | 37 // deleted. |
| 38 // For adds/updates: the specifics must be valid and the non-unique title (can | 38 // For adds/updates: the specifics must be valid and the non-unique title (can |
| 39 // be the same as sync tag) must be specfied. | 39 // be the same as sync tag) must be specfied. |
| 40 // Note: the non_unique_title is primarily for debug purposes, and will be | 40 // Note: the non_unique_title is primarily for debug purposes, and will be |
| 41 // overwritten if the datatype is encrypted. | 41 // overwritten if the datatype is encrypted. |
| 42 static SyncData CreateLocalDelete( | 42 static SyncData CreateLocalDelete( |
| 43 const std::string& sync_tag, | 43 const std::string& sync_tag, |
| 44 ModelType datatype); | 44 ModelType datatype, |
| 45 bool is_folder); |
| 45 static SyncData CreateLocalData( | 46 static SyncData CreateLocalData( |
| 46 const std::string& sync_tag, | 47 const std::string& sync_tag, |
| 47 const std::string& non_unique_title, | 48 const std::string& non_unique_title, |
| 48 const sync_pb::EntitySpecifics& specifics); | 49 const sync_pb::EntitySpecifics& specifics, |
| 50 bool is_folder); |
| 49 | 51 |
| 50 // Helper method for creating SyncData objects originating from the syncer. | 52 // Helper method for creating SyncData objects originating from the syncer. |
| 51 static SyncData CreateRemoteData( | 53 static SyncData CreateRemoteData( |
| 52 int64 id, const sync_pb::EntitySpecifics& specifics); | 54 int64 id, const sync_pb::EntitySpecifics& specifics, bool is_folder); |
| 53 | 55 |
| 54 // Whether this SyncData holds valid data. The only way to have a SyncData | 56 // Whether this SyncData holds valid data. The only way to have a SyncData |
| 55 // without valid data is to use the default constructor. | 57 // without valid data is to use the default constructor. |
| 56 bool IsValid() const; | 58 bool IsValid() const; |
| 57 | 59 |
| 58 // Return the datatype we're holding information about. Derived from the sync | 60 // Return the datatype we're holding information about. Derived from the sync |
| 59 // datatype specifics. | 61 // datatype specifics. |
| 60 ModelType GetDataType() const; | 62 ModelType GetDataType() const; |
| 61 | 63 |
| 62 // Return the current sync datatype specifics. | 64 // Return the current sync datatype specifics. |
| 63 const sync_pb::EntitySpecifics& GetSpecifics() const; | 65 const sync_pb::EntitySpecifics& GetSpecifics() const; |
| 64 | 66 |
| 65 // Returns the value of the unique client tag. This is only set for data going | 67 // Returns the value of the unique client tag. This is only set for data going |
| 66 // TO the syncer, not coming from. | 68 // TO the syncer, not coming from. |
| 67 const std::string& GetTag() const; | 69 const std::string& GetTag() const; |
| 68 | 70 |
| 69 // Returns the non unique title (for debugging). Currently only set for data | 71 // Returns the non unique title (for debugging). Currently only set for data |
| 70 // going TO the syncer, not from. | 72 // going TO the syncer, not from. |
| 71 const std::string& GetTitle() const; | 73 const std::string& GetTitle() const; |
| 72 | 74 |
| 73 // Should only be called by sync code when IsLocal() is false. | 75 // Should only be called by sync code when IsLocal() is false. |
| 74 int64 GetRemoteId() const; | 76 int64 GetRemoteId() const; |
| 75 | 77 |
| 76 // Whether this sync data is for local data or data coming from the syncer. | 78 // Whether this sync data is for local data or data coming from the syncer. |
| 77 bool IsLocal() const; | 79 bool IsLocal() const; |
| 78 | 80 |
| 81 bool IsFolder() const; |
| 82 |
| 79 std::string ToString() const; | 83 std::string ToString() const; |
| 80 | 84 |
| 81 // TODO(zea): Query methods for other sync properties: parent, successor, etc. | 85 // TODO(zea): Query methods for other sync properties: parent, successor, etc. |
| 82 | 86 |
| 83 private: | 87 private: |
| 84 // Necessary since we forward-declare sync_pb::SyncEntity; see | 88 // Necessary since we forward-declare sync_pb::SyncEntity; see |
| 85 // comments in immutable.h. | 89 // comments in immutable.h. |
| 86 struct ImmutableSyncEntityTraits { | 90 struct ImmutableSyncEntityTraits { |
| 87 typedef sync_pb::SyncEntity* Wrapper; | 91 typedef sync_pb::SyncEntity* Wrapper; |
| 88 | 92 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 102 | 106 |
| 103 // Clears |entity|. | 107 // Clears |entity|. |
| 104 SyncData(int64 id, sync_pb::SyncEntity* entity); | 108 SyncData(int64 id, sync_pb::SyncEntity* entity); |
| 105 | 109 |
| 106 // Whether this SyncData holds valid data. | 110 // Whether this SyncData holds valid data. |
| 107 bool is_valid_; | 111 bool is_valid_; |
| 108 | 112 |
| 109 // Equal to kInvalidId iff this is local. | 113 // Equal to kInvalidId iff this is local. |
| 110 int64 id_; | 114 int64 id_; |
| 111 | 115 |
| 116 bool is_folder_; |
| 117 |
| 112 // The actual shared sync entity being held. | 118 // The actual shared sync entity being held. |
| 113 ImmutableSyncEntity immutable_entity_; | 119 ImmutableSyncEntity immutable_entity_; |
| 114 }; | 120 }; |
| 115 | 121 |
| 122 typedef std::vector<syncer::SyncData> SyncDataList; |
| 123 |
| 116 // gmock printer helper. | 124 // gmock printer helper. |
| 117 void PrintTo(const SyncData& sync_data, std::ostream* os); | 125 void PrintTo(const SyncData& sync_data, std::ostream* os); |
| 118 | 126 |
| 119 } // namespace syncer | 127 } // namespace syncer |
| 120 | 128 |
| 121 #endif // SYNC_API_SYNC_DATA_H_ | 129 #endif // SYNC_API_SYNC_DATA_H_ |
| OLD | NEW |