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

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

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/engine/conflict_util.cc ('k') | sync/engine/directory_commit_contribution.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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_DIRECTORY_COMMIT_CONTRIBUTION_H_
6 #define SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12 #include <vector>
13
14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h"
16 #include "sync/base/sync_export.h"
17 #include "sync/engine/commit_contribution.h"
18 #include "sync/internal_api/public/base/model_type.h"
19 #include "sync/internal_api/public/util/syncer_error.h"
20 #include "sync/protocol/sync.pb.h"
21 #include "sync/sessions/directory_type_debug_info_emitter.h"
22 #include "sync/sessions/status_controller.h"
23
24 namespace syncer {
25
26 namespace sessions {
27 class StatusController;
28 } // namespace sessions
29
30 namespace syncable {
31 class Directory;
32 } // namespace syncable
33
34 // This class represents a set of items belonging to a particular data type that
35 // have been selected from the syncable Directory and prepared for commit.
36 //
37 // This class handles the bookkeeping related to the commit of these items,
38 // including processing the commit response message and setting and unsetting
39 // the SYNCING bits.
40 class SYNC_EXPORT DirectoryCommitContribution : public CommitContribution {
41 public:
42 // This destructor will DCHECK if UnsetSyncingBits() has not been called yet.
43 ~DirectoryCommitContribution() override;
44
45 // Build a CommitContribution from the IS_UNSYNCED items in |dir| with the
46 // given |type|. The contribution will include at most |max_items| entries.
47 //
48 // This function may return NULL if this type has no items ready for and
49 // requiring commit. This function may make model neutral changes to the
50 // directory.
51 static std::unique_ptr<DirectoryCommitContribution> Build(
52 syncable::Directory* dir,
53 ModelType type,
54 size_t max_items,
55 DirectoryTypeDebugInfoEmitter* debug_info_emitter);
56
57 // Serialize this contribution's entries to the given commit request |msg|.
58 //
59 // This function is not const. It will update some state in this contribution
60 // that will be used when processing the associated commit response. This
61 // function should not be called more than once.
62 void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) override;
63
64 // Updates this contribution's contents in accordance with the provided
65 // |response|.
66 //
67 // This function may make model-neutral changes to the directory. It is not
68 // valid to call this function unless AddToCommitMessage() was called earlier.
69 // This function should not be called more than once.
70 SyncerError ProcessCommitResponse(
71 const sync_pb::ClientToServerResponse& response,
72 sessions::StatusController* status) override;
73
74 // Cleans up any temporary state associated with the commit. Must be called
75 // before destruction.
76 void CleanUp() override;
77
78 // Returns the number of entries included in this contribution.
79 size_t GetNumEntries() const override;
80
81 private:
82 class DirectoryCommitContributionTest;
83 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes);
84 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest,
85 GatherAndTruncate);
86
87 DirectoryCommitContribution(
88 const std::vector<int64_t>& metahandles,
89 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
90 const sync_pb::DataTypeContext& context,
91 syncable::Directory* directory,
92 DirectoryTypeDebugInfoEmitter* debug_info_emitter);
93
94 void UnsetSyncingBits();
95
96 syncable::Directory* dir_;
97 const std::vector<int64_t> metahandles_;
98 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_;
99 sync_pb::DataTypeContext context_;
100 size_t entries_start_index_;
101
102 // This flag is tracks whether or not the directory entries associated with
103 // this commit still have their SYNCING bits set. These bits will be set when
104 // the CommitContribution is created with Build() and unset when CleanUp() is
105 // called. This flag must be unset by the time our destructor is called.
106 bool syncing_bits_set_;
107
108 // A pointer to the commit counters of our parent CommitContributor.
109 DirectoryTypeDebugInfoEmitter* debug_info_emitter_;
110
111 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution);
112 };
113
114 } // namespace syncer
115
116 #endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_
OLDNEW
« no previous file with comments | « sync/engine/conflict_util.cc ('k') | sync/engine/directory_commit_contribution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698