This source file includes following definitions.
- acknowledge
- register
- unregister
- startService
- requestSyncFromContentResolver
- isChromeInForeground
- isSyncEnabled
- setShouldRunStates
package org.chromium.sync.notifier;
import android.accounts.Account;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import com.google.ipc.invalidation.external.client.types.ObjectId;
import org.chromium.base.CollectionUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TestableInvalidationService extends InvalidationService {
final List<List<ObjectId>> mRegistrations = new ArrayList<List<ObjectId>>();
final List<List<ObjectId>> mUnregistrations = new ArrayList<List<ObjectId>>();
final Set<ObjectId> mCurrentRegistrations = new HashSet<ObjectId>();
final List<Intent> mStartedServices = new ArrayList<Intent>();
final List<Bundle> mRequestedSyncs = new ArrayList<Bundle>();
final List<byte[]> mAcknowledgements = new ArrayList<byte[]>();
private boolean mIsChromeInForeground = false;
private boolean mIsSyncEnabled = false;
public TestableInvalidationService() {
}
@Override
public void acknowledge(byte[] ackHandle) {
mAcknowledgements.add(ackHandle);
}
@Override
public void register(byte[] clientId, Iterable<ObjectId> objectIds) {
List<ObjectId> objectIdList = CollectionUtil.newArrayList(objectIds);
mRegistrations.add(objectIdList);
mCurrentRegistrations.addAll(objectIdList);
super.register(clientId, objectIds);
}
@Override
public void unregister(byte[] clientId, Iterable<ObjectId> objectIds) {
List<ObjectId> objectIdList = CollectionUtil.newArrayList(objectIds);
mUnregistrations.add(objectIdList);
mCurrentRegistrations.removeAll(objectIdList);
super.unregister(clientId, objectIds);
}
@Override
public ComponentName startService(Intent intent) {
mStartedServices.add(intent);
return super.startService(intent);
}
@Override
public void requestSyncFromContentResolver(Bundle bundle, Account account,
String contractAuthority) {
mRequestedSyncs.add(bundle);
super.requestSyncFromContentResolver(bundle, account, contractAuthority);
}
@Override
boolean isChromeInForeground() {
return mIsChromeInForeground;
}
@Override
boolean isSyncEnabled() {
return mIsSyncEnabled;
}
void setShouldRunStates(boolean isChromeInForeground, boolean isSyncEnabled) {
this.mIsChromeInForeground = isChromeInForeground;
this.mIsSyncEnabled = isSyncEnabled;
}
}