Bug 984740 - When calling notifyChange, don't request an upload sync if the caller is Sync. r=nalexander

This commit is contained in:
Richard Newman 2014-03-18 19:20:07 -07:00
Родитель 736dff6935
Коммит 956ddc0952
3 изменённых файлов: 43 добавлений и 13 удалений

Просмотреть файл

@ -66,6 +66,14 @@ public abstract class SQLiteBridgeContentProvider extends ContentProvider {
shutdown();
}
/**
* Return true of the query is from Firefox Sync.
* @param uri query URI
*/
public static boolean isCallerSync(Uri uri) {
String isSync = uri.getQueryParameter(BrowserContract.PARAM_IS_SYNC);
return !TextUtils.isEmpty(isSync);
}
private SQLiteBridge getDB(Context context, final String databasePath) {
SQLiteBridge bridge = null;
@ -327,7 +335,8 @@ public abstract class SQLiteBridgeContentProvider extends ContentProvider {
}
if (rowsAdded > 0) {
mContext.getContentResolver().notifyChange(uri, null);
final boolean shouldSyncToNetwork = !isCallerSync(uri);
mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return rowsAdded;

Просмотреть файл

@ -107,6 +107,15 @@ public class TabsProvider extends ContentProvider {
}
}
/**
* Return true of the query is from Firefox Sync.
* @param uri query URI
*/
public static boolean isCallerSync(Uri uri) {
String isSync = uri.getQueryParameter(BrowserContract.PARAM_IS_SYNC);
return !TextUtils.isEmpty(isSync);
}
final class TabsDatabaseHelper extends SQLiteOpenHelper {
public TabsDatabaseHelper(Context context, String databasePath) {
super(context, databasePath, null, DATABASE_VERSION);
@ -297,8 +306,10 @@ public class TabsProvider extends ContentProvider {
deleted = deleteInTransaction(uri, selection, selectionArgs);
}
if (deleted > 0)
getContext().getContentResolver().notifyChange(uri, null);
if (deleted > 0) {
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return deleted;
}
@ -365,8 +376,10 @@ public class TabsProvider extends ContentProvider {
result = insertInTransaction(uri, values);
}
if (result != null)
getContext().getContentResolver().notifyChange(uri, null);
if (result != null) {
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return result;
}
@ -425,8 +438,10 @@ public class TabsProvider extends ContentProvider {
updated = updateInTransaction(uri, values, selection, selectionArgs);
}
if (updated > 0)
getContext().getContentResolver().notifyChange(uri, null);
if (updated > 0) {
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return updated;
}
@ -577,8 +592,10 @@ public class TabsProvider extends ContentProvider {
db.endTransaction();
}
if (successes > 0)
mContext.getContentResolver().notifyChange(uri, null);
if (successes > 0) {
final boolean shouldSyncToNetwork = !isCallerSync(uri);
mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return successes;
}

Просмотреть файл

@ -353,7 +353,8 @@ public abstract class TransactionalProvider<T extends SQLiteOpenHelper> extends
}
if (deleted > 0) {
getContext().getContentResolver().notifyChange(uri, null);
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return deleted;
@ -377,7 +378,8 @@ public abstract class TransactionalProvider<T extends SQLiteOpenHelper> extends
}
if (result != null) {
getContext().getContentResolver().notifyChange(uri, null);
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return result;
@ -401,7 +403,8 @@ public abstract class TransactionalProvider<T extends SQLiteOpenHelper> extends
}
if (updated > 0) {
getContext().getContentResolver().notifyChange(uri, null);
final boolean shouldSyncToNetwork = !isCallerSync(uri);
getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return updated;
@ -434,7 +437,8 @@ public abstract class TransactionalProvider<T extends SQLiteOpenHelper> extends
}
if (successes > 0) {
mContext.getContentResolver().notifyChange(uri, null);
final boolean shouldSyncToNetwork = !isCallerSync(uri);
mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork);
}
return successes;