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

Side by Side Diff: sync/engine/syncer_util.h

Issue 10735041: Remove syncproto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address most comments Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sync/engine/syncer_unittest.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SYNC_ENGINE_SYNCER_UTIL_H_
9 #define SYNC_ENGINE_SYNCER_UTIL_H_ 9 #define SYNC_ENGINE_SYNCER_UTIL_H_
10 10
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "sync/engine/syncer.h" 15 #include "sync/engine/syncer.h"
16 #include "sync/engine/syncer_types.h" 16 #include "sync/engine/syncer_types.h"
17 #include "sync/syncable/entry_kernel.h" 17 #include "sync/syncable/entry_kernel.h"
18 #include "sync/syncable/metahandle_set.h" 18 #include "sync/syncable/metahandle_set.h"
19 #include "sync/syncable/syncable_id.h" 19 #include "sync/syncable/syncable_id.h"
20 20
21 namespace sync_pb {
22 class SyncEntity;
23 }
24
21 namespace syncer { 25 namespace syncer {
22
23 class Cryptographer; 26 class Cryptographer;
24 class SyncEntity;
25 27
26 // If the server sent down a client-tagged entry, or an entry whose 28 // If the server sent down a client-tagged entry, or an entry whose
27 // commit response was lost, it is necessary to update a local entry 29 // commit response was lost, it is necessary to update a local entry
28 // with an ID that doesn't match the ID of the update. Here, we 30 // with an ID that doesn't match the ID of the update. Here, we
29 // find the ID of such an entry, if it exists. This function may 31 // find the ID of such an entry, if it exists. This function may
30 // determine that |server_entry| should be dropped; if so, it returns 32 // determine that |server_entry| should be dropped; if so, it returns
31 // the null ID -- callers must handle this case. When update application 33 // the null ID -- callers must handle this case. When update application
32 // should proceed normally with a new local entry, this function will 34 // should proceed normally with a new local entry, this function will
33 // return server_entry.id(); the caller must create an entry with that 35 // return server_entry.id(); the caller must create an entry with that
34 // ID. This function does not alter the database. 36 // ID. This function does not alter the database.
35 syncable::Id FindLocalIdToUpdate( 37 syncable::Id FindLocalIdToUpdate(
36 syncable::BaseTransaction* trans, 38 syncable::BaseTransaction* trans,
37 const SyncEntity& server_entry); 39 const sync_pb::SyncEntity& server_entry);
38 40
39 UpdateAttemptResponse AttemptToUpdateEntry( 41 UpdateAttemptResponse AttemptToUpdateEntry(
40 syncable::WriteTransaction* const trans, 42 syncable::WriteTransaction* const trans,
41 syncable::MutableEntry* const entry, 43 syncable::MutableEntry* const entry,
42 ConflictResolver* resolver, 44 ConflictResolver* resolver,
43 Cryptographer* cryptographer); 45 Cryptographer* cryptographer);
44 46
45 // Pass in name to avoid redundant UTF8 conversion. 47 // Pass in name to avoid redundant UTF8 conversion.
46 void UpdateServerFieldsFromUpdate( 48 void UpdateServerFieldsFromUpdate(
47 syncable::MutableEntry* local_entry, 49 syncable::MutableEntry* local_entry,
48 const SyncEntity& server_entry, 50 const sync_pb::SyncEntity& server_entry,
49 const std::string& name); 51 const std::string& name);
50 52
51 // Creates a new Entry iff no Entry exists with the given id. 53 // Creates a new Entry iff no Entry exists with the given id.
52 void CreateNewEntry(syncable::WriteTransaction *trans, 54 void CreateNewEntry(syncable::WriteTransaction *trans,
53 const syncable::Id& id); 55 const syncable::Id& id);
54 56
55 void SplitServerInformationIntoNewEntry( 57 void SplitServerInformationIntoNewEntry(
56 syncable::WriteTransaction* trans, 58 syncable::WriteTransaction* trans,
57 syncable::MutableEntry* entry); 59 syncable::MutableEntry* entry);
58 60
59 // This function is called on an entry when we can update the user-facing data 61 // This function is called on an entry when we can update the user-facing data
60 // from the server data. 62 // from the server data.
61 void UpdateLocalDataFromServerData(syncable::WriteTransaction* trans, 63 void UpdateLocalDataFromServerData(syncable::WriteTransaction* trans,
62 syncable::MutableEntry* entry); 64 syncable::MutableEntry* entry);
63 65
64 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry); 66 VerifyCommitResult ValidateCommitEntry(syncable::Entry* entry);
65 67
66 VerifyResult VerifyNewEntry(const SyncEntity& update, 68 VerifyResult VerifyNewEntry(const sync_pb::SyncEntity& update,
67 syncable::Entry* target, 69 syncable::Entry* target,
68 const bool deleted); 70 const bool deleted);
69 71
70 // Assumes we have an existing entry; check here for updates that break 72 // Assumes we have an existing entry; check here for updates that break
71 // consistency rules. 73 // consistency rules.
72 VerifyResult VerifyUpdateConsistency(syncable::WriteTransaction* trans, 74 VerifyResult VerifyUpdateConsistency(syncable::WriteTransaction* trans,
73 const SyncEntity& update, 75 const sync_pb::SyncEntity& update,
74 syncable::MutableEntry* target, 76 syncable::MutableEntry* target,
75 const bool deleted, 77 const bool deleted,
76 const bool is_directory, 78 const bool is_directory,
77 syncer::ModelType model_type); 79 syncer::ModelType model_type);
78 80
79 // Assumes we have an existing entry; verify an update that seems to be 81 // Assumes we have an existing entry; verify an update that seems to be
80 // expressing an 'undelete' 82 // expressing an 'undelete'
81 VerifyResult VerifyUndelete(syncable::WriteTransaction* trans, 83 VerifyResult VerifyUndelete(syncable::WriteTransaction* trans,
82 const SyncEntity& update, 84 const sync_pb::SyncEntity& update,
83 syncable::MutableEntry* target); 85 syncable::MutableEntry* target);
84 86
85 // Append |item|, followed by a chain of its predecessors selected by 87 // Append |item|, followed by a chain of its predecessors selected by
86 // |inclusion_filter|, to the |commit_ids| vector and tag them as included by 88 // |inclusion_filter|, to the |commit_ids| vector and tag them as included by
87 // storing in the set |inserted_items|. |inclusion_filter| (typically one of 89 // storing in the set |inserted_items|. |inclusion_filter| (typically one of
88 // IS_UNAPPLIED_UPDATE or IS_UNSYNCED) selects which type of predecessors to 90 // IS_UNAPPLIED_UPDATE or IS_UNSYNCED) selects which type of predecessors to
89 // include. Returns true if |item| was added, and false if it was already in 91 // include. Returns true if |item| was added, and false if it was already in
90 // the list. 92 // the list.
91 // 93 //
92 // Use AddPredecessorsThenItem instead of this method if you want the 94 // Use AddPredecessorsThenItem instead of this method if you want the
(...skipping 15 matching lines...) Expand all
108 syncable::MetahandleSet* inserted_items, 110 syncable::MetahandleSet* inserted_items,
109 std::vector<syncable::Id>* commit_ids); 111 std::vector<syncable::Id>* commit_ids);
110 112
111 void MarkDeletedChildrenSynced( 113 void MarkDeletedChildrenSynced(
112 syncable::Directory* dir, 114 syncable::Directory* dir,
113 std::set<syncable::Id>* deleted_folders); 115 std::set<syncable::Id>* deleted_folders);
114 116
115 } // namespace syncer 117 } // namespace syncer
116 118
117 #endif // SYNC_ENGINE_SYNCER_UTIL_H_ 119 #endif // SYNC_ENGINE_SYNCER_UTIL_H_
OLDNEW
« no previous file with comments | « sync/engine/syncer_unittest.cc ('k') | sync/engine/syncer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698