Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / sync / test / fake_server / fake_server_entity.cc
index b2aa6f9..f3fc604 100644 (file)
@@ -27,7 +27,11 @@ using std::vector;
 using syncer::ModelType;
 
 // The separator used when formatting IDs.
-const char kIdSeparator[] = "/";
+//
+// We chose the underscore character because it doesn't conflict with the
+// special characters used by base/base64.h's encoding, which is also used in
+// the construction of some IDs.
+const char kIdSeparator[] = "_";
 
 namespace fake_server {
 
@@ -64,6 +68,13 @@ string FakeServerEntity::CreateId(const ModelType& model_type,
 }
 
 // static
+std::string FakeServerEntity::GetTopLevelId(const ModelType& model_type) {
+  return FakeServerEntity::CreateId(
+      model_type,
+      syncer::ModelTypeToRootTag(model_type));
+}
+
+// static
 ModelType FakeServerEntity::GetModelTypeFromId(const string& id) {
   vector<string> tokens;
   size_t token_count = Tokenize(id, kIdSeparator, &tokens);
@@ -80,8 +91,8 @@ FakeServerEntity::FakeServerEntity(const string& id,
                                    const ModelType& model_type,
                                    int64 version,
                                    const string& name)
-      : id_(id),
-        model_type_(model_type),
+      : model_type_(model_type),
+        id_(id),
         version_(version),
         name_(name) {}