| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "chrome/browser/sync/engine/syncer_command.h" | 10 #include "chrome/browser/sync/engine/syncer_command.h" |
| 11 #include "chrome/browser/sync/engine/syncproto.h" | 11 #include "chrome/browser/sync/engine/syncproto.h" |
| 12 #include "chrome/browser/sync/syncable/syncable.h" | 12 #include "chrome/browser/sync/syncable/syncable.h" |
| 13 | 13 |
| 14 namespace browser_sync { | 14 namespace browser_sync { |
| 15 | 15 |
| 16 class BuildCommitCommand : public SyncerCommand { | 16 class BuildCommitCommand : public SyncerCommand { |
| 17 public: | 17 public: |
| 18 BuildCommitCommand(); | 18 BuildCommitCommand(); |
| 19 virtual ~BuildCommitCommand(); | 19 virtual ~BuildCommitCommand(); |
| 20 | 20 |
| 21 // SyncerCommand implementation. | 21 // SyncerCommand implementation. |
| 22 virtual void ExecuteImpl(sessions::SyncSession* session); | 22 virtual void ExecuteImpl(sessions::SyncSession* session); |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); | 25 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); |
| 26 | 26 |
| 27 // Constants controlling range of values. | 27 // Functions returning constants controlling range of values. |
| 28 static const int64 kFirstPosition; | 28 static int64 GetFirstPosition(); |
| 29 static const int64 kLastPosition; | 29 static int64 GetLastPosition(); |
| 30 static const int64 kGap; | 30 static int64 GetGap(); |
| 31 | 31 |
| 32 void AddExtensionsActivityToMessage(sessions::SyncSession* session, | 32 void AddExtensionsActivityToMessage(sessions::SyncSession* session, |
| 33 CommitMessage* message); | 33 CommitMessage* message); |
| 34 // Helper for computing position. Find the numeric position value | 34 // Helper for computing position. Find the numeric position value |
| 35 // of the closest already-synced entry. |direction| must be one of | 35 // of the closest already-synced entry. |direction| must be one of |
| 36 // NEXT_ID or PREV_ID; this parameter controls the search direction. | 36 // NEXT_ID or PREV_ID; this parameter controls the search direction. |
| 37 // For an open range (no predecessor or successor), the return | 37 // For an open range (no predecessor or successor), the return |
| 38 // value will be kFirstPosition or kLastPosition. | 38 // value will be kFirstPosition or kLastPosition. |
| 39 int64 FindAnchorPosition(syncable::IdField direction, | 39 int64 FindAnchorPosition(syncable::IdField direction, |
| 40 const syncable::Entry& entry); | 40 const syncable::Entry& entry); |
| 41 // Given two values of the type returned by FindAnchorPosition, | 41 // Given two values of the type returned by FindAnchorPosition, |
| 42 // compute a third value in between the two ranges. | 42 // compute a third value in between the two ranges. |
| 43 int64 InterpolatePosition(int64 lo, int64 hi); | 43 int64 InterpolatePosition(int64 lo, int64 hi); |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); | 45 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 } // namespace browser_sync | 48 } // namespace browser_sync |
| 49 | 49 |
| 50 #endif // CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ | 50 #endif // CHROME_BROWSER_SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ |
| OLD | NEW |