| 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 COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "components/sync/base/model_type.h" | 16 #include "components/sync/base/model_type.h" |
| 17 #include "components/sync/base/syncer_error.h" | 17 #include "components/sync/base/syncer_error.h" |
| 18 #include "components/sync/engine_impl/commit_contribution.h" | 18 #include "components/sync/engine_impl/commit_contribution.h" |
| 19 #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h" | 19 #include "components/sync/engine_impl/cycle/data_type_debug_info_emitter.h" |
| 20 #include "components/sync/engine_impl/cycle/status_controller.h" | 20 #include "components/sync/engine_impl/cycle/status_controller.h" |
| 21 #include "components/sync/protocol/sync.pb.h" | 21 #include "components/sync/protocol/sync.pb.h" |
| 22 | 22 |
| 23 namespace syncer { | 23 namespace syncer { |
| 24 | 24 |
| 25 class StatusController; | 25 class StatusController; |
| 26 | 26 |
| 27 namespace syncable { | 27 namespace syncable { |
| 28 class Directory; | 28 class Directory; |
| 29 } // namespace syncable | 29 } // namespace syncable |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 std::unique_ptr<DirectoryCommitContribution> Build( | 48 static std::unique_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 DataTypeDebugInfoEmitter* 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 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|. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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, GatherAndTruncate); | 81 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherAndTruncate); |
| 82 | 82 |
| 83 DirectoryCommitContribution( | 83 DirectoryCommitContribution( |
| 84 const std::vector<int64_t>& metahandles, | 84 const std::vector<int64_t>& metahandles, |
| 85 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | 85 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
| 86 const sync_pb::DataTypeContext& context, | 86 const sync_pb::DataTypeContext& context, |
| 87 syncable::Directory* directory, | 87 syncable::Directory* directory, |
| 88 DirectoryTypeDebugInfoEmitter* debug_info_emitter); | 88 DataTypeDebugInfoEmitter* debug_info_emitter); |
| 89 | 89 |
| 90 void UnsetSyncingBits(); | 90 void UnsetSyncingBits(); |
| 91 | 91 |
| 92 syncable::Directory* dir_; | 92 syncable::Directory* dir_; |
| 93 const std::vector<int64_t> metahandles_; | 93 const std::vector<int64_t> metahandles_; |
| 94 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_; | 94 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_; |
| 95 sync_pb::DataTypeContext context_; | 95 sync_pb::DataTypeContext context_; |
| 96 size_t entries_start_index_; | 96 size_t entries_start_index_; |
| 97 | 97 |
| 98 // This flag is tracks whether or not the directory entries associated with | 98 // This flag is tracks whether or not the directory entries associated with |
| 99 // this commit still have their SYNCING bits set. These bits will be set when | 99 // this commit still have their SYNCING bits set. These bits will be set when |
| 100 // the CommitContribution is created with Build() and unset when CleanUp() is | 100 // the CommitContribution is created with Build() and unset when CleanUp() is |
| 101 // called. This flag must be unset by the time our destructor is called. | 101 // called. This flag must be unset by the time our destructor is called. |
| 102 bool syncing_bits_set_; | 102 bool syncing_bits_set_; |
| 103 | 103 |
| 104 // A pointer to the commit counters of our parent CommitContributor. | 104 // A pointer to the commit counters of our parent CommitContributor. |
| 105 DirectoryTypeDebugInfoEmitter* debug_info_emitter_; | 105 DataTypeDebugInfoEmitter* debug_info_emitter_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); | 107 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace syncer | 110 } // namespace syncer |
| 111 | 111 |
| 112 #endif // COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 112 #endif // COMPONENTS_SYNC_ENGINE_IMPL_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| OLD | NEW |