| 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 #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/engine/syncproto.h" |
| 16 | 16 |
| 17 namespace syncable { | 17 namespace syncable { |
| 18 class Id; | 18 class Id; |
| 19 class WriteTransaction; | 19 class WriteTransaction; |
| 20 class MutableEntry; | 20 class MutableEntry; |
| 21 class Directory; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace browser_sync { | 24 namespace browser_sync { |
| 24 | 25 |
| 26 namespace sessions { |
| 27 class OrderedCommitSet; |
| 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 rename items, 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. |
| 25 class ProcessCommitResponseCommand : public ModelChangingSyncerCommand { | 42 class ProcessCommitResponseCommand : public ModelChangingSyncerCommand { |
| 26 public: | 43 public: |
| 27 | 44 |
| 28 ProcessCommitResponseCommand(); | 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 ClientToServerMessage& commit_message, |
| 57 const ClientToServerResponse& commit_response); |
| 29 virtual ~ProcessCommitResponseCommand(); | 58 virtual ~ProcessCommitResponseCommand(); |
| 30 | 59 |
| 31 protected: | 60 protected: |
| 32 // ModelChangingSyncerCommand implementation. | 61 // ModelChangingSyncerCommand implementation. |
| 33 virtual std::set<ModelSafeGroup> GetGroupsToChange( | 62 virtual std::set<ModelSafeGroup> GetGroupsToChange( |
| 34 const sessions::SyncSession& session) const OVERRIDE; | 63 const sessions::SyncSession& session) const OVERRIDE; |
| 35 virtual SyncerError ModelNeutralExecuteImpl( | 64 virtual SyncerError ModelNeutralExecuteImpl( |
| 36 sessions::SyncSession* session) OVERRIDE; | 65 sessions::SyncSession* session) OVERRIDE; |
| 37 virtual SyncerError ModelChangingExecuteImpl( | 66 virtual SyncerError ModelChangingExecuteImpl( |
| 38 sessions::SyncSession* session) OVERRIDE; | 67 sessions::SyncSession* session) OVERRIDE; |
| 39 | 68 |
| 40 private: | 69 private: |
| 41 CommitResponse::ResponseType ProcessSingleCommitResponse( | 70 CommitResponse::ResponseType ProcessSingleCommitResponse( |
| 42 syncable::WriteTransaction* trans, | 71 syncable::WriteTransaction* trans, |
| 43 const sync_pb::CommitResponse_EntryResponse& pb_commit_response, | 72 const sync_pb::CommitResponse_EntryResponse& pb_commit_response, |
| 44 const sync_pb::SyncEntity& pb_committed_entry, | 73 const sync_pb::SyncEntity& pb_committed_entry, |
| 45 const syncable::Id& pre_commit_id, | 74 const syncable::Id& pre_commit_id, |
| 46 std::set<syncable::Id>* conflicting_new_directory_ids, | |
| 47 std::set<syncable::Id>* deleted_folders); | 75 std::set<syncable::Id>* deleted_folders); |
| 48 | 76 |
| 49 // Actually does the work of execute. | 77 // Actually does the work of execute. |
| 50 SyncerError ProcessCommitResponse(sessions::SyncSession* session); | 78 SyncerError ProcessCommitResponse(sessions::SyncSession* session); |
| 51 | 79 |
| 52 void ProcessSuccessfulCommitResponse( | 80 void ProcessSuccessfulCommitResponse( |
| 53 const sync_pb::SyncEntity& committed_entry, | 81 const sync_pb::SyncEntity& committed_entry, |
| 54 const CommitResponse_EntryResponse& entry_response, | 82 const CommitResponse_EntryResponse& entry_response, |
| 55 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, | 83 const syncable::Id& pre_commit_id, syncable::MutableEntry* local_entry, |
| 56 bool syncing_was_set, std::set<syncable::Id>* deleted_folders); | 84 bool syncing_was_set, std::set<syncable::Id>* deleted_folders); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 void OverrideClientFieldsAfterCommit( | 114 void OverrideClientFieldsAfterCommit( |
| 87 const sync_pb::SyncEntity& committed_entry, | 115 const sync_pb::SyncEntity& committed_entry, |
| 88 const CommitResponse_EntryResponse& entry_response, | 116 const CommitResponse_EntryResponse& entry_response, |
| 89 syncable::MutableEntry* local_entry); | 117 syncable::MutableEntry* local_entry); |
| 90 | 118 |
| 91 // Helper to extract the final name from the protobufs. | 119 // Helper to extract the final name from the protobufs. |
| 92 const std::string& GetResultingPostCommitName( | 120 const std::string& GetResultingPostCommitName( |
| 93 const sync_pb::SyncEntity& committed_entry, | 121 const sync_pb::SyncEntity& committed_entry, |
| 94 const CommitResponse_EntryResponse& entry_response); | 122 const CommitResponse_EntryResponse& entry_response); |
| 95 | 123 |
| 124 // Helper to clean up in case of failure. |
| 125 void ClearSyncingBits( |
| 126 syncable::Directory *dir, |
| 127 const std::vector<syncable::Id>& commit_ids); |
| 128 |
| 129 const sessions::OrderedCommitSet& commit_set_; |
| 130 const ClientToServerMessage& commit_message_; |
| 131 const ClientToServerResponse& commit_response_; |
| 132 |
| 96 DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand); | 133 DISALLOW_COPY_AND_ASSIGN(ProcessCommitResponseCommand); |
| 97 }; | 134 }; |
| 98 | 135 |
| 99 } // namespace browser_sync | 136 } // namespace browser_sync |
| 100 | 137 |
| 101 #endif // SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_ | 138 #endif // SYNC_ENGINE_PROCESS_COMMIT_RESPONSE_COMMAND_H_ |
| OLD | NEW |