Home | History | Annotate | Download | only in syncable
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 //
      5 // Definition of ModelTypePayloadMap and various utility functions.
      6 
      7 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_
      8 #define CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_
      9 #pragma once
     10 
     11 #include <map>
     12 #include <string>
     13 
     14 #include "chrome/browser/sync/engine/model_safe_worker.h"
     15 #include "chrome/browser/sync/syncable/model_type.h"
     16 
     17 class DictionaryValue;
     18 
     19 namespace syncable {
     20 
     21 // A container that contains a set of datatypes with possible string
     22 // payloads.
     23 typedef std::map<ModelType, std::string> ModelTypePayloadMap;
     24 
     25 // Helper functions for building ModelTypePayloadMaps.
     26 
     27 // Make a TypePayloadMap from all the types in a ModelTypeBitSet using
     28 // a default payload.
     29 ModelTypePayloadMap ModelTypePayloadMapFromBitSet(
     30     const ModelTypeBitSet& model_types,
     31     const std::string& payload);
     32 
     33 // Make a TypePayloadMap for all the enabled types in a
     34 // ModelSafeRoutingInfo using a default payload.
     35 ModelTypePayloadMap ModelTypePayloadMapFromRoutingInfo(
     36     const browser_sync::ModelSafeRoutingInfo& routes,
     37     const std::string& payload);
     38 
     39 // Caller takes ownership of the returned dictionary.
     40 DictionaryValue* ModelTypePayloadMapToValue(
     41     const ModelTypePayloadMap& model_type_payloads);
     42 
     43 // Coalesce |update| into |original|, overwriting only when |update| has
     44 // a non-empty payload.
     45 void CoalescePayloads(ModelTypePayloadMap* original,
     46                       const ModelTypePayloadMap& update);
     47 
     48 }  // namespace syncable
     49 
     50 #endif  // CHROME_BROWSER_SYNC_SYNCABLE_MODEL_TYPE_PAYLOAD_MAP_H_
     51