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 // Utility functions manipulating syncable::Entries, intended for use by the | 5 // Utility functions manipulating syncable::Entries, intended for use by the |
6 // syncer. | 6 // syncer. |
7 | 7 |
8 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ | 8 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ |
9 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ | 9 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ |
10 | 10 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "components/sync/base/sync_export.h" | |
18 #include "components/sync/engine_impl/syncer.h" | 17 #include "components/sync/engine_impl/syncer.h" |
19 #include "components/sync/engine_impl/syncer_types.h" | 18 #include "components/sync/engine_impl/syncer_types.h" |
20 #include "components/sync/syncable/entry_kernel.h" | 19 #include "components/sync/syncable/entry_kernel.h" |
21 #include "components/sync/syncable/metahandle_set.h" | 20 #include "components/sync/syncable/metahandle_set.h" |
22 #include "components/sync/syncable/mutable_entry.h" | 21 #include "components/sync/syncable/mutable_entry.h" |
23 #include "components/sync/syncable/syncable_id.h" | 22 #include "components/sync/syncable/syncable_id.h" |
24 | 23 |
25 namespace sync_pb { | 24 namespace sync_pb { |
26 class SyncEntity; | 25 class SyncEntity; |
27 } // namespace sync_pb | 26 } // namespace sync_pb |
(...skipping 25 matching lines...) Expand all Loading... |
53 Cryptographer* cryptographer); | 52 Cryptographer* cryptographer); |
54 | 53 |
55 // Returns the most accurate position information available in this update. It | 54 // Returns the most accurate position information available in this update. It |
56 // prefers to use the unique_position() field, but will fall back to using the | 55 // prefers to use the unique_position() field, but will fall back to using the |
57 // int64_t-based position_in_parent if necessary. | 56 // int64_t-based position_in_parent if necessary. |
58 // | 57 // |
59 // The suffix parameter is the unique bookmark tag for the item being updated. | 58 // The suffix parameter is the unique bookmark tag for the item being updated. |
60 // | 59 // |
61 // Will return an invalid position if no valid position can be constructed, or | 60 // Will return an invalid position if no valid position can be constructed, or |
62 // if this type does not support positioning. | 61 // if this type does not support positioning. |
63 SYNC_EXPORT UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update, | 62 UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update, |
64 const std::string& suffix); | 63 const std::string& suffix); |
65 | 64 |
66 // Fetch the cache_guid and item_id-based unique bookmark tag from an update. | 65 // Fetch the cache_guid and item_id-based unique bookmark tag from an update. |
67 // Will return an empty string if someting unexpected happens. | 66 // Will return an empty string if someting unexpected happens. |
68 SYNC_EXPORT std::string GetUniqueBookmarkTagFromUpdate( | 67 std::string GetUniqueBookmarkTagFromUpdate(const sync_pb::SyncEntity& update); |
69 const sync_pb::SyncEntity& update); | |
70 | 68 |
71 // Pass in name to avoid redundant UTF8 conversion. | 69 // Pass in name to avoid redundant UTF8 conversion. |
72 SYNC_EXPORT void UpdateServerFieldsFromUpdate( | 70 void UpdateServerFieldsFromUpdate( |
73 syncable::ModelNeutralMutableEntry* local_entry, | 71 syncable::ModelNeutralMutableEntry* local_entry, |
74 const sync_pb::SyncEntity& server_entry, | 72 const sync_pb::SyncEntity& server_entry, |
75 const std::string& name); | 73 const std::string& name); |
76 | 74 |
77 // Creates a new Entry iff no Entry exists with the given id. | 75 // Creates a new Entry iff no Entry exists with the given id. |
78 void CreateNewEntry(syncable::ModelNeutralWriteTransaction* trans, | 76 void CreateNewEntry(syncable::ModelNeutralWriteTransaction* trans, |
79 const syncable::Id& id); | 77 const syncable::Id& id); |
80 | 78 |
81 // This function is called on an entry when we can update the user-facing data | 79 // This function is called on an entry when we can update the user-facing data |
82 // from the server data. | 80 // from the server data. |
(...skipping 22 matching lines...) Expand all Loading... |
105 const sync_pb::SyncEntity& update, | 103 const sync_pb::SyncEntity& update, |
106 syncable::ModelNeutralMutableEntry* target); | 104 syncable::ModelNeutralMutableEntry* target); |
107 | 105 |
108 void MarkDeletedChildrenSynced(syncable::Directory* dir, | 106 void MarkDeletedChildrenSynced(syncable::Directory* dir, |
109 syncable::BaseWriteTransaction* trans, | 107 syncable::BaseWriteTransaction* trans, |
110 std::set<syncable::Id>* deleted_folders); | 108 std::set<syncable::Id>* deleted_folders); |
111 | 109 |
112 } // namespace syncer | 110 } // namespace syncer |
113 | 111 |
114 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ | 112 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_ |
OLD | NEW |