diff options
author | maxbogue <maxbogue@chromium.org> | 2016-02-01 14:21:30 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-01 22:22:31 +0000 |
commit | 8be0f39e5721c510803383caf51e825dfd4f590c (patch) | |
tree | 637386e966a3fa5081dcbbbcb57f709be5a0c145 /sync/api | |
parent | 13b5f044fa548fec789776c4a245c91ddbb2085d (diff) | |
download | chromium_src-8be0f39e5721c510803383caf51e825dfd4f590c.zip chromium_src-8be0f39e5721c510803383caf51e825dfd4f590c.tar.gz chromium_src-8be0f39e5721c510803383caf51e825dfd4f590c.tar.bz2 |
[Sync] USS: Load metadata into the processor.
Data still needs to be loaded, and then testing will be easier.
BUG=569645,569987
Review URL: https://codereview.chromium.org/1635693002
Cr-Commit-Position: refs/heads/master@{#372786}
Diffstat (limited to 'sync/api')
-rw-r--r-- | sync/api/metadata_batch.cc | 29 | ||||
-rw-r--r-- | sync/api/metadata_batch.h | 32 |
2 files changed, 58 insertions, 3 deletions
diff --git a/sync/api/metadata_batch.cc b/sync/api/metadata_batch.cc new file mode 100644 index 0000000..072ad5e --- /dev/null +++ b/sync/api/metadata_batch.cc @@ -0,0 +1,29 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "sync/api/metadata_batch.h" + +namespace syncer_v2 { + +MetadataBatch::MetadataBatch() {} +MetadataBatch::~MetadataBatch() {} + +EntityMetadataMap&& MetadataBatch::TakeAllMetadata() { + return std::move(metadata_map_); +} + +void MetadataBatch::AddMetadata(const std::string& client_tag, + const sync_pb::EntityMetadata& metadata) { + metadata_map_.insert(std::make_pair(client_tag, metadata)); +} + +const DataTypeState& MetadataBatch::GetDataTypeState() const { + return state_; +} + +void MetadataBatch::SetDataTypeState(const DataTypeState& state) { + state_ = state; +} + +} // namespace syncer_v2 diff --git a/sync/api/metadata_batch.h b/sync/api/metadata_batch.h index 459999c..56ab2a7 100644 --- a/sync/api/metadata_batch.h +++ b/sync/api/metadata_batch.h @@ -5,15 +5,41 @@ #ifndef SYNC_API_METADATA_BATCH_H_ #define SYNC_API_METADATA_BATCH_H_ +#include <map> + #include "sync/base/sync_export.h" +#include "sync/internal_api/public/non_blocking_sync_common.h" +#include "sync/protocol/entity_metadata.pb.h" namespace syncer_v2 { -// Interface used by the processor to read metadata requested from the service. +// Map of client tag to EntityMetadata proto. +typedef std::map<std::string, sync_pb::EntityMetadata> EntityMetadataMap; + +// Container used to pass sync metadata from services to their processor. class SYNC_EXPORT MetadataBatch { public: - MetadataBatch() {} - virtual ~MetadataBatch() {} + MetadataBatch(); + virtual ~MetadataBatch(); + + // Allows the caller to take ownership of the entire metadata map. This is + // done because the caller will probably swap out all the EntityMetadata + // protos from the map for performance reasons. + EntityMetadataMap&& TakeAllMetadata(); + + // Add |metadata| for |client_tag| to the batch. + void AddMetadata(const std::string& client_tag, + const sync_pb::EntityMetadata& metadata); + + // Get the DataTypeState for this batch. + const DataTypeState& GetDataTypeState() const; + + // Set the DataTypeState for this batch. + void SetDataTypeState(const DataTypeState& state); + + private: + EntityMetadataMap metadata_map_; + DataTypeState state_; }; } // namespace syncer_v2 |