Chromium Code Reviews| Index: sync/android/java/src/org/chromium/sync/ModelType.java |
| diff --git a/sync/android/java/src/org/chromium/sync/ModelType.java b/sync/android/java/src/org/chromium/sync/ModelType.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ee22a7ca9b7185b0133586b3bb67c494acfbf8d6 |
| --- /dev/null |
| +++ b/sync/android/java/src/org/chromium/sync/ModelType.java |
| @@ -0,0 +1,40 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
|
Yaron
2013/01/10 19:29:40
I suppose this should be 2013.
nyquist
2013/01/10 22:01:42
Done here and in all the new files.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.sync; |
| + |
| +import com.google.ipc.invalidation.external.client.types.ObjectId; |
| +import com.google.protos.ipc.invalidation.Types; |
| + |
| +/** |
| + * The model types that are synced in Chrome for Android. |
| + */ |
| +public enum ModelType { |
| + |
| + // A bookmark folder or a bookmark URL object. |
|
Yaron
2013/01/10 19:29:40
Nit: use javadoc for IDEs?
nyquist
2013/01/10 22:01:42
Done.
|
| + BOOKMARK("BOOKMARK"), |
| + // A typed_url folder or a typed_url object. |
| + TYPED_URL("TYPED_URL"), |
| + // An object representing a browser session. |
|
Yaron
2013/01/10 19:29:40
.. browser session or tab.
nyquist
2013/01/10 22:01:42
Done.
|
| + SESSION("SESSION"); |
| + |
| + private final String mModelType; |
| + |
| + ModelType(String modelType) { |
| + mModelType = modelType; |
| + } |
| + |
| + public ObjectId toObjectId() { |
| + return ObjectId.newInstance(Types.ObjectSource.Type.CHROME_SYNC.getNumber(), |
| + mModelType.getBytes()); |
| + } |
| + |
| + public static ModelType fromObjectId(ObjectId objectId) { |
| + try { |
| + return valueOf(new String(objectId.getName())); |
| + } catch (IllegalArgumentException e) { |
| + return null; |
| + } |
| + } |
| +} |