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

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: Attempt to fix win compile 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 <vector>
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 commit.
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 will DCHECK if UnsetSyncingBits() has not been called yet.
36 ~SyncDirectoryCommitContribution();
37
38 // Build a CommitContribution from the IS_UNSYNCED items in |dir| with the
39 // given |type|. The contribution will include at most |max_items| entries.
40 //
41 // This function may return NULL if this type has no items ready for and
42 // requiring commit. This function may make model neutral changes to the
43 // directory.
44 static SyncDirectoryCommitContribution* Build(
45 syncable::Directory* dir,
46 ModelType type,
47 size_t max_items);
48
49 // Serialize this contribution's entries to the given commit request |msg|.
50 //
51 // This function is not const. It will update some state in this contribution
52 // that will be used when processing the associated commit response. This
53 // function should not be called more than once.
54 void AddToCommitMessage(sync_pb::ClientToServerMessage* msg);
55
56 // Updates this contribution's contents in accordance with the provided
57 // |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 // Cleans up any temproary state associated with the commit. Must be called
67 // before destruction.
68 void CleanUp();
69
70 // Returns the number of entries included in this contribution.
71 size_t GetNumEntries() const;
72
73 private:
74 class SyncDirectoryCommitContributionTest;
75 FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest, GatherByTypes);
76 FRIEND_TEST_ALL_PREFIXES(SyncDirectoryCommitContributionTest,
77 GatherAndTruncate);
78
79 SyncDirectoryCommitContribution(
80 const std::vector<int64>& metahandles,
81 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
82 syncable::Directory* directory);
83
84 void UnsetSyncingBits();
85
86 syncable::Directory* dir_;
87 const std::vector<int64> metahandles_;
88 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_;
89 size_t entries_start_index_;
90
91 // This flag is tracks whether or not the directory entries associated with
92 // this commit still have their SYNCING bits set. These bits will be set when
93 // the CommitContribution is created with Build() and unset when CleanUp() is
94 // called. This flag must be unset by the time our destructor is called.
95 bool syncing_bits_set_;
96
97 DISALLOW_COPY_AND_ASSIGN(SyncDirectoryCommitContribution);
98 };
99
100 } // namespace syncer
101
102 #endif // SYNC_ENGINE_SYNC_DIRECTORY_COMMIT_CONTRIBUTION_H_
OLDNEW
« no previous file with comments | « sync/engine/process_commit_response_command_unittest.cc ('k') | sync/engine/sync_directory_commit_contribution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698