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

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

Issue 10735041: Remove syncproto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve DCHECKing, fix tests 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
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 #ifndef SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_ 5 #ifndef SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
6 #define SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_ 6 #define SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "sync/engine/model_changing_syncer_command.h" 14 #include "sync/engine/model_changing_syncer_command.h"
15 #include "sync/engine/syncproto.h" 15 #include "sync/protocol/sync.pb.h"
16 16
17 namespace syncer { 17 namespace syncer {
18 18
19 namespace sessions { 19 namespace sessions {
20 class OrderedCommitSet; 20 class OrderedCommitSet;
21 } 21 }
22 22
23 namespace syncable { 23 namespace syncable {
24 class Id; 24 class Id;
25 class WriteTransaction; 25 class WriteTransaction;
(...skipping 20 matching lines...) Expand all
46 // to be committed in this batch. 46 // to be committed in this batch.
47 // 47 //
48 // The commmit_message parameter contains the message that was sent to the 48 // The commmit_message parameter contains the message that was sent to the
49 // server. 49 // server.
50 // 50 //
51 // The commit_response parameter contains the response received from the 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 52 // server. This may be uninitialized if we were unable to contact the server
53 // or a serious error was encountered. 53 // or a serious error was encountered.
54 ProcessCommitResponseCommand( 54 ProcessCommitResponseCommand(
55 const sessions::OrderedCommitSet& commit_set, 55 const sessions::OrderedCommitSet& commit_set,
56 const ClientToServerMessage& commit_message, 56 const sync_pb::ClientToServerMessage& commit_message,
57 const ClientToServerResponse& commit_response); 57 const sync_pb::ClientToServerResponse& commit_response);
58 virtual ~ProcessCommitResponseCommand(); 58 virtual ~ProcessCommitResponseCommand();
59 59
60 protected: 60 protected:
61 // ModelChangingSyncerCommand implementation. 61 // ModelChangingSyncerCommand implementation.
62 virtual std::set<ModelSafeGroup> GetGroupsToChange( 62 virtual std::set<ModelSafeGroup> GetGroupsToChange(
63 const sessions::SyncSession& session) const OVERRIDE; 63 const sessions::SyncSession& session) const OVERRIDE;
64 virtual SyncerError ModelChangingExecuteImpl( 64 virtual SyncerError ModelChangingExecuteImpl(
65 sessions::SyncSession* session) OVERRIDE; 65 sessions::SyncSession* session) OVERRIDE;
66 66
67 private: 67 private:
68 CommitResponse::ResponseType ProcessSingleCommitResponse( 68 sync_pb::CommitResponse::ResponseType ProcessSingleCommitResponse(
69 syncable::WriteTransaction* trans, 69 syncable::WriteTransaction* trans,
70 const sync_pb::CommitResponse_EntryResponse& pb_commit_response, 70 const sync_pb::CommitResponse_EntryResponse& pb_commit_response,
71 const sync_pb::SyncEntity& pb_committed_entry, 71 const sync_pb::SyncEntity& pb_committed_entry,
72 const syncable::Id& pre_commit_id, 72 const syncable::Id& pre_commit_id,
73 std::set<syncable::Id>* deleted_folders); 73 std::set<syncable::Id>* deleted_folders);
74 74
75 // Actually does the work of execute. 75 // Actually does the work of execute.
76 SyncerError ProcessCommitResponse(sessions::SyncSession* session); 76 SyncerError ProcessCommitResponse(sessions::SyncSession* session);
77 77
78 void ProcessSuccessfulCommitResponse( 78 void ProcessSuccessfulCommitResponse(
79 const sync_pb::SyncEntity& committed_entry, 79 const sync_pb::SyncEntity& committed_entry,
80 const CommitResponse_EntryResponse& entry_response, 80 const sync_pb::CommitResponse_EntryResponse& entry_response,
81 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, 81 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry,
82 bool syncing_was_set, std::set<syncable::Id>* deleted_folders); 82 bool syncing_was_set, std::set<syncable::Id>* deleted_folders);
83 83
84 // Update the BASE_VERSION and SERVER_VERSION, post-commit. 84 // Update the BASE_VERSION and SERVER_VERSION, post-commit.
85 // Helper for ProcessSuccessfulCommitResponse. 85 // Helper for ProcessSuccessfulCommitResponse.
86 bool UpdateVersionAfterCommit( 86 bool UpdateVersionAfterCommit(
87 const sync_pb::SyncEntity& committed_entry, 87 const sync_pb::SyncEntity& committed_entry,
88 const CommitResponse_EntryResponse& entry_response, 88 const sync_pb::CommitResponse_EntryResponse& entry_response,
89 const syncable::Id& pre_commit_id, 89 const syncable::Id& pre_commit_id,
90 syncable::MutableEntry* local_entry); 90 syncable::MutableEntry* local_entry);
91 91
92 // If the server generated an ID for us during a commit, apply the new ID. 92 // If the server generated an ID for us during a commit, apply the new ID.
93 // Helper for ProcessSuccessfulCommitResponse. 93 // Helper for ProcessSuccessfulCommitResponse.
94 bool ChangeIdAfterCommit( 94 bool ChangeIdAfterCommit(
95 const CommitResponse_EntryResponse& entry_response, 95 const sync_pb::CommitResponse_EntryResponse& entry_response,
96 const syncable::Id& pre_commit_id, 96 const syncable::Id& pre_commit_id,
97 syncable::MutableEntry* local_entry); 97 syncable::MutableEntry* local_entry);
98 98
99 // Update the SERVER_ fields to reflect the server state after committing. 99 // Update the SERVER_ fields to reflect the server state after committing.
100 // Helper for ProcessSuccessfulCommitResponse. 100 // Helper for ProcessSuccessfulCommitResponse.
101 void UpdateServerFieldsAfterCommit( 101 void UpdateServerFieldsAfterCommit(
102 const sync_pb::SyncEntity& committed_entry, 102 const sync_pb::SyncEntity& committed_entry,
103 const CommitResponse_EntryResponse& entry_response, 103 const sync_pb::CommitResponse_EntryResponse& entry_response,
104 syncable::MutableEntry* local_entry); 104 syncable::MutableEntry* local_entry);
105 105
106 // The server can override some values during a commit; the overridden values 106 // The server can override some values during a commit; the overridden values
107 // are returned as fields in the CommitResponse_EntryResponse. This method 107 // are returned as fields in the CommitResponse_EntryResponse. This method
108 // stores the fields back in the client-visible (i.e. not the SERVER_* fields) 108 // stores the fields back in the client-visible (i.e. not the SERVER_* fields)
109 // fields of the entry. This should only be done if the item did not change 109 // fields of the entry. This should only be done if the item did not change
110 // locally while the commit was in flight. 110 // locally while the commit was in flight.
111 // Helper for ProcessSuccessfulCommitResponse. 111 // Helper for ProcessSuccessfulCommitResponse.
112 void OverrideClientFieldsAfterCommit( 112 void OverrideClientFieldsAfterCommit(
113 const sync_pb::SyncEntity& committed_entry, 113 const sync_pb::SyncEntity& committed_entry,
114 const CommitResponse_EntryResponse& entry_response, 114 const sync_pb::CommitResponse_EntryResponse& entry_response,
115 syncable::MutableEntry* local_entry); 115 syncable::MutableEntry* local_entry);
116 116
117 // Helper to extract the final name from the protobufs. 117 // Helper to extract the final name from the protobufs.
118 const std::string& GetResultingPostCommitName( 118 const std::string& GetResultingPostCommitName(
119 const sync_pb::SyncEntity& committed_entry, 119 const sync_pb::SyncEntity& committed_entry,
120 const CommitResponse_EntryResponse& entry_response); 120 const sync_pb::CommitResponse_EntryResponse& entry_response);
121 121
122 // Helper to clean up in case of failure. 122 // Helper to clean up in case of failure.
123 void ClearSyncingBits( 123 void ClearSyncingBits(
124 syncable::Directory *dir, 124 syncable::Directory *dir,
125 const std::vector<syncable::Id>& commit_ids); 125 const std::vector<syncable::Id>& commit_ids);
126 126
127 const sessions::OrderedCommitSet& commit_set_; 127 const sessions::OrderedCommitSet& commit_set_;
128 const ClientToServerMessage& commit_message_; 128 const sync_pb::ClientToServerMessage& commit_message_;
129 const ClientToServerResponse& commit_response_; 129 const sync_pb::ClientToServerResponse& commit_response_;
130 130
131 DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand); 131 DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand);
132 }; 132 };
133 133
134 } // namespace syncer 134 } // namespace syncer
135 135
136 #endif // SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_ 136 #endif // SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698