Chromium Code Reviews| Index: sync/internal_api/public/base/model_type_state_map.h |
| diff --git a/sync/internal_api/public/base/model_type_state_map.h b/sync/internal_api/public/base/model_type_state_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e9c5592e96a93ff2168b8fe952579591e6cdad80 |
| --- /dev/null |
| +++ b/sync/internal_api/public/base/model_type_state_map.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2012 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. |
| +// |
| +// Definition of ModelTypeStateMap and various utility functions. |
| + |
| +#ifndef SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_ |
| +#define SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "sync/base/sync_export.h" |
| +#include "sync/internal_api/public/base/model_type.h" |
| + |
| +// TODO(akalin): Move the non-exported functions in this file to a |
| +// private header. |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +} |
| + |
| +namespace syncer { |
| + |
| +struct InvalidationState { |
|
akalin
2012/08/13 19:41:48
can we move this into its own header? I think it'
dcheng
2012/08/18 00:41:29
Done.
|
| + std::string payload; |
| + std::string ack_handle; |
|
akalin
2012/08/13 19:41:48
can we use invalidation::AckHandle for now, until
dcheng
2012/08/18 00:41:29
I've just declared an empty AckHandle class for no
|
| + |
| + bool operator==(const InvalidationState& rhs) const; |
|
akalin
2012/08/13 19:41:48
use Equals()
dcheng
2012/08/18 00:41:29
As discussed, we are now using Gmock matchers.
|
| +}; |
| + |
| +// A container that contains a set of datatypes with possible string |
| +// payloads. |
| +typedef std::map<ModelType, InvalidationState> ModelTypeStateMap; |
| + |
| +// Helper functions for building ModelTypeStateMaps. |
| + |
| +// Make a TypeStateMap from all the types in a ModelTypeSet using a |
| +// default payload. |
| +SYNC_EXPORT ModelTypeStateMap ModelTypeStateMapFromEnumSet( |
| + ModelTypeSet model_types, const std::string& payload); |
| + |
| +ModelTypeSet ModelTypeStateMapToEnumSet( |
| + const ModelTypeStateMap& payload_map); |
| + |
| +std::string ModelTypeStateMapToString( |
| + const ModelTypeStateMap& model_type_payloads); |
| + |
| +// Caller takes ownership of the returned dictionary. |
| +base::DictionaryValue* ModelTypeStateMapToValue( |
| + const ModelTypeStateMap& model_type_payloads); |
| + |
| +// Coalesce |update| into |original|, overwriting only when |update| has |
| +// a non-empty payload. |
| +void CoalesceStates(ModelTypeStateMap* original, |
| + const ModelTypeStateMap& update); |
| + |
| +} // namespace syncer |
| + |
| +#endif // SYNC_INTERNAL_PUBLIC_API_BASE_MODEL_TYPE_STATE_MAP_H_ |