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

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

Issue 10735041: Remove syncproto.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve DCHECKing, fix tests Created 8 years, 5 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 | « no previous file | sync/engine/build_commit_command.cc » ('j') | sync/engine/build_commit_command.cc » ('J')
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 "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "sync/engine/syncer_command.h" 12 #include "sync/engine/syncer_command.h"
13 #include "sync/engine/syncproto.h"
14 #include "sync/syncable/entry_kernel.h" 13 #include "sync/syncable/entry_kernel.h"
15 14
16 namespace syncer { 15 namespace syncer {
17 16
18 namespace sessions { 17 namespace sessions {
19 class OrderedCommitSet; 18 class OrderedCommitSet;
20 } 19 }
21 20
22 namespace syncable { 21 namespace syncable {
23 class Entry; 22 class Entry;
24 } 23 }
25 24
26 // A class that contains the code used to serialize a set of sync items into a 25 // A class that contains the code used to serialize a set of sync items into a
27 // protobuf commit message. This conversion process references the 26 // protobuf commit message. This conversion process references the
28 // syncable::Directory, which is why it must be called within the same 27 // syncable::Directory, which is why it must be called within the same
29 // transaction as the GetCommitIdsCommand that fetched the set of items to be 28 // transaction as the GetCommitIdsCommand that fetched the set of items to be
30 // committed. 29 // committed.
31 // 30 //
32 // See SyncerCommand documentation for more info. 31 // See SyncerCommand documentation for more info.
33 class BuildCommitCommand : public SyncerCommand { 32 class BuildCommitCommand : public SyncerCommand {
34 public: 33 public:
35 // The batch_commit_set parameter contains a set of references to the items 34 // The batch_commit_set parameter contains a set of references to the items
36 // that should be committed. 35 // that should be committed.
37 // 36 //
38 // The commit_message parameter is an output parameter which will contain the 37 // The commit_message parameter is an output parameter which will contain the
39 // fully initialized commit message once ExecuteImpl() has been called. 38 // fully initialized commit message once ExecuteImpl() has been called.
40 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set, 39 BuildCommitCommand(const sessions::OrderedCommitSet& batch_commit_set,
41 ClientToServerMessage* commit_message); 40 sync_pb::ClientToServerMessage* commit_message);
42 virtual ~BuildCommitCommand(); 41 virtual ~BuildCommitCommand();
43 42
44 // SyncerCommand implementation. 43 // SyncerCommand implementation.
45 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE; 44 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
46 45
47 private: 46 private:
48 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition); 47 FRIEND_TEST_ALL_PREFIXES(BuildCommitCommandTest, InterpolatePosition);
49 48
50 // Functions returning constants controlling range of values. 49 // Functions returning constants controlling range of values.
51 static int64 GetFirstPosition(); 50 static int64 GetFirstPosition();
52 static int64 GetLastPosition(); 51 static int64 GetLastPosition();
53 static int64 GetGap(); 52 static int64 GetGap();
54 53
55 void AddExtensionsActivityToMessage(sessions::SyncSession* session, 54 void AddExtensionsActivityToMessage(sessions::SyncSession* session,
56 CommitMessage* message); 55 sync_pb::CommitMessage* message);
57 // Helper for computing position. Find the numeric position value 56 // Helper for computing position. Find the numeric position value
58 // of the closest already-synced entry. |direction| must be one of 57 // of the closest already-synced entry. |direction| must be one of
59 // NEXT_ID or PREV_ID; this parameter controls the search direction. 58 // NEXT_ID or PREV_ID; this parameter controls the search direction.
60 // For an open range (no predecessor or successor), the return 59 // For an open range (no predecessor or successor), the return
61 // value will be kFirstPosition or kLastPosition. 60 // value will be kFirstPosition or kLastPosition.
62 int64 FindAnchorPosition(syncable::IdField direction, 61 int64 FindAnchorPosition(syncable::IdField direction,
63 const syncable::Entry& entry); 62 const syncable::Entry& entry);
64 // Given two values of the type returned by FindAnchorPosition, 63 // Given two values of the type returned by FindAnchorPosition,
65 // compute a third value in between the two ranges. 64 // compute a third value in between the two ranges.
66 int64 InterpolatePosition(int64 lo, int64 hi); 65 int64 InterpolatePosition(int64 lo, int64 hi);
67 66
68 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand); 67 DISALLOW_COPY_AND_ASSIGN(BuildCommitCommand);
69 68
70 // Input parameter; see constructor comment. 69 // Input parameter; see constructor comment.
71 const sessions::OrderedCommitSet& batch_commit_set_; 70 const sessions::OrderedCommitSet& batch_commit_set_;
72 71
73 // Output parameter; see constructor comment. 72 // Output parameter; see constructor comment.
74 ClientToServerMessage* commit_message_; 73 sync_pb::ClientToServerMessage* commit_message_;
75 }; 74 };
76 75
77 } // namespace syncer 76 } // namespace syncer
78 77
79 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_ 78 #endif // SYNC_ENGINE_BUILD_COMMIT_COMMAND_H_
OLDNEW
« no previous file with comments | « no previous file | sync/engine/build_commit_command.cc » ('j') | sync/engine/build_commit_command.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698