com.google.ipc.invalidation.common.ObjectIdDigestUtils Java Examples

The following examples show how to use com.google.ipc.invalidation.common.ObjectIdDigestUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<ObjectIdP> add(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> addedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.put(ObjectIdDigestUtils.getDigest(oid.getSource(),
        oid.getName().getByteArray(), digestFunction), oid) == null) {
      // There was no previous value, so this is a new item.
      addedOids.add(oid);
    }
  }
  if (!addedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return addedOids;
}
 
Example #2
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Collection<ObjectIdP> remove(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> removedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.remove(ObjectIdDigestUtils.getDigest(oid, digestFunction)) != null) {
      removedOids.add(oid);
    }
  }
  if (!removedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return removedOids;
}
 
Example #3
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Collection<ObjectIdP> remove(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> removedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.remove(ObjectIdDigestUtils.getDigest(oid, digestFunction)) != null) {
      removedOids.add(oid);
    }
  }
  if (!removedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return removedOids;
}
 
Example #4
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean remove(ObjectIdP oid) {
  if (registrations.remove(ObjectIdDigestUtils.getDigest(oid, digestFunction)) != null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #5
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Collection<ObjectIdP> add(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> addedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.put(ObjectIdDigestUtils.getDigest(oid, digestFunction), oid) == null) {
      // There was no previous value, so this is a new item.
      addedOids.add(oid);
    }
  }
  if (!addedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return addedOids;
}
 
Example #6
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean add(ObjectIdP oid) {
  if (registrations.put(ObjectIdDigestUtils.getDigest(oid, digestFunction), oid) == null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #7
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override

public RegistrationManagerState getRegistrationManagerStateCopyForTest() {
  Preconditions.checkState(resources.getInternalScheduler().isRunningOnThread());
  return registrationManager.getRegistrationManagerStateCopyForTest(
      new ObjectIdDigestUtils.Sha1DigestFunction());
}
 
Example #8
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean add(ObjectIdP oid) {
  if (registrations.put(ObjectIdDigestUtils.getDigest(oid.getSource(),
      oid.getName().getByteArray(), digestFunction), oid) == null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #9
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean remove(ObjectIdP oid) {
  if (registrations.remove(ObjectIdDigestUtils.getDigest(oid, digestFunction)) != null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #10
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Collection<ObjectIdP> add(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> addedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.put(ObjectIdDigestUtils.getDigest(oid, digestFunction), oid) == null) {
      // There was no previous value, so this is a new item.
      addedOids.add(oid);
    }
  }
  if (!addedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return addedOids;
}
 
Example #11
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean add(ObjectIdP oid) {
  if (registrations.put(ObjectIdDigestUtils.getDigest(oid, digestFunction), oid) == null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #12
Source File: InvalidationClientCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override

public RegistrationManagerState getRegistrationManagerStateCopyForTest() {
  Preconditions.checkState(resources.getInternalScheduler().isRunningOnThread());
  return registrationManager.getRegistrationManagerStateCopyForTest(
      new ObjectIdDigestUtils.Sha1DigestFunction());
}
 
Example #13
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<ObjectIdP> remove(Collection<ObjectIdP> oids) {
  Collection<ObjectIdP> removedOids = new ArrayList<ObjectIdP>();
  for (ObjectIdP oid : oids) {
    if (registrations.remove(ObjectIdDigestUtils.getDigest(oid.getSource(),
        oid.getName().getByteArray(), digestFunction)) != null) {
      removedOids.add(oid);
    }
  }
  if (!removedOids.isEmpty()) {
    // Only recompute the digest if we made changes.
    recomputeDigest();
  }
  return removedOids;
}
 
Example #14
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean remove(ObjectIdP oid) {
  if (registrations.remove(ObjectIdDigestUtils.getDigest(oid.getSource(),
      oid.getName().getByteArray(), digestFunction)) != null) {
    recomputeDigest();
    return true;
  }
  return false;
}
 
Example #15
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean contains(ObjectIdP oid) {
  return registrations.containsKey(ObjectIdDigestUtils.getDigest(oid, digestFunction));
}
 
Example #16
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** Recomputes the digests over all objects and sets {@code this.digest}. */
private void recomputeDigest() {
  this.digest = ObjectIdDigestUtils.getDigest(registrations.keySet(), digestFunction);
}
 
Example #17
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Recomputes the digests over all objects and sets {@code this.digest}. */
private void recomputeDigest() {
  this.digest = ObjectIdDigestUtils.getDigest(registrations.keySet(), digestFunction);
}
 
Example #18
Source File: SimpleRegistrationStore.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public boolean contains(ObjectIdP oid) {
  return registrations.containsKey(ObjectIdDigestUtils.getDigest(oid.getSource(),
      oid.getName().getByteArray(), digestFunction));
}
 
Example #19
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public boolean contains(ObjectIdP oid) {
  return registrations.containsKey(ObjectIdDigestUtils.getDigest(oid, digestFunction));
}
 
Example #20
Source File: SimpleRegistrationStore.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** Recomputes the digests over all objects and sets {@code this.digest}. */
private void recomputeDigest() {
  this.digest = ObjectIdDigestUtils.getDigest(registrations.keySet(), digestFunction);
}