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

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

Issue 25638003: sync: Implement per-type commit interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fixes from first review Created 7 years, 2 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
OLDNEW
(Empty)
1 // Copyright 2013 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.
4
5 #ifndef SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
6 #define SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
7
8 #include <map>
Nicolas Zea 2013/10/09 00:17:39 not needed
rlarocque 2013/10/09 20:00:19 Done.
9
10 #include "base/gtest_prod_util.h"
11 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/internal_api/public/util/syncer_error.h"
14 #include "sync/protocol/sync.pb.h"
15 #include "sync/sessions/status_controller.h"
16
17 namespace syncer {
18
19 namespace sessions {
20 class StatusController;
21 } // namespace sessions
22
23 namespace syncable {
24 class Directory;
25 } // namespace syncable
26
27 // This class represents a set of items belonging to a particular data type that
28 // have been selected from the syncable Directory and prepared for a commit.
Nicolas Zea 2013/10/09 00:17:39 for a commit -> for commit
rlarocque 2013/10/09 20:00:19 Done.
29 //
30 // This class handles the bookkeeping related to the commit of these items,
31 // including processing the commit response message and setting and unsetting
32 // the SYNCING bits.
33 class SYNC_EXPORT_PRIVATE SyncDirectoryCommitContribution {
34 public:
35 // This destructor may make model neutral changes to the directory.
36 // (It unsets its entities' SYNCING bits.)
Nicolas Zea 2013/10/09 00:17:39 As you mentioned, it's odd to be doing this work i
rlarocque 2013/10/09 20:00:19 I can see that side of the argument. However, uns
Nicolas Zea 2013/10/10 21:34:45 Even if we don't have transactions passed through,
rlarocque 2013/10/11 23:03:30 I was hoping to avoid that. That DCHECK() means t
37 ~SyncDirectoryCommitContribution();
38
39 // Build a CommitContribution from the IS_UNSYNCED items in |dir| with the
40 // given |type|. The contribution will include at most |max_items| entries.
41 //
42 // This function may return NULL if this type has no items ready for and
Nicolas Zea 2013/10/09 00:17:39 doesn't "ready for" already imply "requiring"? I'd
rlarocque 2013/10/09 20:00:19 I think of an item as "requiring" commit if its IS
43 // requiring commit. This function may make model neutral changes to the
44 // directory.
45 static SyncDirectoryCommitContribution* Build(
46 syncable::Directory* dir,
47 ModelType type,
48 size_t max_items);
49
50 // Serialize this objects's entries to the given commit request |msg|.
Nicolas Zea 2013/10/09 00:17:39 this object's -> this contribution's (here and bel
rlarocque 2013/10/09 20:00:19 Done.
51 //
52 // This function is not const. It will update some state in this object that
53 // will be used when processing the associated commit response. This function
54 // should not be called more than once.
55 void AddToCommitMessage(sync_pb::ClientToServerMessage* msg);
56
57 // Updates this object's contents in accordance with the provided |response|.
58 //
59 // This function may make model-neutral changes to the directory. It is not
60 // valid to call this function unless AddToCommitMessage() was called earlier.
61 // This function should not be called more than once.
62 SyncerError ProcessCommitResponse(
63 const sync_pb::ClientToServerResponse& response,
64 sessions::StatusController* status);
65
66 // Returns the number of entries included in this contribution.
67 size_t GetNumEntries();
68
69 private:
70 class SyncDirectoryCommitContributionTest;
71 FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest, GatherByTypes);
72 FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest,
73 GatherAndTruncate);
74
75 SyncDirectoryCommitContribution(
76 const std::vector<int64>& metahandles,
77 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
78 syncable::Directory* directory);
79
80 syncable::Directory* dir_;
81 const std::vector<int64> metahandles_;
82 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_;
83 size_t entries_start_index_;
84
85 DISALLOW_COPY_AND_ASSIGN(SyncDirectoryCommitContribution);
86 };
87
88 } // namespace syncer
89
90 #endif // SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698