Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 11 | #include "sync/base/sync_export.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | #include "sync/engine/syncer_command.h" |
| 13 | #include "sync/syncable/entry_kernel.h" |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 14 | #include "sync/util/extensions_activity.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 15 | |
| 16 | namespace syncer { |
| 17 | |
| 18 | namespace sessions { |
| 19 | class OrderedCommitSet; |
| 20 | } |
| 21 | |
| 22 | namespace syncable { |
| 23 | class Entry; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 24 | class BaseTransaction; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 34 | class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand { |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 41 | BuildCommitCommand( |
| 42 | syncable::BaseTransaction* trans, |
| 43 | const sessions::OrderedCommitSet& batch_commit_set, |
| 44 | sync_pb::ClientToServerMessage* commit_message, |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 45 | ExtensionsActivity::Records* extensions_activity_buffer); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 46 | virtual ~BuildCommitCommand(); |
| 47 | |
| 48 | // SyncerCommand implementation. |
| 49 | virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; |
| 50 | |
| 51 | private: |
| 52 | FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); |
| 53 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 54 | void AddExtensionsActivityToMessage(sessions::SyncSession* session, |
| 55 | sync_pb::CommitMessage* message); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 56 | |
| 57 | // Fills the config_params field of |message|. |
| 58 | void AddClientConfigParamsToMessage(sessions::SyncSession* session, |
| 59 | sync_pb::CommitMessage* message); |
| 60 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); |
| 62 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 63 | // A pointer to a valid transaction not owned by this class. |
| 64 | syncable::BaseTransaction* trans_; |
| 65 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 66 | // Input parameter; see constructor comment. |
| 67 | const sessions::OrderedCommitSet& batch_commit_set_; |
| 68 | |
| 69 | // Output parameter; see constructor comment. |
| 70 | sync_pb::ClientToServerMessage* commit_message_; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 71 | |
Torne (Richard Coles) | a36e592 | 2013-08-05 13:57:33 +0100 | [diff] [blame] | 72 | ExtensionsActivity::Records* extensions_activity_buffer_; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace syncer |
| 76 | |
| 77 | #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |