| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "sync/base/sync_export.h" | 12 #include "sync/base/sync_export.h" |
| 13 #include "sync/engine/commit_contribution.h" | 13 #include "sync/engine/commit_contribution.h" |
| 14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "sync/internal_api/public/base/model_type.h" |
| 15 #include "sync/internal_api/public/util/syncer_error.h" | 15 #include "sync/internal_api/public/util/syncer_error.h" |
| 16 #include "sync/protocol/sync.pb.h" | 16 #include "sync/protocol/sync.pb.h" |
| 17 #include "sync/sessions/directory_type_debug_info_emitter.h" |
| 17 #include "sync/sessions/status_controller.h" | 18 #include "sync/sessions/status_controller.h" |
| 18 | 19 |
| 19 namespace syncer { | 20 namespace syncer { |
| 20 | 21 |
| 21 namespace sessions { | 22 namespace sessions { |
| 22 class StatusController; | 23 class StatusController; |
| 23 } // namespace sessions | 24 } // namespace sessions |
| 24 | 25 |
| 25 namespace syncable { | 26 namespace syncable { |
| 26 class Directory; | 27 class Directory; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 | 41 |
| 41 // 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 |
| 42 // given |type|. The contribution will include at most |max_items| entries. | 43 // given |type|. The contribution will include at most |max_items| entries. |
| 43 // | 44 // |
| 44 // 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 |
| 45 // requiring commit. This function may make model neutral changes to the | 46 // requiring commit. This function may make model neutral changes to the |
| 46 // directory. | 47 // directory. |
| 47 static scoped_ptr<DirectoryCommitContribution> Build( | 48 static scoped_ptr<DirectoryCommitContribution> Build( |
| 48 syncable::Directory* dir, | 49 syncable::Directory* dir, |
| 49 ModelType type, | 50 ModelType type, |
| 50 size_t max_items); | 51 size_t max_items, |
| 52 DirectoryTypeDebugInfoEmitter* debug_info_emitter); |
| 51 | 53 |
| 52 // Serialize this contribution's entries to the given commit request |msg|. | 54 // Serialize this contribution's entries to the given commit request |msg|. |
| 53 // | 55 // |
| 54 // 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 |
| 55 // that will be used when processing the associated commit response. This | 57 // that will be used when processing the associated commit response. This |
| 56 // function should not be called more than once. | 58 // function should not be called more than once. |
| 57 virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) OVERRIDE; | 59 virtual void AddToCommitMessage(sync_pb::ClientToServerMessage* msg) OVERRIDE; |
| 58 | 60 |
| 59 // Updates this contribution's contents in accordance with the provided | 61 // Updates this contribution's contents in accordance with the provided |
| 60 // |response|. | 62 // |response|. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 private: | 78 private: |
| 77 class DirectoryCommitContributionTest; | 79 class DirectoryCommitContributionTest; |
| 78 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes); | 80 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, GatherByTypes); |
| 79 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, | 81 FRIEND_TEST_ALL_PREFIXES(DirectoryCommitContributionTest, |
| 80 GatherAndTruncate); | 82 GatherAndTruncate); |
| 81 | 83 |
| 82 DirectoryCommitContribution( | 84 DirectoryCommitContribution( |
| 83 const std::vector<int64>& metahandles, | 85 const std::vector<int64>& metahandles, |
| 84 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, | 86 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, |
| 85 const sync_pb::DataTypeContext& context, | 87 const sync_pb::DataTypeContext& context, |
| 86 syncable::Directory* directory); | 88 syncable::Directory* directory, |
| 89 DirectoryTypeDebugInfoEmitter* debug_info_emitter); |
| 87 | 90 |
| 88 void UnsetSyncingBits(); | 91 void UnsetSyncingBits(); |
| 89 | 92 |
| 90 syncable::Directory* dir_; | 93 syncable::Directory* dir_; |
| 91 const std::vector<int64> metahandles_; | 94 const std::vector<int64> metahandles_; |
| 92 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_; | 95 const google::protobuf::RepeatedPtrField<sync_pb::SyncEntity> entities_; |
| 93 sync_pb::DataTypeContext context_; | 96 sync_pb::DataTypeContext context_; |
| 94 size_t entries_start_index_; | 97 size_t entries_start_index_; |
| 95 | 98 |
| 96 // This flag is tracks whether or not the directory entries associated with | 99 // This flag is tracks whether or not the directory entries associated with |
| 97 // this commit still have their SYNCING bits set. These bits will be set when | 100 // this commit still have their SYNCING bits set. These bits will be set when |
| 98 // the CommitContribution is created with Build() and unset when CleanUp() is | 101 // the CommitContribution is created with Build() and unset when CleanUp() is |
| 99 // called. This flag must be unset by the time our destructor is called. | 102 // called. This flag must be unset by the time our destructor is called. |
| 100 bool syncing_bits_set_; | 103 bool syncing_bits_set_; |
| 101 | 104 |
| 105 // A pointer to the commit counters of our parent CommitContributor. |
| 106 DirectoryTypeDebugInfoEmitter* debug_info_emitter_; |
| 107 |
| 102 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); | 108 DISALLOW_COPY_AND_ASSIGN(DirectoryCommitContribution); |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 } // namespace syncer | 111 } // namespace syncer |
| 106 | 112 |
| 107 #endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ | 113 #endif // SYNC_ENGINE_DIRECTORY_COMMIT_CONTRIBUTION_H_ |
| OLD | NEW |