зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1252960 - Rename UrlMetadata* table to UrlImageData* r=ahunt
MozReview-Commit-ID: 2TNcctxAbRc --HG-- rename : mobile/android/base/java/org/mozilla/gecko/db/URLMetadataTable.java => mobile/android/base/java/org/mozilla/gecko/db/URLImageDataTable.java extra : source : 7038e10280b2905704687ea6d74020c6c437e114
This commit is contained in:
Родитель
3063243dfc
Коммит
7b36cfa2af
|
@ -2078,7 +2078,7 @@ public final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
upgradeDatabaseFrom25to26(db);
|
||||
break;
|
||||
|
||||
// case 27 occurs in UrlMetadataTable.onUpgrade
|
||||
// case 27 occurs in URLImageDataTable.onUpgrade
|
||||
|
||||
case 28:
|
||||
upgradeDatabaseFrom27to28(db);
|
||||
|
|
|
@ -164,8 +164,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
|
||||
static {
|
||||
sTables = new Table[] {
|
||||
// See awful shortcut assumption hack in getURLMetadataTable.
|
||||
new URLMetadataTable()
|
||||
// See awful shortcut assumption hack in getURLImageDataTable.
|
||||
new URLImageDataTable()
|
||||
};
|
||||
// We will reuse this.
|
||||
HashMap<String, String> map;
|
||||
|
@ -370,8 +370,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
|
||||
// Convenience accessor.
|
||||
// Assumes structure of sTables!
|
||||
private URLMetadataTable getURLMetadataTable() {
|
||||
return (URLMetadataTable) sTables[0];
|
||||
private URLImageDataTable getURLImageDataTable() {
|
||||
return (URLImageDataTable) sTables[0];
|
||||
}
|
||||
|
||||
private static boolean hasFaviconsInProjection(String[] projection) {
|
||||
|
@ -2204,7 +2204,7 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
|
||||
return deleteFavicons(uri, faviconSelection, null) +
|
||||
deleteThumbnails(uri, thumbnailSelection, null) +
|
||||
getURLMetadataTable().deleteUnused(getWritableDatabase(uri));
|
||||
getURLImageDataTable().deleteUnused(getWritableDatabase(uri));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,17 +34,17 @@ public class LocalURLMetadata implements URLMetadata {
|
|||
private final Uri uriWithProfile;
|
||||
|
||||
public LocalURLMetadata(String mProfile) {
|
||||
uriWithProfile = DBUtils.appendProfileWithDefault(mProfile, URLMetadataTable.CONTENT_URI);
|
||||
uriWithProfile = DBUtils.appendProfileWithDefault(mProfile, URLImageDataTable.CONTENT_URI);
|
||||
}
|
||||
|
||||
// A list of columns in the table. It's used to simplify some loops for reading/writing data.
|
||||
private static final Set<String> COLUMNS;
|
||||
static {
|
||||
final HashSet<String> tempModel = new HashSet<>(4);
|
||||
tempModel.add(URLMetadataTable.URL_COLUMN);
|
||||
tempModel.add(URLMetadataTable.TILE_IMAGE_URL_COLUMN);
|
||||
tempModel.add(URLMetadataTable.TILE_COLOR_COLUMN);
|
||||
tempModel.add(URLMetadataTable.TOUCH_ICON_COLUMN);
|
||||
tempModel.add(URLImageDataTable.URL_COLUMN);
|
||||
tempModel.add(URLImageDataTable.TILE_IMAGE_URL_COLUMN);
|
||||
tempModel.add(URLImageDataTable.TILE_COLOR_COLUMN);
|
||||
tempModel.add(URLImageDataTable.TOUCH_ICON_COLUMN);
|
||||
COLUMNS = Collections.unmodifiableSet(tempModel);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class LocalURLMetadata implements URLMetadata {
|
|||
final int bestSize = LoadFaviconResult.selectBestSizeFromList(sizes, preferredSize);
|
||||
final String iconURL = icons.getString(Integer.toString(bestSize));
|
||||
|
||||
data.put(URLMetadataTable.TOUCH_ICON_COLUMN, iconURL);
|
||||
data.put(URLImageDataTable.TOUCH_ICON_COLUMN, iconURL);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.w(LOGTAG, "Exception processing touchIconList for LocalURLMetadata; ignoring.", e);
|
||||
|
@ -169,14 +169,14 @@ public class LocalURLMetadata implements URLMetadata {
|
|||
return Collections.unmodifiableMap(data);
|
||||
}
|
||||
|
||||
final String selection = DBUtils.computeSQLInClause(urlsToQuery.size(), URLMetadataTable.URL_COLUMN);
|
||||
final String selection = DBUtils.computeSQLInClause(urlsToQuery.size(), URLImageDataTable.URL_COLUMN);
|
||||
List<String> columns = requestedColumns;
|
||||
// We need the url to build our final HashMap, so we force it to be included in the query.
|
||||
if (!columns.contains(URLMetadataTable.URL_COLUMN)) {
|
||||
if (!columns.contains(URLImageDataTable.URL_COLUMN)) {
|
||||
// The requestedColumns may be immutable (e.g. if the caller used Collections.singletonList), hence
|
||||
// we have to create a copy.
|
||||
columns = new ArrayList<String>(columns);
|
||||
columns.add(URLMetadataTable.URL_COLUMN);
|
||||
columns.add(URLImageDataTable.URL_COLUMN);
|
||||
}
|
||||
|
||||
final Cursor cursor = cr.query(uriWithProfile,
|
||||
|
@ -191,7 +191,7 @@ public class LocalURLMetadata implements URLMetadata {
|
|||
|
||||
do {
|
||||
final Map<String, Object> metadata = fromCursor(cursor);
|
||||
final String url = cursor.getString(cursor.getColumnIndexOrThrow(URLMetadataTable.URL_COLUMN));
|
||||
final String url = cursor.getString(cursor.getColumnIndexOrThrow(URLImageDataTable.URL_COLUMN));
|
||||
|
||||
data.put(url, metadata);
|
||||
cache.put(url, metadata);
|
||||
|
@ -230,8 +230,8 @@ public class LocalURLMetadata implements URLMetadata {
|
|||
Uri uri = uriWithProfile.buildUpon()
|
||||
.appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true")
|
||||
.build();
|
||||
cr.update(uri, values, URLMetadataTable.URL_COLUMN + "=?", new String[] {
|
||||
(String) data.get(URLMetadataTable.URL_COLUMN)
|
||||
cr.update(uri, values, URLImageDataTable.URL_COLUMN + "=?", new String[] {
|
||||
(String) data.get(URLImageDataTable.URL_COLUMN)
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOGTAG, "error saving", ex);
|
||||
|
|
|
@ -13,8 +13,8 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import android.net.Uri;
|
||||
|
||||
// Holds metadata info about urls. Supports some helper functions for getting back a HashMap of key value data.
|
||||
public class URLMetadataTable extends BaseTable {
|
||||
private static final String LOGTAG = "GeckoURLMetadataTable";
|
||||
public class URLImageDataTable extends BaseTable {
|
||||
private static final String LOGTAG = "GeckoURLImageDataTable";
|
||||
|
||||
private static final String TABLE = "metadata"; // Name of the table in the db
|
||||
private static final int TABLE_ID_NUMBER = BrowserProvider.METADATA;
|
||||
|
@ -29,7 +29,7 @@ public class URLMetadataTable extends BaseTable {
|
|||
public static final String TILE_COLOR_COLUMN = "tileColor";
|
||||
public static final String TOUCH_ICON_COLUMN = "touchIcon";
|
||||
|
||||
URLMetadataTable() { }
|
||||
URLImageDataTable() { }
|
||||
|
||||
@Override
|
||||
protected String getTable() {
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import static org.mozilla.gecko.db.URLMetadataTable.TILE_COLOR_COLUMN;
|
||||
import static org.mozilla.gecko.db.URLMetadataTable.TILE_IMAGE_URL_COLUMN;
|
||||
import static org.mozilla.gecko.db.URLImageDataTable.TILE_COLOR_COLUMN;
|
||||
import static org.mozilla.gecko.db.URLImageDataTable.TILE_IMAGE_URL_COLUMN;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
|
@ -382,8 +382,8 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
|||
'db/TabsAccessor.java',
|
||||
'db/TabsProvider.java',
|
||||
'db/UrlAnnotations.java',
|
||||
'db/URLImageDataTable.java',
|
||||
'db/URLMetadata.java',
|
||||
'db/URLMetadataTable.java',
|
||||
'delegates/BookmarkStateChangeDelegate.java',
|
||||
'delegates/BrowserAppDelegate.java',
|
||||
'delegates/BrowserAppDelegateWithReference.java',
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.mozilla.gecko.db.BrowserContract;
|
|||
import org.mozilla.gecko.db.BrowserContract.UrlAnnotations.SyncStatus;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.db.URLMetadata;
|
||||
import org.mozilla.gecko.db.URLMetadataTable;
|
||||
import org.mozilla.gecko.db.URLImageDataTable;
|
||||
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentProviderResult;
|
||||
|
@ -198,10 +198,10 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
private ContentValues createUrlMetadataEntry(final String url, final String tileImage, final String tileColor,
|
||||
final String touchIcon) {
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(URLMetadataTable.URL_COLUMN, url);
|
||||
values.put(URLMetadataTable.TILE_IMAGE_URL_COLUMN, tileImage);
|
||||
values.put(URLMetadataTable.TILE_COLOR_COLUMN, tileColor);
|
||||
values.put(URLMetadataTable.TOUCH_ICON_COLUMN, touchIcon);
|
||||
values.put(URLImageDataTable.URL_COLUMN, url);
|
||||
values.put(URLImageDataTable.TILE_IMAGE_URL_COLUMN, tileImage);
|
||||
values.put(URLImageDataTable.TILE_COLOR_COLUMN, tileColor);
|
||||
values.put(URLImageDataTable.TOUCH_ICON_COLUMN, touchIcon);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
@ -261,8 +261,8 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
}
|
||||
|
||||
private Cursor getUrlMetadataByUrl(final String url) throws Exception {
|
||||
return mProvider.query(URLMetadataTable.CONTENT_URI, null,
|
||||
URLMetadataTable.URL_COLUMN + " = ?",
|
||||
return mProvider.query(URLImageDataTable.CONTENT_URI, null,
|
||||
URLImageDataTable.URL_COLUMN + " = ?",
|
||||
new String[] { url },
|
||||
null);
|
||||
}
|
||||
|
@ -1535,9 +1535,9 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
final String touchIcon = "http://mozilla.org/touchIcon.png";
|
||||
|
||||
// We can only use update since the redirection machinery doesn't exist for insert
|
||||
mProvider.update(URLMetadataTable.CONTENT_URI.buildUpon().appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true").build(),
|
||||
mProvider.update(URLImageDataTable.CONTENT_URI.buildUpon().appendQueryParameter(BrowserContract.PARAM_INSERT_IF_NEEDED, "true").build(),
|
||||
createUrlMetadataEntry(url1, tileImage, tileColor, touchIcon),
|
||||
URLMetadataTable.URL_COLUMN + "=?",
|
||||
URLImageDataTable.URL_COLUMN + "=?",
|
||||
new String[] {url1}
|
||||
);
|
||||
|
||||
|
@ -1555,10 +1555,10 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
final String touchIcon = "http://hello.org/touchIcon.png";
|
||||
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
data.put(URLMetadataTable.URL_COLUMN, url2);
|
||||
data.put(URLMetadataTable.TILE_IMAGE_URL_COLUMN, tileImage);
|
||||
data.put(URLMetadataTable.TILE_COLOR_COLUMN, tileColor);
|
||||
data.put(URLMetadataTable.TOUCH_ICON_COLUMN, touchIcon);
|
||||
data.put(URLImageDataTable.URL_COLUMN, url2);
|
||||
data.put(URLImageDataTable.TILE_IMAGE_URL_COLUMN, tileImage);
|
||||
data.put(URLImageDataTable.TILE_COLOR_COLUMN, tileColor);
|
||||
data.put(URLImageDataTable.TOUCH_ICON_COLUMN, touchIcon);
|
||||
|
||||
BrowserDB.from(getTestProfile()).getURLMetadata().save(mResolver, data);
|
||||
|
||||
|
@ -1586,22 +1586,22 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
// 1: retrieve just touch Icons for URL 1
|
||||
results = metadata.getForURLs(mResolver,
|
||||
Collections.singletonList(url1),
|
||||
Collections.singletonList(URLMetadataTable.TOUCH_ICON_COLUMN));
|
||||
Collections.singletonList(URLImageDataTable.TOUCH_ICON_COLUMN));
|
||||
|
||||
mAsserter.is(results.containsKey(url1), true, "URL 1 not found in results");
|
||||
|
||||
urlData = results.get(url1);
|
||||
mAsserter.is(urlData.containsKey(URLMetadataTable.TOUCH_ICON_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLImageDataTable.TOUCH_ICON_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
|
||||
// 2: retrieve just tile color for URL 2
|
||||
results = metadata.getForURLs(mResolver,
|
||||
Collections.singletonList(url2),
|
||||
Collections.singletonList(URLMetadataTable.TILE_COLOR_COLUMN));
|
||||
Collections.singletonList(URLImageDataTable.TILE_COLOR_COLUMN));
|
||||
|
||||
mAsserter.is(results.containsKey(url2), true, "URL 2 not found in results");
|
||||
|
||||
urlData = results.get(url2);
|
||||
mAsserter.is(urlData.containsKey(URLMetadataTable.TILE_COLOR_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLImageDataTable.TILE_COLOR_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
|
||||
|
||||
// 3: retrieve all columns for both URLs
|
||||
|
@ -1609,9 +1609,9 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
|
||||
results = metadata.getForURLs(mResolver,
|
||||
urls,
|
||||
Arrays.asList(URLMetadataTable.TILE_IMAGE_URL_COLUMN,
|
||||
URLMetadataTable.TILE_COLOR_COLUMN,
|
||||
URLMetadataTable.TOUCH_ICON_COLUMN
|
||||
Arrays.asList(URLImageDataTable.TILE_IMAGE_URL_COLUMN,
|
||||
URLImageDataTable.TILE_COLOR_COLUMN,
|
||||
URLImageDataTable.TOUCH_ICON_COLUMN
|
||||
));
|
||||
|
||||
mAsserter.is(results.containsKey(url1), true, "URL 1 not found in results");
|
||||
|
@ -1620,9 +1620,9 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
|
||||
for (final String url : urls) {
|
||||
urlData = results.get(url);
|
||||
mAsserter.is(urlData.containsKey(URLMetadataTable.TILE_IMAGE_URL_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLMetadataTable.TILE_COLOR_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLMetadataTable.TOUCH_ICON_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLImageDataTable.TILE_IMAGE_URL_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLImageDataTable.TILE_COLOR_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
mAsserter.is(urlData.containsKey(URLImageDataTable.TOUCH_ICON_COLUMN), true, "touchIcon column missing in UrlMetadata results");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче