Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / cacheinvalidation / src / java / com / google / ipc / invalidation / common / ObjectIdDigestUtils.java
index 710b05a..248803e 100644 (file)
@@ -16,9 +16,8 @@
 
 package com.google.ipc.invalidation.common;
 
-import com.google.common.base.Preconditions;
 import com.google.ipc.invalidation.util.Bytes;
-import com.google.protos.ipc.invalidation.ClientProtocol.ObjectIdP;
+import com.google.ipc.invalidation.util.Preconditions;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -29,13 +28,12 @@ import java.security.NoSuchAlgorithmException;
  * Digest-related utilities for object ids.
  *
  */
-
 public class ObjectIdDigestUtils {
   /**
    * Implementation of {@link DigestFunction} using SHA-1.
    */
-  
-  public static class Sha1DigestFunction implements DigestFunction {
+  public static class Sha1DigestFunction
+      implements DigestFunction {
     /** Digest implementation. */
     private MessageDigest sha1;
 
@@ -79,7 +77,6 @@ public class ObjectIdDigestUtils {
    * <p>
    * REQUIRES: {@code objectIdDigests} iterate in sorted order.
    */
-  
   public static Bytes getDigest(Iterable<Bytes> objectIdDigests, DigestFunction digestFn) {
     digestFn.reset();
     for (Bytes objectIdDigest : objectIdDigests) {
@@ -88,16 +85,18 @@ public class ObjectIdDigestUtils {
     return new Bytes(digestFn.getDigest());
   }
 
-  /** Returns the digest of {@code objectId} using {@code digestFn}. */
-  
-  public static Bytes getDigest(ObjectIdP objectId, DigestFunction digestFn) {
+  /**
+   * Returns the digest for the object id with source {@code objectSource} and name
+   * {@code objectName} using {@code digestFn}.
+   */
+  public static Bytes getDigest(int objectSource, byte[] objectName, DigestFunction digestFn) {
     digestFn.reset();
     ByteBuffer buffer = ByteBuffer.allocate(Integer.SIZE / 8).order(ByteOrder.LITTLE_ENDIAN);
-    buffer.putInt(objectId.getSource());
+    buffer.putInt(objectSource);
 
     // Little endian number for type followed by bytes.
     digestFn.update(buffer.array());
-    digestFn.update(objectId.getName().toByteArray());
+    digestFn.update(objectName);
     return new Bytes(digestFn.getDigest());
   }
 }