| OLD | NEW |
| (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_BUILD_COMMIT_COMMAND_H_ | |
| 6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "sync/base/sync_export.h" | |
| 12 #include "sync/engine/syncer_command.h" | |
| 13 #include "sync/syncable/entry_kernel.h" | |
| 14 #include "sync/util/extensions_activity.h" | |
| 15 | |
| 16 namespace syncer { | |
| 17 | |
| 18 namespace sessions { | |
| 19 class OrderedCommitSet; | |
| 20 } | |
| 21 | |
| 22 namespace syncable { | |
| 23 class Entry; | |
| 24 class BaseTransaction; | |
| 25 } | |
| 26 | |
| 27 // A class that contains the code used to serialize a set of sync items into a | |
| 28 // protobuf commit message. This conversion process references the | |
| 29 // syncable::Directory, which is why it must be called within the same | |
| 30 // transaction as the GetCommitIdsCommand that fetched the set of items to be | |
| 31 // committed. | |
| 32 // | |
| 33 // See SyncerCommand documentation for more info. | |
| 34 class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand { | |
| 35 public: | |
| 36 // The batch_commit_set parameter contains a set of references to the items | |
| 37 // that should be committed. | |
| 38 // | |
| 39 // The commit_message parameter is an output parameter which will contain the | |
| 40 // fully initialized commit message once ExecuteImpl() has been called. | |
| 41 BuildCommitCommand( | |
| 42 syncable::BaseTransaction* trans, | |
| 43 const sessions::OrderedCommitSet& batch_commit_set, | |
| 44 sync_pb::ClientToServerMessage* commit_message, | |
| 45 ExtensionsActivity::Records* extensions_activity_buffer); | |
| 46 virtual ~BuildCommitCommand(); | |
| 47 | |
| 48 // SyncerCommand implementation. | |
| 49 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; | |
| 50 | |
| 51 // Helper function that takes a snapshot of |meta_entry| and puts it into a | |
| 52 // protobuf suitable for use in a commit request message. | |
| 53 static void BuildCommitItem(const syncable::Entry& meta_entry, | |
| 54 sync_pb::SyncEntity* sync_entry); | |
| 55 | |
| 56 private: | |
| 57 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); | |
| 58 | |
| 59 void AddExtensionsActivityToMessage(sessions::SyncSession* session, | |
| 60 sync_pb::CommitMessage* message); | |
| 61 | |
| 62 // Fills the config_params field of |message|. | |
| 63 void AddClientConfigParamsToMessage(sessions::SyncSession* session, | |
| 64 sync_pb::CommitMessage* message); | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); | |
| 67 | |
| 68 // A pointer to a valid transaction not owned by this class. | |
| 69 syncable::BaseTransaction* trans_; | |
| 70 | |
| 71 // Input parameter; see constructor comment. | |
| 72 const sessions::OrderedCommitSet& batch_commit_set_; | |
| 73 | |
| 74 // Output parameter; see constructor comment. | |
| 75 sync_pb::ClientToServerMessage* commit_message_; | |
| 76 | |
| 77 ExtensionsActivity::Records* extensions_activity_buffer_; | |
| 78 }; | |
| 79 | |
| 80 } // namespace syncer | |
| 81 | |
| 82 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | |
| OLD | NEW |