| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 5 #ifndef SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| 6 #define SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 6 #define SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // This class represents a set of items belonging to a particular data type that | 30 // This class represents a set of items belonging to a particular data type that |
| 31 // have been selected from the syncable Directory and prepared for commit. | 31 // have been selected from the syncable Directory and prepared for commit. |
| 32 // | 32 // |
| 33 // This class handles the bookkeeping related to the commit of these items, | 33 // This class handles the bookkeeping related to the commit of these items, |
| 34 // including processing the commit response message and setting and unsetting | 34 // including processing the commit response message and setting and unsetting |
| 35 // the SYNCING bits. | 35 // the SYNCING bits. |
| 36 class SYNC_EXPORT_PRIVATE DirectoryCommitContribution | 36 class SYNC_EXPORT_PRIVATE DirectoryCommitContribution |
| 37 : public CommitContribution { | 37 : public CommitContribution { |
| 38 public: | 38 public: |
| 39 // This destructor will DCHECK if UnsetSyncingBits() has not been called yet. | 39 // This destructor will DCHECK if UnsetSyncingBits() has not been called yet. |
| 40 virtual ~DirectoryCommitContribution(); | 40 ~DirectoryCommitContribution() override; |
| 41 | 41 |
| 42 // Build a CommitContribution from the IS_UNSYNCED items in |dir| with the | 42 // Build a CommitContribution from the IS_UNSYNCED items in |dir| with the |
| 43 // given |type|. The contribution will include at most |max_items| entries. | 43 // given |type|. The contribution will include at most |max_items| entries. |
| 44 // | 44 // |
| 45 // This function may return NULL if this type has no items ready for and | 45 // This function may return NULL if this type has no items ready for and |
| 46 // requiring commit. This function may make model neutral changes to the | 46 // requiring commit. This function may make model neutral changes to the |
| 47 // directory. | 47 // directory. |
| 48 static scoped_ptr<DirectoryCommitContribution> Build( | 48 static scoped_ptr<DirectoryCommitContribution> Build( |
| 49 syncable::Directory* dir, | 49 syncable::Directory* dir, |
| 50 ModelType type, | 50 ModelType type, |
| 51 size_t max_items, | 51 size_t max_items, |
| 52 DirectoryTypeDebugInfoEmitter* debug_info_emitter); | 52 DirectoryTypeDebugInfoEmitter* debug_info_emitter); |
| 53 | 53 |
| 54 // Serialize this contribution's entries to the given commit request |msg|. | 54 // Serialize this contribution's entries to the given commit request |msg|. |
| 55 // | 55 // |
| 56 // This function is not const. It will update some state in this contribution | 56 // This function is not const. It will update some state in this contribution |
| 57 // that will be used when processing the associated commit response. This | 57 // that will be used when processing the associated commit response. This |
| 58 // function should not be called more than once. | 58 // function should not be called more than once. |
| 59 virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) override; | 59 void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) override; |
| 60 | 60 |
| 61 // Updates this contribution's contents in accordance with the provided | 61 // Updates this contribution's contents in accordance with the provided |
| 62 // |response|. | 62 // |response|. |
| 63 // | 63 // |
| 64 // This function may make model-neutral changes to the directory. It is not | 64 // This function may make model-neutral changes to the directory. It is not |
| 65 // valid to call this function unless AddToCommitMessage() was called earlier. | 65 // valid to call this function unless AddToCommitMessage() was called earlier. |
| 66 // This function should not be called more than once. | 66 // This function should not be called more than once. |
| 67 virtual SyncerError ProcessCommitResponse( | 67 SyncerError ProcessCommitResponse( |
| 68 const sync_pb::ClientToServerResponse& response, | 68 const sync_pb::ClientToServerResponse& response, |
| 69 sessions::StatusController* status) override; | 69 sessions::StatusController* status) override; |
| 70 | 70 |
| 71 // Cleans up any temporary state associated with the commit. Must be called | 71 // Cleans up any temporary state associated with the commit. Must be called |
| 72 // before destruction. | 72 // before destruction. |
| 73 virtual void CleanUp() override; | 73 void CleanUp() override; |
| 74 | 74 |
| 75 // Returns the number of entries included in this contribution. | 75 // Returns the number of entries included in this contribution. |
| 76 virtual size_t GetNumEntries() const override; | 76 size_t GetNumEntries() const override; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 class DirectoryCommitContributionTest; | 79 class DirectoryCommitContributionTest; |
| 80 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes); | 80 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes); |
| 81 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, | 81 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, |
| 82 GatherAndTruncate); | 82 GatherAndTruncate); |
| 83 | 83 |
| 84 DirectoryCommitContribution( | 84 DirectoryCommitContribution( |
| 85 const std::vector<int64>& metahandles, | 85 const std::vector<int64>& metahandles, |
| 86 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | 86 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 104 | 104 |
| 105 // A pointer to the commit counters of our parent CommitContributor. | 105 // A pointer to the commit counters of our parent CommitContributor. |
| 106 DirectoryTypeDebugInfoEmitter* debug_info_emitter_; | 106 DirectoryTypeDebugInfoEmitter* debug_info_emitter_; |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); | 108 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 } // namespace syncer | 111 } // namespace syncer |
| 112 | 112 |
| 113 #endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 113 #endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| OLD | NEW |