Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: sync/engine/build_commit_command.h

Issue 10210009: sync: Loop committing items without downloading updates (v2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.cc ('k') | sync/engine/build_commit_command.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "sync/engine/syncer_command.h" 11 #include "sync/engine/syncer_command.h"
12 #include "sync/engine/syncproto.h" 12 #include "sync/engine/syncproto.h"
13 #include "sync/syncable/syncable.h" 13 #include "sync/syncable/syncable.h"
14 14
15 namespace browser_sync { 15 namespace browser_sync {
16 16
17 namespace sessions {
18 class OrderedCommitSet;
19 }
20
21 // A class that contains the code used to serialize a set of sync items into a
22 // protobuf commit message. This conversion process references the
23 // syncable::Directory, which is why it must be called within the same
24 // transaction as the GetCommitIdsCommand that fetched the set of items to be
25 // committed.
26 //
27 // See SyncerCommand documentation for more info.
17 class BuildCommitCommand : public SyncerCommand { 28 class BuildCommitCommand : public SyncerCommand {
18 public: 29 public:
19 BuildCommitCommand(); 30 // The batch_commit_set parameter contains a set of references to the items
31 // that should be committed.
32 //
33 // The commit_message parameter is an output parameter which will contain the
34 // fully initialized commit message once ExecuteImpl() has been called.
35 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set,
36 ClientToServerMessage* commit_message);
20 virtual ~BuildCommitCommand(); 37 virtual ~BuildCommitCommand();
21 38
22 // SyncerCommand implementation. 39 // SyncerCommand implementation.
23 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; 40 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
24 41
25 private: 42 private:
26 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); 43 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition);
27 44
28 // Functions returning constants controlling range of values. 45 // Functions returning constants controlling range of values.
29 static int64 GetFirstPosition(); 46 static int64 GetFirstPosition();
30 static int64 GetLastPosition(); 47 static int64 GetLastPosition();
31 static int64 GetGap(); 48 static int64 GetGap();
32 49
33 void AddExtensionsActivityToMessage(sessions::SyncSession* session, 50 void AddExtensionsActivityToMessage(sessions::SyncSession* session,
34 CommitMessage* message); 51 CommitMessage* message);
35 // Helper for computing position. Find the numeric position value 52 // Helper for computing position. Find the numeric position value
36 // of the closest already-synced entry. |direction| must be one of 53 // of the closest already-synced entry. |direction| must be one of
37 // NEXT_ID or PREV_ID; this parameter controls the search direction. 54 // NEXT_ID or PREV_ID; this parameter controls the search direction.
38 // For an open range (no predecessor or successor), the return 55 // For an open range (no predecessor or successor), the return
39 // value will be kFirstPosition or kLastPosition. 56 // value will be kFirstPosition or kLastPosition.
40 int64 FindAnchorPosition(syncable::IdField direction, 57 int64 FindAnchorPosition(syncable::IdField direction,
41 const syncable::Entry& entry); 58 const syncable::Entry& entry);
42 // Given two values of the type returned by FindAnchorPosition, 59 // Given two values of the type returned by FindAnchorPosition,
43 // compute a third value in between the two ranges. 60 // compute a third value in between the two ranges.
44 int64 InterpolatePosition(int64 lo, int64 hi); 61 int64 InterpolatePosition(int64 lo, int64 hi);
45 62
46 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); 63 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand);
64
65 // Input parameter; see constructor comment.
66 const sessions::OrderedCommitSet& batch_commit_set_;
67
68 // Output parameter; see constructor comment.
69 ClientToServerMessage* commit_message_;
47 }; 70 };
48 71
49 } // namespace browser_sync 72 } // namespace browser_sync
50 73
51 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ 74 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.cc ('k') | sync/engine/build_commit_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698