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_BUILD_COMMIT_COMMAND_H_ | 5 #ifndef SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | 6 #define SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set, | 38 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set, |
39 sync_pb::ClientToServerMessage* commit_message); | 39 sync_pb::ClientToServerMessage* commit_message); |
40 virtual ~BuildCommitCommand(); | 40 virtual ~BuildCommitCommand(); |
41 | 41 |
42 // SyncerCommand implementation. | 42 // SyncerCommand implementation. |
43 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; | 43 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; |
44 | 44 |
45 private: | 45 private: |
46 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); | 46 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); |
47 | 47 |
48 // Functions returning constants controlling range of values. | |
49 static int64 GetFirstPosition(); | |
50 static int64 GetLastPosition(); | |
51 static int64 GetGap(); | |
52 | |
53 void AddExtensionsActivityToMessage(sessions::SyncSession* session, | 48 void AddExtensionsActivityToMessage(sessions::SyncSession* session, |
54 sync_pb::CommitMessage* message); | 49 sync_pb::CommitMessage* message); |
55 // Helper for computing position. Find the numeric position value | 50 // Helper for computing position. Find the numeric position value |
56 // of the closest already-synced entry. |direction| must be one of | 51 // of the closest already-synced entry. |direction| must be one of |
57 // NEXT_ID or PREV_ID; this parameter controls the search direction. | 52 // NEXT_ID or PREV_ID; this parameter controls the search direction. |
58 // For an open range (no predecessor or successor), the return | 53 // For an open range (no predecessor or successor), the return |
59 // value will be kFirstPosition or kLastPosition. | 54 // value will be kFirstPosition or kLastPosition. |
60 int64 FindAnchorPosition(syncable::IdField direction, | 55 int64 FindAnchorPosition(syncable::IdField direction, |
61 const syncable::Entry& entry); | 56 const syncable::Entry& entry); |
62 // Given two values of the type returned by FindAnchorPosition, | 57 // Given two values of the type returned by FindAnchorPosition, |
63 // compute a third value in between the two ranges. | 58 // compute a third value in between the two ranges. |
64 int64 InterpolatePosition(int64 lo, int64 hi); | 59 int64 InterpolatePosition(int64 lo, int64 hi); |
65 | 60 |
66 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); | 61 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); |
67 | 62 |
68 // Input parameter; see constructor comment. | 63 // Input parameter; see constructor comment. |
69 const sessions::OrderedCommitSet& batch_commit_set_; | 64 const sessions::OrderedCommitSet& batch_commit_set_; |
70 | 65 |
71 // Output parameter; see constructor comment. | 66 // Output parameter; see constructor comment. |
72 sync_pb::ClientToServerMessage* commit_message_; | 67 sync_pb::ClientToServerMessage* commit_message_; |
73 }; | 68 }; |
74 | 69 |
75 } // namespace syncer | 70 } // namespace syncer |
76 | 71 |
77 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | 72 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
OLD | NEW |