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

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

Issue 25638003: sync: Implement per-type commit interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempt to fix win compile Created 7 years, 2 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/get_commit_ids.cc ('k') | sync/engine/process_commit_response_command.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
6 #define SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
7
8 #include <set>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "sync/base/sync_export.h"
14 #include "sync/engine/syncer_command.h"
15 #include "sync/protocol/sync.pb.h"
16
17 namespace syncer {
18
19 namespace sessions {
20 class OrderedCommitSet;
21 }
22
23 namespace syncable {
24 class Id;
25 class ModelNeutralWriteTransaction;
26 class ModelNeutralMutableEntry;
27 class Directory;
28 }
29
30 // A class that processes the server's response to our commmit attempt. Note
31 // that some of the preliminary processing is performed in
32 // PostClientToServerMessage command.
33 //
34 // As part of processing the commit response, this command will modify sync
35 // entries. It can change their IDs, update their versions, etc.
36 //
37 // This command will return a non-SYNCER_OK value if an error occurred while
38 // processing the response, or if the server's response indicates that it had
39 // trouble processing the request.
40 //
41 // See SyncerCommand documentation for more info.
42 class SYNC_EXPORT_PRIVATE ProcessCommitResponseCommand : public SyncerCommand {
43 public:
44
45 // The commit_set parameter contains references to all the items which were
46 // to be committed in this batch.
47 //
48 // The commmit_message parameter contains the message that was sent to the
49 // server.
50 //
51 // The commit_response parameter contains the response received from the
52 // server. This may be uninitialized if we were unable to contact the server
53 // or a serious error was encountered.
54 ProcessCommitResponseCommand(
55 const sessions::OrderedCommitSet& commit_set,
56 const sync_pb::ClientToServerMessage& commit_message,
57 const sync_pb::ClientToServerResponse& commit_response);
58 virtual ~ProcessCommitResponseCommand();
59
60 protected:
61 // SyncerCommand implementation.
62 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
63
64 private:
65 sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
66 syncable::ModelNeutralWriteTransaction* trans,
67 const sync_pb::CommitResponse_EntryResponse& pb_commit_response,
68 const sync_pb::SyncEntity& pb_committed_entry,
69 int64 metahandle,
70 std::set<syncable::Id>* deleted_folders);
71
72 void ProcessSuccessfulCommitResponse(
73 const sync_pb::SyncEntity& committed_entry,
74 const sync_pb::CommitResponse_EntryResponse& entry_response,
75 const syncable::Id& pre_commit_id,
76 syncable::ModelNeutralMutableEntry* local_entry,
77 bool syncing_was_set, std::set<syncable::Id>* deleted_folders);
78
79 // Update the BASE_VERSION and SERVER_VERSION, post-commit.
80 // Helper for ProcessSuccessfulCommitResponse.
81 bool UpdateVersionAfterCommit(
82 const sync_pb::SyncEntity& committed_entry,
83 const sync_pb::CommitResponse_EntryResponse& entry_response,
84 const syncable::Id& pre_commit_id,
85 syncable::ModelNeutralMutableEntry* local_entry);
86
87 // If the server generated an ID for us during a commit, apply the new ID.
88 // Helper for ProcessSuccessfulCommitResponse.
89 bool ChangeIdAfterCommit(
90 const sync_pb::CommitResponse_EntryResponse& entry_response,
91 const syncable::Id& pre_commit_id,
92 syncable::ModelNeutralMutableEntry* local_entry);
93
94 // Update the SERVER_ fields to reflect the server state after committing.
95 // Helper for ProcessSuccessfulCommitResponse.
96 void UpdateServerFieldsAfterCommit(
97 const sync_pb::SyncEntity& committed_entry,
98 const sync_pb::CommitResponse_EntryResponse& entry_response,
99 syncable::ModelNeutralMutableEntry* local_entry);
100
101 // Helper to extract the final name from the protobufs.
102 const std::string& GetResultingPostCommitName(
103 const sync_pb::SyncEntity& committed_entry,
104 const sync_pb::CommitResponse_EntryResponse& entry_response);
105
106 // Helper to clean up in case of failure.
107 void ClearSyncingBits(
108 syncable::Directory *dir,
109 const std::vector<syncable::Id>& commit_ids);
110
111 const sessions::OrderedCommitSet& commit_set_;
112 const sync_pb::ClientToServerMessage& commit_message_;
113 const sync_pb::ClientToServerResponse& commit_response_;
114
115 DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand);
116 };
117
118 } // namespace syncer
119
120 #endif // SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
OLDNEW
« no previous file with comments | « sync/engine/get_commit_ids.cc ('k') | sync/engine/process_commit_response_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698