Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: components/sync/engine_impl/syncer_util.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 SYNC_ENGINE_SYNCER_UTIL_H_ 8 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_
9 #define SYNC_ENGINE_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 "sync/base/sync_export.h" 17 #include "components/sync/base/sync_export.h"
18 #include "sync/engine/syncer.h" 18 #include "components/sync/engine_impl/syncer.h"
19 #include "sync/engine/syncer_types.h" 19 #include "components/sync/engine_impl/syncer_types.h"
20 #include "sync/syncable/entry_kernel.h" 20 #include "components/sync/syncable/entry_kernel.h"
21 #include "sync/syncable/metahandle_set.h" 21 #include "components/sync/syncable/metahandle_set.h"
22 #include "sync/syncable/mutable_entry.h" 22 #include "components/sync/syncable/mutable_entry.h"
23 #include "sync/syncable/syncable_id.h" 23 #include "components/sync/syncable/syncable_id.h"
24 24
25 namespace sync_pb { 25 namespace sync_pb {
26 class SyncEntity; 26 class SyncEntity;
27 } // namespace sync_pb 27 } // namespace sync_pb
28 28
29 namespace syncer { 29 namespace syncer {
30 30
31 namespace syncable { 31 namespace syncable {
32 class BaseTransaction; 32 class BaseTransaction;
33 class ModelNeutralWriteTransaction; 33 class ModelNeutralWriteTransaction;
34 } // namespace syncable 34 } // namespace syncable
35 35
36 class Cryptographer; 36 class Cryptographer;
37 37
38 // If the server sent down a client-tagged entry, or an entry whose 38 // If the server sent down a client-tagged entry, or an entry whose
39 // commit response was lost, it is necessary to update a local entry 39 // commit response was lost, it is necessary to update a local entry
40 // with an ID that doesn't match the ID of the update. Here, we 40 // with an ID that doesn't match the ID of the update. Here, we
41 // find the ID of such an entry, if it exists. This function may 41 // find the ID of such an entry, if it exists. This function may
42 // determine that |server_entry| should be dropped; if so, it returns 42 // determine that |server_entry| should be dropped; if so, it returns
43 // the null ID -- callers must handle this case. When update application 43 // the null ID -- callers must handle this case. When update application
44 // should proceed normally with a new local entry, this function will 44 // should proceed normally with a new local entry, this function will
45 // return server_entry.id(); the caller must create an entry with that 45 // return server_entry.id(); the caller must create an entry with that
46 // ID. This function does not alter the database. 46 // ID. This function does not alter the database.
47 syncable::Id FindLocalIdToUpdate( 47 syncable::Id FindLocalIdToUpdate(syncable::BaseTransaction* trans,
48 syncable::BaseTransaction* trans, 48 const sync_pb::SyncEntity& server_entry);
49 const sync_pb::SyncEntity& server_entry);
50 49
51 UpdateAttemptResponse AttemptToUpdateEntry( 50 UpdateAttemptResponse AttemptToUpdateEntry(
52 syncable::WriteTransaction* const trans, 51 syncable::WriteTransaction* const trans,
53 syncable::MutableEntry* const entry, 52 syncable::MutableEntry* const entry,
54 Cryptographer* cryptographer); 53 Cryptographer* cryptographer);
55 54
56 // Returns the most accurate position information available in this update. It 55 // Returns the most accurate position information available in this update. It
57 // prefers to use the unique_position() field, but will fall back to using the 56 // prefers to use the unique_position() field, but will fall back to using the
58 // int64_t-based position_in_parent if necessary. 57 // int64_t-based position_in_parent if necessary.
59 // 58 //
60 // The suffix parameter is the unique bookmark tag for the item being updated. 59 // The suffix parameter is the unique bookmark tag for the item being updated.
61 // 60 //
62 // Will return an invalid position if no valid position can be constructed, or 61 // Will return an invalid position if no valid position can be constructed, or
63 // if this type does not support positioning. 62 // if this type does not support positioning.
64 SYNC_EXPORT UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update, 63 SYNC_EXPORT UniquePosition GetUpdatePosition(const sync_pb::SyncEntity& update,
65 const std::string& suffix); 64 const std::string& suffix);
66 65
67 // Fetch the cache_guid and item_id-based unique bookmark tag from an update. 66 // Fetch the cache_guid and item_id-based unique bookmark tag from an update.
68 // Will return an empty string if someting unexpected happens. 67 // Will return an empty string if someting unexpected happens.
69 SYNC_EXPORT std::string GetUniqueBookmarkTagFromUpdate( 68 SYNC_EXPORT std::string GetUniqueBookmarkTagFromUpdate(
70 const sync_pb::SyncEntity& update); 69 const sync_pb::SyncEntity& update);
71 70
72 // Pass in name to avoid redundant UTF8 conversion. 71 // Pass in name to avoid redundant UTF8 conversion.
73 SYNC_EXPORT void UpdateServerFieldsFromUpdate( 72 SYNC_EXPORT void UpdateServerFieldsFromUpdate(
74 syncable::ModelNeutralMutableEntry* local_entry, 73 syncable::ModelNeutralMutableEntry* local_entry,
75 const sync_pb::SyncEntity& server_entry, 74 const sync_pb::SyncEntity& server_entry,
76 const std::string& name); 75 const std::string& name);
77 76
78 // Creates a new Entry iff no Entry exists with the given id. 77 // Creates a new Entry iff no Entry exists with the given id.
79 void CreateNewEntry(syncable::ModelNeutralWriteTransaction *trans, 78 void CreateNewEntry(syncable::ModelNeutralWriteTransaction* trans,
80 const syncable::Id& id); 79 const syncable::Id& id);
81 80
82 // This function is called on an entry when we can update the user-facing data 81 // This function is called on an entry when we can update the user-facing data
83 // from the server data. 82 // from the server data.
84 void UpdateLocalDataFromServerData(syncable::WriteTransaction* trans, 83 void UpdateLocalDataFromServerData(syncable::WriteTransaction* trans,
85 syncable::MutableEntry* entry); 84 syncable::MutableEntry* entry);
86 85
87 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry); 86 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry);
88 87
89 VerifyResult VerifyNewEntry(const sync_pb::SyncEntity& update, 88 VerifyResult VerifyNewEntry(const sync_pb::SyncEntity& update,
90 syncable::Entry* target, 89 syncable::Entry* target,
91 const bool deleted); 90 const bool deleted);
92 91
93 // Assumes we have an existing entry; check here for updates that break 92 // Assumes we have an existing entry; check here for updates that break
94 // consistency rules. 93 // consistency rules.
95 VerifyResult VerifyUpdateConsistency( 94 VerifyResult VerifyUpdateConsistency(
96 syncable::ModelNeutralWriteTransaction* trans, 95 syncable::ModelNeutralWriteTransaction* trans,
97 const sync_pb::SyncEntity& update, 96 const sync_pb::SyncEntity& update,
98 const bool deleted, 97 const bool deleted,
99 const bool is_directory, 98 const bool is_directory,
100 ModelType model_type, 99 ModelType model_type,
101 syncable::ModelNeutralMutableEntry* target); 100 syncable::ModelNeutralMutableEntry* target);
102 101
103 // Assumes we have an existing entry; verify an update that seems to be 102 // Assumes we have an existing entry; verify an update that seems to be
104 // expressing an 'undelete' 103 // expressing an 'undelete'
105 VerifyResult VerifyUndelete(syncable::ModelNeutralWriteTransaction* trans, 104 VerifyResult VerifyUndelete(syncable::ModelNeutralWriteTransaction* trans,
106 const sync_pb::SyncEntity& update, 105 const sync_pb::SyncEntity& update,
107 syncable::ModelNeutralMutableEntry* target); 106 syncable::ModelNeutralMutableEntry* target);
108 107
109 void MarkDeletedChildrenSynced( 108 void MarkDeletedChildrenSynced(syncable::Directory* dir,
110 syncable::Directory* dir, 109 syncable::BaseWriteTransaction* trans,
111 syncable::BaseWriteTransaction* trans, 110 std::set<syncable::Id>* deleted_folders);
112 std::set<syncable::Id>* deleted_folders);
113 111
114 } // namespace syncer 112 } // namespace syncer
115 113
116 #endif // SYNC_ENGINE_SYNCER_UTIL_H_ 114 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_UTIL_H_
OLDNEW
« no previous file with comments | « components/sync/engine_impl/syncer_unittest.cc ('k') | components/sync/engine_impl/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698