Add tests to verify accelerators properly work on constrained window.
[chromium-blink-merge.git] / sync / engine / build_commit_command.h
blobb4190ca8454ebb2d34a5f8c0cdb15ced6de950a1
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.
5 #ifndef SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
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"
15 namespace syncer {
17 namespace sessions {
18 class OrderedCommitSet;
21 namespace syncable {
22 class Entry;
25 // A class that contains the code used to serialize a set of sync items into a
26 // protobuf commit message. This conversion process references the
27 // syncable::Directory, which is why it must be called within the same
28 // transaction as the GetCommitIdsCommand that fetched the set of items to be
29 // committed.
31 // See SyncerCommand documentation for more info.
32 class SYNC_EXPORT_PRIVATE BuildCommitCommand : public SyncerCommand {
33 public:
34 // The batch_commit_set parameter contains a set of references to the items
35 // that should be committed.
37 // The commit_message parameter is an output parameter which will contain the
38 // fully initialized commit message once ExecuteImpl() has been called.
39 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set,
40 sync_pb::ClientToServerMessage* commit_message);
41 virtual ~BuildCommitCommand();
43 // SyncerCommand implementation.
44 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
46 private:
47 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition);
49 // Functions returning constants controlling range of values.
50 static int64 GetFirstPosition();
51 static int64 GetLastPosition();
52 static int64 GetGap();
54 void AddExtensionsActivityToMessage(sessions::SyncSession* session,
55 sync_pb::CommitMessage* message);
56 // Helper for computing position. Find the numeric position value
57 // of the closest already-synced entry. |direction| must be one of
58 // NEXT_ID or PREV_ID; this parameter controls the search direction.
59 // For an open range (no predecessor or successor), the return
60 // value will be kFirstPosition or kLastPosition.
61 int64 FindAnchorPosition(syncable::IdField direction,
62 const syncable::Entry& entry);
63 // Given two values of the type returned by FindAnchorPosition,
64 // compute a third value in between the two ranges.
65 int64 InterpolatePosition(int64 lo, int64 hi);
67 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand);
69 // Input parameter; see constructor comment.
70 const sessions::OrderedCommitSet& batch_commit_set_;
72 // Output parameter; see constructor comment.
73 sync_pb::ClientToServerMessage* commit_message_;
76 } // namespace syncer
78 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_