merge fx-team to mozilla-central

This commit is contained in:
Carsten "Tomcat" Book 2014-02-24 12:54:35 +01:00
Родитель 79dfc8c78d 355d73083d
Коммит 1a54de3afd
11 изменённых файлов: 560 добавлений и 380 удалений

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

@ -49,9 +49,20 @@
<!-- Firefox Accounts stuff -->
<!ENTITY fxaPrivacyNotice.link.label "Privacy Notice">
<!ENTITY determiningAcctStatus.label "Determining your account status…">
<!-- LOCALIZATION NOTE (signedInUnverified.beforename.label,
signedInUnverified.aftername.label): these two string are used respectively
before and after the account email address. Localizers can use one of them, or
both, to better adapt this sentence to their language.
-->
<!ENTITY signedInUnverified.beforename.label "">
<!ENTITY signedInUnverified.aftername.label "is not verified.">
<!-- LOCALIZATION NOTE (signedInLoginFailure.beforename.label,
signedInLoginFailure.aftername.label): these two string are used respectively
before and after the account email address. Localizers can use one of them, or
both, to better adapt this sentence to their language.
-->
<!ENTITY signedInLoginFailure.beforename.label "Please sign in to reconnect">
<!ENTITY signedInLoginFailure.aftername.label "">

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

@ -65,17 +65,23 @@ public class testBrowserProvider extends ContentProviderTest {
BrowserContract.Bookmarks.READING_LIST_FOLDER_GUID });
c = mProvider.query(appendUriParam(BrowserContract.Bookmarks.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), null, null, null, null);
mAsserter.is(c.getCount(), 7, "All non-special bookmarks and folders were deleted");
assertCountIsAndClose(c, 7, "All non-special bookmarks and folders were deleted");
mProvider.delete(appendUriParam(BrowserContract.History.CONTENT_URI, BrowserContract.PARAM_IS_SYNC, "1"), null, null);
c = mProvider.query(appendUriParam(BrowserContract.History.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), null, null, null, null);
mAsserter.is(c.getCount(), 0, "All history entries were deleted");
assertCountIsAndClose(c, 0, "All history entries were deleted");
mProvider.delete(BrowserContract.Favicons.CONTENT_URI, null, null);
mAsserter.is(c.getCount(), 0, "All favicons were deleted");
mProvider.delete(appendUriParam(BrowserContract.Favicons.CONTENT_URI, BrowserContract.PARAM_IS_SYNC, "1"), null, null);
c = mProvider.query(appendUriParam(BrowserContract.Favicons.CONTENT_URI,
BrowserContract.PARAM_SHOW_DELETED, "1"),
null, null, null, null);
assertCountIsAndClose(c, 0, "All favicons were deleted");
mProvider.delete(BrowserContract.Thumbnails.CONTENT_URI, null, null);
mAsserter.is(c.getCount(), 0, "All thumbnails were deleted");
mProvider.delete(appendUriParam(BrowserContract.Thumbnails.CONTENT_URI, BrowserContract.PARAM_IS_SYNC, "1"), null, null);
c = mProvider.query(appendUriParam(BrowserContract.Thumbnails.CONTENT_URI,
BrowserContract.PARAM_SHOW_DELETED, "1"),
null, null, null, null);
assertCountIsAndClose(c, 0, "All thumbnails were deleted");
}
private ContentValues createBookmark(String title, String url, long parentId,
@ -326,7 +332,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(seenException, false, "Batch updating succeded");
mOperations.clear();
// Delte all visits
// Delete all visits
for (int i = 0; i < TESTCOUNT; i++) {
builder = ContentProviderOperation.newDelete(BrowserContract.History.CONTENT_URI);
builder.withSelection(BrowserContract.History.URL + " = ?",
@ -340,7 +346,7 @@ public class testBrowserProvider extends ContentProviderTest {
} catch (OperationApplicationException ex) {
seenException = true;
}
mAsserter.is(seenException, false, "Batch deletion succeded");
mAsserter.is(seenException, false, "Batch deletion succeeded");
}
// Force a Constraint error, see if later operations still apply correctly
@ -475,6 +481,8 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(new Integer(parentId), new Integer(rootId),
"The PARENT of the " + guid + " special folder is correct");
}
c.close();
}
}
@ -549,6 +557,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.Bookmarks.TYPE)), String.valueOf(BrowserContract.Bookmarks.TYPE_BOOKMARK),
"Inserted bookmark has correct default type");
c.close();
}
}
@ -571,12 +580,14 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Bookmarks.FAVICON)), "UTF8"),
favicon, "Inserted bookmark has corresponding favicon image");
c.close();
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Inserted favicon found");
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Combined.FAVICON)), "UTF8"),
favicon, "Inserted favicon has corresponding favicon image");
c.close();
}
}
@ -587,6 +598,7 @@ public class testBrowserProvider extends ContentProviderTest {
Cursor c = getBookmarkById(id);
mAsserter.is(c.moveToFirst(), true, "Inserted bookmark found");
c.close();
return id;
}
@ -603,6 +615,7 @@ public class testBrowserProvider extends ContentProviderTest {
Cursor c = getBookmarkById(appendUriParam(BrowserContract.Bookmarks.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), id);
mAsserter.is(c.moveToFirst(), true, "Deleted bookmark was only marked as deleted");
c.close();
deleted = mProvider.delete(appendUriParam(BrowserContract.Bookmarks.CONTENT_URI, BrowserContract.PARAM_IS_SYNC, "1"),
BrowserContract.Bookmarks._ID + " = ?",
@ -612,6 +625,7 @@ public class testBrowserProvider extends ContentProviderTest {
c = getBookmarkById(appendUriParam(BrowserContract.Bookmarks.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), id);
mAsserter.is(c.moveToFirst(), false, "Inserted bookmark is now actually deleted");
c.close();
id = insertOneBookmark();
@ -622,6 +636,7 @@ public class testBrowserProvider extends ContentProviderTest {
c = getBookmarkById(id);
mAsserter.is(c.moveToFirst(), false,
"Inserted bookmark can't be found after deletion using URI with ID");
c.close();
if (Build.VERSION.SDK_INT >= 8 &&
Build.VERSION.SDK_INT < 16) {
@ -631,6 +646,7 @@ public class testBrowserProvider extends ContentProviderTest {
long parentId = ContentUris.parseId(mProvider.insert(BrowserContract.Bookmarks.CONTENT_URI, b));
c = getBookmarkById(parentId);
mAsserter.is(c.moveToFirst(), true, "Inserted bookmarks folder found");
c.close();
b = createBookmark("Example", "http://example.com", parentId,
BrowserContract.Bookmarks.TYPE_BOOKMARK, 0, "tags", "description", "keyword");
@ -638,6 +654,7 @@ public class testBrowserProvider extends ContentProviderTest {
id = ContentUris.parseId(mProvider.insert(BrowserContract.Bookmarks.CONTENT_URI, b));
c = getBookmarkById(id);
mAsserter.is(c.moveToFirst(), true, "Inserted bookmark found");
c.close();
deleted = 0;
try {
@ -664,11 +681,13 @@ public class testBrowserProvider extends ContentProviderTest {
Cursor c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Inserted favicon found");
c.close();
mProvider.delete(ContentUris.withAppendedId(BrowserContract.Bookmarks.CONTENT_URI, id), null, null);
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), false, "Favicon is deleted with last reference to it");
c.close();
}
}
@ -713,6 +732,7 @@ public class testBrowserProvider extends ContentProviderTest {
new String[] { String.valueOf(id) });
mAsserter.is((updated == 1), true, "Inserted bookmark was updated");
c.close();
c = getBookmarkById(id);
mAsserter.is(c.moveToFirst(), true, "Updated bookmark found");
@ -752,12 +772,14 @@ public class testBrowserProvider extends ContentProviderTest {
u.put(BrowserContract.Bookmarks.URL, "http://examples2.com");
updated = mProvider.update(ContentUris.withAppendedId(BrowserContract.Bookmarks.CONTENT_URI, id), u, null, null);
c.close();
c = getBookmarkById(id);
mAsserter.is(c.moveToFirst(), true, "Updated bookmark found");
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.Bookmarks.URL)), u.getAsString(BrowserContract.Bookmarks.URL),
"Updated bookmark has correct URL using URI with id");
c.close();
}
}
@ -784,12 +806,14 @@ public class testBrowserProvider extends ContentProviderTest {
ContentValues u = createFaviconEntry(pageUrl, newFavicon);
mProvider.update(BrowserContract.Favicons.CONTENT_URI, u, null, null);
c.close();
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Updated favicon found");
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Combined.FAVICON)), "UTF8"),
newFavicon, "Updated favicon has corresponding favicon image");
c.close();
}
}
@ -825,6 +849,7 @@ public class testBrowserProvider extends ContentProviderTest {
}
mAsserter.is(i, count, "Folder has the right number of children.");
c.close();
}
public static final int NUMBER_OF_CHILDREN = 1001;
@ -921,6 +946,7 @@ public class testBrowserProvider extends ContentProviderTest {
id = insertWithNullCol(BrowserContract.History.VISITS);
mAsserter.is(new Long(id), new Long(-1),
"Should not be able to insert history with null number of visits");
c.close();
}
}
@ -943,12 +969,14 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.History.FAVICON)), "UTF8"),
favicon, "Inserted history entry has corresponding favicon image");
c.close();
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Inserted favicon found");
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Combined.FAVICON)), "UTF8"),
favicon, "Inserted favicon has corresponding favicon image");
c.close();
}
}
@ -959,6 +987,7 @@ public class testBrowserProvider extends ContentProviderTest {
Cursor c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "Inserted history entry found");
c.close();
return id;
}
@ -981,6 +1010,7 @@ public class testBrowserProvider extends ContentProviderTest {
new String[] { String.valueOf(id) });
mAsserter.is((deleted == 1), true, "Inserted history entry was deleted");
c.close();
c = getHistoryEntryById(appendUriParam(BrowserContract.History.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), id);
mAsserter.is(c.moveToFirst(), false, "Inserted history is now actually deleted");
@ -990,10 +1020,12 @@ public class testBrowserProvider extends ContentProviderTest {
deleted = mProvider.delete(ContentUris.withAppendedId(BrowserContract.History.CONTENT_URI, id), null, null);
mAsserter.is((deleted == 1), true,
"Inserted history entry was deleted using URI with id");
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), false,
"Inserted history entry can't be found after deletion using URI with ID");
c.close();
}
}
@ -1012,9 +1044,11 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(c.moveToFirst(), true, "Inserted favicon found");
mProvider.delete(ContentUris.withAppendedId(BrowserContract.History.CONTENT_URI, id), null, null);
c.close();
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), false, "Favicon is deleted with last reference to it");
c.close();
}
}
@ -1056,6 +1090,7 @@ public class testBrowserProvider extends ContentProviderTest {
new String[] { String.valueOf(id) });
mAsserter.is((updated == 1), true, "Inserted history entry was updated");
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "Updated history entry found");
@ -1089,12 +1124,14 @@ public class testBrowserProvider extends ContentProviderTest {
u.put(BrowserContract.History.URL, "http://examples2.com");
updated = mProvider.update(ContentUris.withAppendedId(BrowserContract.History.CONTENT_URI, id), u, null, null);
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "Updated history entry found");
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.History.URL)), u.getAsString(BrowserContract.History.URL),
"Updated history entry has correct URL using URI with id");
c.close();
}
}
@ -1121,12 +1158,14 @@ public class testBrowserProvider extends ContentProviderTest {
ContentValues u = createFaviconEntry(pageUrl, newFavicon);
mProvider.update(BrowserContract.Favicons.CONTENT_URI, u, null, null);
c.close();
c = getFaviconsByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Updated favicon found");
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Combined.FAVICON)), "UTF8"),
newFavicon, "Updated favicon has corresponding favicon image");
c.close();
}
}
@ -1195,6 +1234,7 @@ public class testBrowserProvider extends ContentProviderTest {
BrowserContract.History._ID + " = ?",
new String[] { String.valueOf(id) });
mAsserter.is((updated == 1), true, "Inserted history entry was updated");
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "Updated history entry found");
@ -1220,6 +1260,8 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is((updated == 1), true, "History entry was inserted");
id = getHistoryEntryIdByUrl(TEST_URL_2);
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "History entry was inserted");
@ -1239,6 +1281,7 @@ public class testBrowserProvider extends ContentProviderTest {
BrowserContract.History._ID + " = ?",
new String[] { String.valueOf(id) });
mAsserter.is((updated == 1), true, "Inserted history entry was updated");
c.close();
c = getHistoryEntryById(id);
mAsserter.is(c.moveToFirst(), true, "Updated history entry found");
@ -1253,6 +1296,7 @@ public class testBrowserProvider extends ContentProviderTest {
"Updated history entry has same creation date");
mAsserter.isnot(new Long(c.getLong(c.getColumnIndex(BrowserContract.History.DATE_MODIFIED))), new Long(dateModified),
"Updated history entry has new modification date");
c.close();
}
}
@ -1275,6 +1319,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Thumbnails.DATA)), "UTF8"),
thumbnail, "Inserted thumbnail has corresponding thumbnail image");
c.close();
}
}
@ -1301,12 +1346,14 @@ public class testBrowserProvider extends ContentProviderTest {
ContentValues u = createThumbnailEntry(pageUrl, newThumbnail);
mProvider.update(BrowserContract.Thumbnails.CONTENT_URI, u, null, null);
c.close();
c = getThumbnailByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), true, "Updated thumbnail found");
mAsserter.is(new String(c.getBlob(c.getColumnIndex(BrowserContract.Thumbnails.DATA)), "UTF8"),
newThumbnail, "Updated thumbnail has corresponding thumbnail image");
c.close();
}
}
@ -1325,9 +1372,11 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(c.moveToFirst(), true, "Inserted thumbnail found");
mProvider.delete(ContentUris.withAppendedId(BrowserContract.History.CONTENT_URI, id), null, null);
c.close();
c = getThumbnailByUrl(pageUrl);
mAsserter.is(c.moveToFirst(), false, "Thumbnail is deleted with last reference to it");
c.close();
}
}
@ -1435,6 +1484,7 @@ public class testBrowserProvider extends ContentProviderTest {
"Combined entry has correct number of visits");
mAsserter.is(new Long(c.getLong(c.getColumnIndex(BrowserContract.Combined.DATE_LAST_VISITED))), new Long(LAST_VISITED),
"Combined entry has correct last visit time");
c.close();
}
}
@ -1495,6 +1545,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(new Integer(display), new Integer(expectedDisplay),
"Combined display column should always be DISPLAY_READER for the reading list item");
}
c.close();
}
}
@ -1527,6 +1578,7 @@ public class testBrowserProvider extends ContentProviderTest {
new String[] { String.valueOf(combinedBookmarkId) });
mAsserter.is((deleted == 1), true, "Inserted combined bookmark was deleted");
c.close();
c = mProvider.query(BrowserContract.Combined.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), 1, "1 combined entry found");
@ -1534,6 +1586,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(c.moveToFirst(), true, "Found combined entry without bookmark id");
mAsserter.is(new Long(c.getLong(c.getColumnIndex(BrowserContract.Combined.BOOKMARK_ID))), new Long(0),
"Bookmark id should not be set to removed bookmark id");
c.close();
}
}
@ -1569,6 +1622,7 @@ public class testBrowserProvider extends ContentProviderTest {
new String[] { String.valueOf(combinedReadingListItemId) });
mAsserter.is((deleted == 1), true, "Inserted combined reading list item was deleted");
c.close();
c = mProvider.query(BrowserContract.Combined.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), 1, "1 combined entry found");
@ -1578,6 +1632,7 @@ public class testBrowserProvider extends ContentProviderTest {
"Bookmark id should not be set to removed bookmark id");
mAsserter.is(new Long(c.getLong(c.getColumnIndex(BrowserContract.Combined.DISPLAY))), new Long(BrowserContract.Combined.DISPLAY_NORMAL),
"Combined entry should have reader display type");
c.close();
}
}
@ -1608,7 +1663,8 @@ public class testBrowserProvider extends ContentProviderTest {
}
Cursor c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), count, count + " history entries found");
assertCountIsAndClose(c, count, count + " history entries found");
// add thumbnails for each entry
allVals = new ContentValues[count];
@ -1622,7 +1678,7 @@ public class testBrowserProvider extends ContentProviderTest {
mAsserter.is(inserts, count, "Expected number of inserts matches");
c = mProvider.query(BrowserContract.Thumbnails.CONTENT_URI, null, null, null, null);
mAsserter.is(c.getCount(), count, count + " thumbnails entries found");
assertCountIsAndClose(c, count, count + " thumbnails entries found");
}
@Override
@ -1637,57 +1693,61 @@ public class testBrowserProvider extends ContentProviderTest {
Uri url = appendUriParam(BrowserContract.History.CONTENT_OLD_URI, BrowserContract.PARAM_EXPIRE_PRIORITY, "NORMAL");
mProvider.delete(url, null, null);
Cursor c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), count, count + " history entries found");
assertCountIsAndClose(c, count, count + " history entries found");
// expiring with a normal priority should delete all but 10 thumbnails
c = mProvider.query(BrowserContract.Thumbnails.CONTENT_URI, null, null, null, null);
mAsserter.is(c.getCount(), thumbCount, thumbCount + " thumbnails found");
assertCountIsAndClose(c, thumbCount, thumbCount + " thumbnails found");
ensureEmptyDatabase();
// insert a bunch of new entries
// Insert a bunch of new entries.
createFakeHistory(0, count);
// expiring with a aggressive priority should leave 500 entries
// Expiring with a aggressive priority should leave 500 entries.
url = appendUriParam(BrowserContract.History.CONTENT_OLD_URI, BrowserContract.PARAM_EXPIRE_PRIORITY, "AGGRESSIVE");
mProvider.delete(url, null, null);
c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), 500, "500 history entries found");
// expiring with a aggressive priority should delete all but 10 thumbnails
c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
assertCountIsAndClose(c, 500, "500 history entries found");
// Expiring with a aggressive priority should delete all but 10 thumbnails.
c = mProvider.query(BrowserContract.Thumbnails.CONTENT_URI, null, null, null, null);
mAsserter.is(c.getCount(), thumbCount, thumbCount + " thumbnails found");
assertCountIsAndClose(c, thumbCount, thumbCount + " thumbnails found");
ensureEmptyDatabase();
// insert a bunch of entries with an old time created/modified
// Insert a bunch of entries with an old time created/modified.
long time = 1000L * 60L * 60L * 24L * 30L * 3L;
createFakeHistory(time, count);
// expiring with an normal priority should remove at most 1000 entries
// entries leaving at least 2000
// Expiring with an normal priority should remove at most 1000 entries,
// entries leaving at least 2000.
url = appendUriParam(BrowserContract.History.CONTENT_OLD_URI, BrowserContract.PARAM_EXPIRE_PRIORITY, "NORMAL");
mProvider.delete(url, null, null);
c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), 2000, "2000 history entries found");
// expiring with a normal priority should delete all but 10 thumbnails
c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
assertCountIsAndClose(c, 2000, "2000 history entries found");
// Expiring with a normal priority should delete all but 10 thumbnails.
c = mProvider.query(BrowserContract.Thumbnails.CONTENT_URI, null, null, null, null);
mAsserter.is(c.getCount(), thumbCount, thumbCount + " thumbnails found");
assertCountIsAndClose(c, thumbCount, thumbCount + " thumbnails found");
ensureEmptyDatabase();
// insert a bunch of entries with an old time created/modified
time = 1000L * 60L * 60L * 24L * 30L * 3L;
createFakeHistory(time, count);
// expiring with an agressive priority should remove old
// entries leaving at least 500
// Expiring with an aggressive priority should remove old
// entries, leaving at least 500.
url = appendUriParam(BrowserContract.History.CONTENT_OLD_URI, BrowserContract.PARAM_EXPIRE_PRIORITY, "AGGRESSIVE");
mProvider.delete(url, null, null);
c = mProvider.query(BrowserContract.History.CONTENT_URI, null, "", null, null);
mAsserter.is(c.getCount(), 500, "500 history entries found");
assertCountIsAndClose(c, 500, "500 history entries found");
// expiring with an aggressive priority should delete all but 10 thumbnails
c = mProvider.query(BrowserContract.Thumbnails.CONTENT_URI, null, null, null, null);
mAsserter.is(c.getCount(), thumbCount, thumbCount + " thumbnails found");
assertCountIsAndClose(c, thumbCount, thumbCount + " thumbnails found");
}
}
@ -1776,4 +1836,16 @@ public class testBrowserProvider extends ContentProviderTest {
ensureOnlyChangeNotifiedStartsWith(BrowserContract.History.CONTENT_URI, "bulkInsert");
}
}
/**
* Assert that the provided cursor has the expected number of rows,
* closing the cursor afterwards.
*/
private void assertCountIsAndClose(Cursor c, int expectedCount, String message) {
try {
mAsserter.is(c.getCount(), expectedCount, message);
} finally {
c.close();
}
}
}

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

@ -83,14 +83,70 @@ const DEFAULT_PROVIDERS = [
"resource://gre/modules/LightweightThemeManager.jsm"
];
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function logFuncGetter() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
Cu.import("resource://gre/modules/Log.jsm");
// Configure a logger at the parent 'addons' level to format
// messages for all the modules under addons.*
const PARENT_LOGGER_ID = "addons";
let parentLogger = Log.repository.getLogger(PARENT_LOGGER_ID);
parentLogger.level = Log.Level.Warn;
let formatter = new Log.BasicFormatter();
// Set parent logger (and its children) to append to
// the Javascript section of the Browser Console
parentLogger.addAppender(new Log.ConsoleAppender(formatter));
// Set parent logger (and its children) to
// also append to standard out
parentLogger.addAppender(new Log.DumpAppender(formatter));
LogManager.getLogger("addons.manager", this);
return this[aName];
});
}, this);
// Create a new logger (child of 'addons' logger)
// for use by the Addons Manager
const LOGGER_ID = "addons.manager";
let logger = Log.repository.getLogger(LOGGER_ID);
// Provide the ability to enable/disable logging
// messages at runtime.
// If the "extensions.logging.enabled" preference is
// missing or 'false', messages at the WARNING and higher
// severity should be logged to the JS console and standard error.
// If "extensions.logging.enabled" is set to 'true', messages
// at DEBUG and higher should go to JS console and standard error.
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
/**
* Preference listener which listens for a change in the
* "extensions.logging.enabled" preference and changes the logging level of the
* parent 'addons' level logger accordingly.
*/
var PrefObserver = {
init: function PrefObserver_init() {
Services.prefs.addObserver(PREF_LOGGING_ENABLED, this, false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
this.observe(null, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, PREF_LOGGING_ENABLED);
},
observe: function PrefObserver_observe(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
}
else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) {
let debugLogEnabled = false;
try {
debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED);
}
catch (e) {
}
if (debugLogEnabled) {
parentLogger.level = Log.Level.Debug;
}
else {
parentLogger.level = Log.Level.Warn;
}
}
}
};
PrefObserver.init();
/**
* Calls a callback method consuming any thrown exception. Any parameters after
@ -104,7 +160,7 @@ function safeCall(aCallback, ...aArgs) {
aCallback.apply(null, aArgs);
}
catch (e) {
WARN("Exception calling callback", e);
logger.warn("Exception calling callback", e);
}
}
@ -130,7 +186,7 @@ function callProvider(aProvider, aMethod, aDefault, ...aArgs) {
return aProvider[aMethod].apply(aProvider, aArgs);
}
catch (e) {
ERROR("Exception calling provider " + aMethod, e);
logger.error("Exception calling provider " + aMethod, e);
return aDefault;
}
}
@ -496,7 +552,7 @@ var AddonManagerInternal = {
catch (e) { }
if (appChanged !== false) {
LOG("Application has been upgraded");
logger.debug("Application has been upgraded");
Services.prefs.setCharPref(PREF_EM_LAST_APP_VERSION,
Services.appinfo.version);
Services.prefs.setCharPref(PREF_EM_LAST_PLATFORM_VERSION,
@ -558,7 +614,7 @@ var AddonManagerInternal = {
}
catch (e) {
AddonManagerPrivate.recordException("AMI", "provider " + url + " load failed", e);
ERROR("Exception loading default provider \"" + url + "\"", e);
logger.error("Exception loading default provider \"" + url + "\"", e);
}
});
}
@ -576,7 +632,7 @@ var AddonManagerInternal = {
}
catch (e) {
AddonManagerPrivate.recordException("AMI", "provider " + url + " load failed", e);
ERROR("Exception loading provider " + entry + " from category \"" +
logger.error("Exception loading provider " + entry + " from category \"" +
url + "\"", e);
}
}
@ -601,7 +657,7 @@ var AddonManagerInternal = {
this.recordTimestamp("AMI_startup_end");
}
catch (e) {
ERROR("startup failed", e);
logger.error("startup failed", e);
AddonManagerPrivate.recordException("AMI", "startup failed", e);
}
},
@ -629,7 +685,7 @@ var AddonManagerInternal = {
aTypes.forEach(function(aType) {
if (!(aType.id in this.types)) {
if (!VALID_TYPES_REGEXP.test(aType.id)) {
WARN("Ignoring invalid type " + aType.id);
logger.warn("Ignoring invalid type " + aType.id);
return;
}
@ -716,7 +772,7 @@ var AddonManagerInternal = {
provider[aMethod].apply(provider, aArgs);
}
catch (e) {
ERROR("Exception calling provider " + aMethod, e);
logger.error("Exception calling provider " + aMethod, e);
}
}
},
@ -751,12 +807,12 @@ var AddonManagerInternal = {
// Log and swallow the errors from methods that do return promises.
nextPromise = nextPromise.then(
null,
e => ERROR("Exception calling provider " + aMethod, e));
e => logger.error("Exception calling provider " + aMethod, e));
allProviders.push(nextPromise);
}
}
catch (e) {
ERROR("Exception calling provider " + aMethod, e);
logger.error("Exception calling provider " + aMethod, e);
}
}
// Because we use promise.then to catch and log all errors above, Promise.all()
@ -771,7 +827,7 @@ var AddonManagerInternal = {
* have finished shutting down
*/
shutdown: function AMI_shutdown() {
LOG("shutdown");
logger.debug("shutdown");
// Clean up listeners
Services.prefs.removeObserver(PREF_EM_CHECK_COMPATIBILITY, this);
Services.prefs.removeObserver(PREF_EM_STRICT_COMPATIBILITY, this);
@ -786,15 +842,15 @@ var AddonManagerInternal = {
if (gStarted) {
shuttingDown = this.callProvidersAsync("shutdown")
.then(null,
err => ERROR("Failure during async provider shutdown", err))
err => logger.error("Failure during async provider shutdown", err))
.then(() => AddonRepository.shutdown());
}
else {
shuttingDown = AddonRepository.shutdown();
}
shuttingDown.then(val => LOG("Async provider shutdown done"),
err => ERROR("Failure during AddonRepository shutdown", err))
shuttingDown.then(val => logger.debug("Async provider shutdown done"),
err => logger.error("Failure during AddonRepository shutdown", err))
.then(() => {
this.managerListeners.splice(0, this.managerListeners.length);
this.installListeners.splice(0, this.installListeners.length);
@ -1088,7 +1144,7 @@ var AddonManagerInternal = {
return;
}
LOG("Downloading hotfix version " + update.version);
logger.debug("Downloading hotfix version " + update.version);
AddonManager.getInstallForURL(update.updateURL,
function BUC_getInstallForURL(aInstall) {
aInstall.addListener({
@ -1107,7 +1163,7 @@ var AddonManagerInternal = {
CertUtils.readCertPrefs(PREF_EM_HOTFIX_CERTS));
}
catch (e) {
WARN("The hotfix add-on was not signed by the expected " +
logger.warn("The hotfix add-on was not signed by the expected " +
"certificate and so will not be installed.");
aInstall.cancel();
}
@ -1224,7 +1280,7 @@ var AddonManagerInternal = {
listener[aMethod].apply(listener, aArgs);
}
catch (e) {
WARN("AddonManagerListener threw exception when calling " + aMethod, e);
logger.warn("AddonManagerListener threw exception when calling " + aMethod, e);
}
}
},
@ -1268,7 +1324,7 @@ var AddonManagerInternal = {
}
}
catch (e) {
WARN("InstallListener threw exception when calling " + aMethod, e);
logger.warn("InstallListener threw exception when calling " + aMethod, e);
}
}
return result;
@ -1297,7 +1353,7 @@ var AddonManagerInternal = {
listener[aMethod].apply(listener, aArgs);
}
catch (e) {
WARN("AddonListener threw exception when calling " + aMethod, e);
logger.warn("AddonListener threw exception when calling " + aMethod, e);
}
}
},
@ -1676,7 +1732,7 @@ var AddonManagerInternal = {
Cr.NS_ERROR_INVALID_ARG);
if (!("@mozilla.org/addons/web-install-listener;1" in Cc)) {
WARN("No web installer available, cancelling all installs");
logger.warn("No web installer available, cancelling all installs");
aInstalls.forEach(function(aInstall) {
aInstall.cancel();
});
@ -1710,7 +1766,7 @@ var AddonManagerInternal = {
// In the event that the weblistener throws during instantiation or when
// calling onWebInstallBlocked or onWebInstallRequested all of the
// installs should get cancelled.
WARN("Failure calling web installer", e);
logger.warn("Failure calling web installer", e);
aInstalls.forEach(function(aInstall) {
aInstall.cancel();
});

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

@ -19,6 +19,68 @@ this.EXPORTED_SYMBOLS = ["DeferredSave"];
// If delay parameter is not provided, default is 50 milliseconds.
const DEFAULT_SAVE_DELAY_MS = 50;
Cu.import("resource://gre/modules/Log.jsm");
//Configure a logger at the parent 'DeferredSave' level to format
//messages for all the modules under DeferredSave.*
const DEFERREDSAVE_PARENT_LOGGER_ID = "DeferredSave";
let parentLogger = Log.repository.getLogger(DEFERREDSAVE_PARENT_LOGGER_ID);
parentLogger.level = Log.Level.Warn;
let formatter = new Log.BasicFormatter();
//Set parent logger (and its children) to append to
//the Javascript section of the Browser Console
parentLogger.addAppender(new Log.ConsoleAppender(formatter));
//Set parent logger (and its children) to
//also append to standard out
parentLogger.addAppender(new Log.DumpAppender(formatter));
//Provide the ability to enable/disable logging
//messages at runtime.
//If the "extensions.logging.enabled" preference is
//missing or 'false', messages at the WARNING and higher
//severity should be logged to the JS console and standard error.
//If "extensions.logging.enabled" is set to 'true', messages
//at DEBUG and higher should go to JS console and standard error.
Cu.import("resource://gre/modules/Services.jsm");
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
/**
* Preference listener which listens for a change in the
* "extensions.logging.enabled" preference and changes the logging level of the
* parent 'addons' level logger accordingly.
*/
var PrefObserver = {
init: function PrefObserver_init() {
Services.prefs.addObserver(PREF_LOGGING_ENABLED, this, false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
this.observe(null, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID, PREF_LOGGING_ENABLED);
},
observe: function PrefObserver_observe(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
}
else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) {
let debugLogEnabled = false;
try {
debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED);
}
catch (e) {
}
if (debugLogEnabled) {
parentLogger.level = Log.Level.Debug;
}
else {
parentLogger.level = Log.Level.Warn;
}
}
}
};
PrefObserver.init();
/**
* A module to manage deferred, asynchronous writing of data files
* to disk. Writing is deferred by waiting for a specified delay after
@ -42,10 +104,11 @@ const DEFAULT_SAVE_DELAY_MS = 50;
* begins writing the data to disk. Default 50 milliseconds.
*/
this.DeferredSave = function (aPath, aDataProvider, aDelay) {
// Set up loggers for this instance of DeferredSave
// Create a new logger (child of 'DeferredSave' logger)
// for use by this particular instance of DeferredSave object
let leafName = OS.Path.basename(aPath);
Cu.import("resource://gre/modules/addons/AddonLogging.jsm");
LogManager.getLogger("DeferredSave/" + leafName, this);
let logger_id = DEFERREDSAVE_PARENT_LOGGER_ID + "." + leafName;
this.logger = Log.repository.getLogger(logger_id);
// @type {Deferred|null}, null when no data needs to be written
// @resolves with the result of OS.File.writeAtomic when all writes complete
@ -105,7 +168,7 @@ this.DeferredSave.prototype = {
return;
}
this.LOG("Starting timer");
this.logger.debug("Starting timer");
if (!this._timer)
this._timer = MakeTimer();
this._timer.initWithCallback(() => this._deferredSave(),
@ -118,10 +181,10 @@ this.DeferredSave.prototype = {
* the promise is resolved with the number of bytes written.
*/
saveChanges: function() {
this.LOG("Save changes");
this.logger.debug("Save changes");
if (!this._pending) {
if (this.writeInProgress) {
this.LOG("Data changed while write in progress");
this.logger.debug("Data changed while write in progress");
this.overlappedSaves++;
}
this._pending = Promise.defer();
@ -145,7 +208,7 @@ this.DeferredSave.prototype = {
toSave = this._dataProvider();
}
catch(e) {
this.ERROR("Deferred save dataProvider failed", e);
this.logger.error("Deferred save dataProvider failed", e);
writing.then(null, error => {})
.then(count => {
pending.reject(e);
@ -155,7 +218,7 @@ this.DeferredSave.prototype = {
writing.then(null, error => {return 0;})
.then(count => {
this.LOG("Starting write");
this.logger.debug("Starting write");
this.totalSaves++;
this.writeInProgress = true;
@ -164,13 +227,13 @@ this.DeferredSave.prototype = {
result => {
this._lastError = null;
this.writeInProgress = false;
this.LOG("Write succeeded");
this.logger.debug("Write succeeded");
pending.resolve(result);
},
error => {
this._lastError = error;
this.writeInProgress = false;
this.WARN("Write failed", error);
this.logger.warn("Write failed", error);
pending.reject(error);
});
});
@ -198,7 +261,7 @@ this.DeferredSave.prototype = {
// immediately (_deferredSave queues the write for after the most
// recent write completes, if it hasn't already)
if (this._pending) {
this.LOG("Flush called while data is dirty");
this.logger.debug("Flush called while data is dirty");
if (this._timer) {
this._timer.cancel();
this._timer = null;
@ -208,4 +271,4 @@ this.DeferredSave.prototype = {
return this._writing;
}
}
};

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

@ -14,10 +14,11 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const URI_XPINSTALL_DIALOG = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
@ -29,14 +30,12 @@ const READY_STATES = [
AddonManager.STATE_CANCELLED
];
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function logFuncGetter() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.weblistener";
LogManager.getLogger("addons.weblistener", this);
return this[aName];
});
}, this);
// Create a new logger for use by the Addons Web Listener
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
function notifyObservers(aTopic, aWindow, aUri, aInstalls) {
let info = {
@ -129,7 +128,7 @@ Installer.prototype = {
// Just ignore cancelled downloads
break;
default:
WARN("Download of " + install.sourceURI.spec + " in unexpected state " +
logger.warn("Download of " + install.sourceURI.spec + " in unexpected state " +
install.state);
}
}

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

@ -61,14 +61,12 @@ const BLANK_DB = function() {
const TOOLKIT_ID = "toolkit@mozilla.org";
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function logFuncGetter() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.repository";
LogManager.getLogger("addons.repository", this);
return this[aName];
});
}, this);
// Create a new logger for use by the Addons Repository
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
// A map between XML keys to AddonSearchResult keys for string values
// that require no extra parsing from XML
@ -445,7 +443,7 @@ AddonSearchResult.prototype = {
json[property] = value;
}
} catch (ex) {
WARN("Error writing property value for " + property);
logger.warn("Error writing property value for " + property);
}
}
@ -484,7 +482,7 @@ this.AddonRepository = {
try {
enabled = Services.prefs.getBoolPref(preference);
} catch(e) {
WARN("cacheEnabled: Couldn't get pref: " + preference);
logger.warn("cacheEnabled: Couldn't get pref: " + preference);
}
return enabled;
@ -639,7 +637,7 @@ this.AddonRepository = {
AddonDatabase.repopulate(aAddons, aCallback);
},
searchFailed: function repopulateCacheInternal_searchFailed() {
WARN("Search failed when repopulating cache");
logger.warn("Search failed when repopulating cache");
if (aCallback)
aCallback();
}
@ -679,7 +677,7 @@ this.AddonRepository = {
AddonDatabase.insertAddons(aAddons, aCallback);
},
searchFailed: function cacheAddons_searchFailed() {
WARN("Search failed when adding add-ons to cache");
logger.warn("Search failed when adding add-ons to cache");
if (aCallback)
aCallback();
}
@ -1067,7 +1065,7 @@ this.AddonRepository = {
addon.type = "dictionary";
break;
default:
WARN("Unknown type id when parsing addon: " + id);
logger.warn("Unknown type id when parsing addon: " + id);
}
break;
case "authors":
@ -1312,7 +1310,7 @@ this.AddonRepository = {
_parseAddonCompatElement: function AddonRepo_parseAddonCompatElement(aResultObj, aElement) {
let guid = this._getDescendantTextContent(aElement, "guid");
if (!guid) {
LOG("Compatibility override is missing guid.");
logger.debug("Compatibility override is missing guid.");
return;
}
@ -1348,7 +1346,7 @@ this.AddonRepository = {
let type = aNode.getAttribute("type");
// Only "incompatible" (blacklisting) is supported for now.
if (type != "incompatible") {
LOG("Compatibility override of unsupported type found.");
logger.debug("Compatibility override of unsupported type found.");
return null;
}
@ -1358,18 +1356,18 @@ this.AddonRepository = {
override.maxVersion = this._getDirectDescendantTextContent(aNode, "max_version");
if (!override.minVersion) {
LOG("Compatibility override is missing min_version.");
logger.debug("Compatibility override is missing min_version.");
return null;
}
if (!override.maxVersion) {
LOG("Compatibility override is missing max_version.");
logger.debug("Compatibility override is missing max_version.");
return null;
}
let appRanges = aNode.querySelectorAll("compatible_applications > application");
let appRange = findMatchingAppRange.bind(this)(appRanges);
if (!appRange) {
LOG("Compatibility override is missing a valid application range.");
logger.debug("Compatibility override is missing a valid application range.");
return null;
}
@ -1407,7 +1405,7 @@ this.AddonRepository = {
this._callback = aCallback;
this._maxResults = aMaxResults;
LOG("Requesting " + aURI);
logger.debug("Requesting " + aURI);
this._request = new XHRequest();
this._request.mozBackgroundRequest = true;
@ -1475,7 +1473,7 @@ this.AddonRepository = {
try {
url = Services.prefs.getCharPref(aPreference);
} catch(e) {
WARN("_formatURLPref: Couldn't get pref: " + aPreference);
logger.warn("_formatURLPref: Couldn't get pref: " + aPreference);
return null;
}
@ -1575,7 +1573,7 @@ var AddonDatabase = {
}
} catch (e if e.result == Cr.NS_ERROR_FILE_NOT_FOUND) {
LOG("No " + FILE_DATABASE + " found.");
logger.debug("No " + FILE_DATABASE + " found.");
// Create a blank addons.json file
this._saveDBToDisk();
@ -1604,7 +1602,7 @@ var AddonDatabase = {
return;
} catch (e) {
ERROR("Malformed " + FILE_DATABASE + ": " + e);
logger.error("Malformed " + FILE_DATABASE + ": " + e);
this.databaseOk = false;
return;
@ -1675,7 +1673,7 @@ var AddonDatabase = {
// shutdown(true) never rejects
.then(() => this.shutdown(true))
.then(() => OS.File.remove(this.jsonFile.path, {}))
.then(null, error => ERROR("Unable to delete Addon Repository file " +
.then(null, error => logger.error("Unable to delete Addon Repository file " +
this.jsonFile.path, error))
.then(aCallback);
},
@ -1866,7 +1864,7 @@ var AddonDatabase = {
addon[expectedProperty] = value;
}
} catch (ex) {
WARN("Error in parsing property value for " + expectedProperty + " | " + ex);
logger.warn("Error in parsing property value for " + expectedProperty + " | " + ex);
}
// delete property from obj to indicate we've already
@ -1910,7 +1908,7 @@ var AddonDatabase = {
_saveDBToDisk: function() {
return this.Writer.saveChanges().then(
function() Services.obs.notifyObservers(null, DB_DATA_WRITTEN_TOPIC, null),
ERROR);
logger.error);
},
/**

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

@ -6,10 +6,11 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
const KEY_PROFILEDIR = "ProfD";
const FILE_DATABASE = "addons.sqlite";
@ -24,16 +25,12 @@ const PROP_SINGLE = ["id", "type", "name", "version", "creator", "description",
"dailyUsers", "sourceURI", "repositoryStatus", "size",
"updateDate"];
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.repository.sqlmigrator";
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function logFuncGetter() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
LogManager.getLogger("addons.repository.sqlmigrator", this);
return this[aName];
});
}, this);
// Create a new logger for use by the Addons Repository SQL Migrator
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
this.EXPORTED_SYMBOLS = ["AddonRepository_SQLiteMigrator"];
@ -59,12 +56,12 @@ this.AddonRepository_SQLiteMigrator = {
return false;
}
LOG("Importing addon repository from previous " + FILE_DATABASE + " storage.");
logger.debug("Importing addon repository from previous " + FILE_DATABASE + " storage.");
this._retrieveStoredData((results) => {
this._closeConnection();
let resultArray = [addon for ([,addon] of Iterator(results))];
LOG(resultArray.length + " addons imported.")
logger.debug(resultArray.length + " addons imported.")
aCallback(resultArray);
});
@ -100,13 +97,13 @@ this.AddonRepository_SQLiteMigrator = {
return false;
case 1:
LOG("Upgrading database schema to version 2");
logger.debug("Upgrading database schema to version 2");
this.connection.executeSimpleSQL("ALTER TABLE screenshot ADD COLUMN width INTEGER");
this.connection.executeSimpleSQL("ALTER TABLE screenshot ADD COLUMN height INTEGER");
this.connection.executeSimpleSQL("ALTER TABLE screenshot ADD COLUMN thumbnailWidth INTEGER");
this.connection.executeSimpleSQL("ALTER TABLE screenshot ADD COLUMN thumbnailHeight INTEGER");
case 2:
LOG("Upgrading database schema to version 3");
logger.debug("Upgrading database schema to version 3");
this.connection.createTable("compatibility_override",
"addon_internal_id INTEGER, " +
"num INTEGER, " +
@ -118,7 +115,7 @@ this.AddonRepository_SQLiteMigrator = {
"appMaxVersion TEXT, " +
"PRIMARY KEY (addon_internal_id, num)");
case 3:
LOG("Upgrading database schema to version 4");
logger.debug("Upgrading database schema to version 4");
this.connection.createTable("icon",
"addon_internal_id INTEGER, " +
"size INTEGER, " +
@ -134,7 +131,7 @@ this.AddonRepository_SQLiteMigrator = {
}
this.connection.commitTransaction();
} catch (e) {
ERROR("Failed to open " + FILE_DATABASE + ". Data import will not happen.", e);
logger.error("Failed to open " + FILE_DATABASE + ". Data import will not happen.", e);
this.logSQLError(this.connection.lastError, this.connection.lastErrorString);
this.connection.rollbackTransaction();
return false;
@ -180,7 +177,7 @@ this.AddonRepository_SQLiteMigrator = {
handleCompletion: function getAllAddons_handleCompletion(aReason) {
if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
ERROR("Error retrieving add-ons from database. Returning empty results");
logger.error("Error retrieving add-ons from database. Returning empty results");
aCallback({});
return;
}
@ -198,7 +195,7 @@ this.AddonRepository_SQLiteMigrator = {
while ((row = aResults.getNextRow())) {
let addon_internal_id = row.getResultByName("addon_internal_id");
if (!(addon_internal_id in addons)) {
WARN("Found a developer not linked to an add-on in database");
logger.warn("Found a developer not linked to an add-on in database");
continue;
}
@ -214,7 +211,7 @@ this.AddonRepository_SQLiteMigrator = {
handleCompletion: function getAllDevelopers_handleCompletion(aReason) {
if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
ERROR("Error retrieving developers from database. Returning empty results");
logger.error("Error retrieving developers from database. Returning empty results");
aCallback({});
return;
}
@ -232,7 +229,7 @@ this.AddonRepository_SQLiteMigrator = {
while ((row = aResults.getNextRow())) {
let addon_internal_id = row.getResultByName("addon_internal_id");
if (!(addon_internal_id in addons)) {
WARN("Found a screenshot not linked to an add-on in database");
logger.warn("Found a screenshot not linked to an add-on in database");
continue;
}
@ -247,7 +244,7 @@ this.AddonRepository_SQLiteMigrator = {
handleCompletion: function getAllScreenshots_handleCompletion(aReason) {
if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
ERROR("Error retrieving screenshots from database. Returning empty results");
logger.error("Error retrieving screenshots from database. Returning empty results");
aCallback({});
return;
}
@ -264,7 +261,7 @@ this.AddonRepository_SQLiteMigrator = {
while ((row = aResults.getNextRow())) {
let addon_internal_id = row.getResultByName("addon_internal_id");
if (!(addon_internal_id in addons)) {
WARN("Found a compatibility override not linked to an add-on in database");
logger.warn("Found a compatibility override not linked to an add-on in database");
continue;
}
@ -279,7 +276,7 @@ this.AddonRepository_SQLiteMigrator = {
handleCompletion: function getAllCompatOverrides_handleCompletion(aReason) {
if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
ERROR("Error retrieving compatibility overrides from database. Returning empty results");
logger.error("Error retrieving compatibility overrides from database. Returning empty results");
aCallback({});
return;
}
@ -296,7 +293,7 @@ this.AddonRepository_SQLiteMigrator = {
while ((row = aResults.getNextRow())) {
let addon_internal_id = row.getResultByName("addon_internal_id");
if (!(addon_internal_id in addons)) {
WARN("Found an icon not linked to an add-on in database");
logger.warn("Found an icon not linked to an add-on in database");
continue;
}
@ -312,7 +309,7 @@ this.AddonRepository_SQLiteMigrator = {
handleCompletion: function getAllIcons_handleCompletion(aReason) {
if (aReason != Ci.mozIStorageStatementCallback.REASON_FINISHED) {
ERROR("Error retrieving icons from database. Returning empty results");
logger.error("Error retrieving icons from database. Returning empty results");
aCallback({});
return;
}
@ -349,7 +346,7 @@ this.AddonRepository_SQLiteMigrator = {
try {
return this.asyncStatementsCache[aKey] = this.connection.createAsyncStatement(sql);
} catch (e) {
ERROR("Error creating statement " + aKey + " (" + sql + ")");
logger.error("Error creating statement " + aKey + " (" + sql + ")");
throw Components.Exception("Error creating statement " + aKey + " (" + sql + "): " + e,
e.result);
}
@ -478,7 +475,7 @@ this.AddonRepository_SQLiteMigrator = {
* An error message
*/
logSQLError: function AD_logSQLError(aError, aErrorString) {
ERROR("SQL error " + aError + ": " + aErrorString);
logger.error("SQL error " + aError + ": " + aErrorString);
},
/**
@ -488,7 +485,7 @@ this.AddonRepository_SQLiteMigrator = {
* A mozIStorageError to log
*/
asyncErrorLogger: function AD_asyncErrorLogger(aError) {
ERROR("Async SQL error " + aError.result + ": " + aError.message);
logger.error("Async SQL error " + aError.result + ": " + aError.message);
},
/**

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

@ -44,15 +44,12 @@ XPCOMUtils.defineLazyGetter(this, "CertUtils", function certUtilsLazyGetter() {
var gRDF = Cc["@mozilla.org/rdf/rdf-service;1"].
getService(Ci.nsIRDFService);
["LOG", "WARN", "ERROR"].forEach(function(aName) {
this.__defineGetter__(aName, function logFuncGetter() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
LogManager.getLogger("addons.updates", this);
return this[aName];
});
}, this);
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.updates";
// Create a new logger for use by the Addons Update Checker
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
/**
* A serialisation method for RDF data that produces an identical string
@ -309,7 +306,7 @@ function parseRDFManifest(aId, aUpdateKey, aRequest) {
// A missing updates property doesn't count as a failure, just as no avialable
// update information
if (!updates) {
WARN("Update manifest for " + aId + " did not contain an updates property");
logger.warn("Update manifest for " + aId + " did not contain an updates property");
return [];
}
@ -330,11 +327,11 @@ function parseRDFManifest(aId, aUpdateKey, aRequest) {
let item = items.getNext().QueryInterface(Ci.nsIRDFResource);
let version = getProperty(ds, item, "version");
if (!version) {
WARN("Update manifest is missing a required version property.");
logger.warn("Update manifest is missing a required version property.");
continue;
}
LOG("Found an update entry for " + aId + " version " + version);
logger.debug("Found an update entry for " + aId + " version " + version);
let targetApps = ds.GetTargets(item, EM_R("targetApplication"), true);
while (targetApps.hasMoreElements()) {
@ -347,7 +344,7 @@ function parseRDFManifest(aId, aUpdateKey, aRequest) {
appEntry.maxVersion = getRequiredProperty(ds, targetApp, "maxVersion");
}
catch (e) {
WARN(e);
logger.warn(e);
continue;
}
@ -364,7 +361,7 @@ function parseRDFManifest(aId, aUpdateKey, aRequest) {
if (result.updateURL && AddonManager.checkUpdateSecurity &&
result.updateURL.substring(0, 6) != "https:" &&
(!result.updateHash || result.updateHash.substring(0, 3) != "sha")) {
WARN("updateLink " + result.updateURL + " is not secure and is not verified" +
logger.warn("updateLink " + result.updateURL + " is not secure and is not verified" +
" by a strong enough hash (needs to be sha1 or stronger).");
delete result.updateURL;
delete result.updateHash;
@ -401,7 +398,7 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) {
catch (e) {
}
LOG("Requesting " + aUrl);
logger.debug("Requesting " + aUrl);
try {
this.request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
@ -419,7 +416,7 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) {
this.request.send(null);
}
catch (e) {
ERROR("Failed to request update manifest", e);
logger.error("Failed to request update manifest", e);
}
}
@ -453,14 +450,14 @@ UpdateParser.prototype = {
}
if (!Components.isSuccessCode(request.status)) {
WARN("Request failed: " + this.url + " - " + request.status);
logger.warn("Request failed: " + this.url + " - " + request.status);
this.notifyError(AddonUpdateChecker.ERROR_DOWNLOAD_ERROR);
return;
}
let channel = request.channel;
if (channel instanceof Ci.nsIHttpChannel && !channel.requestSucceeded) {
WARN("Request failed: " + this.url + " - " + channel.responseStatus +
logger.warn("Request failed: " + this.url + " - " + channel.responseStatus +
": " + channel.responseStatusText);
this.notifyError(AddonUpdateChecker.ERROR_DOWNLOAD_ERROR);
return;
@ -468,7 +465,7 @@ UpdateParser.prototype = {
let xml = request.responseXML;
if (!xml || xml.documentElement.namespaceURI == XMLURI_PARSE_ERROR) {
WARN("Update manifest was not valid XML");
logger.warn("Update manifest was not valid XML");
this.notifyError(AddonUpdateChecker.ERROR_PARSE_ERROR);
return;
}
@ -481,7 +478,7 @@ UpdateParser.prototype = {
results = parseRDFManifest(this.id, this.updateKey, request);
}
catch (e) {
WARN(e);
logger.warn(e);
this.notifyError(AddonUpdateChecker.ERROR_PARSE_ERROR);
return;
}
@ -490,13 +487,13 @@ UpdateParser.prototype = {
this.observer.onUpdateCheckComplete(results);
}
catch (e) {
WARN("onUpdateCheckComplete notification failed", e);
logger.warn("onUpdateCheckComplete notification failed", e);
}
}
return;
}
WARN("Update manifest had an unrecognised namespace: " + xml.documentElement.namespaceURI);
logger.warn("Update manifest had an unrecognised namespace: " + xml.documentElement.namespaceURI);
this.notifyError(AddonUpdateChecker.ERROR_UNKNOWN_FORMAT);
},
@ -505,7 +502,7 @@ UpdateParser.prototype = {
*/
onTimeout: function() {
this.request = null;
WARN("Request for " + this.url + " timed out");
logger.warn("Request for " + this.url + " timed out");
this.notifyError(AddonUpdateChecker.ERROR_TIMEOUT);
},
@ -514,22 +511,22 @@ UpdateParser.prototype = {
*/
onError: function UP_onError() {
if (!Components.isSuccessCode(this.request.status)) {
WARN("Request failed: " + this.url + " - " + this.request.status);
logger.warn("Request failed: " + this.url + " - " + this.request.status);
}
else if (this.request.channel instanceof Ci.nsIHttpChannel) {
try {
if (this.request.channel.requestSucceeded) {
WARN("Request failed: " + this.url + " - " +
logger.warn("Request failed: " + this.url + " - " +
this.request.channel.responseStatus + ": " +
this.request.channel.responseStatusText);
}
}
catch (e) {
WARN("HTTP Request failed for an unknown reason");
logger.warn("HTTP Request failed for an unknown reason");
}
}
else {
WARN("Request failed for an unknown reason");
logger.warn("Request failed for an unknown reason");
}
this.request = null;
@ -546,7 +543,7 @@ UpdateParser.prototype = {
this.observer.onUpdateCheckError(aStatus);
}
catch (e) {
WARN("onUpdateCheckError notification failed", e);
logger.warn("onUpdateCheckError notification failed", e);
}
}
},

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

@ -6,24 +6,23 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
this.EXPORTED_SYMBOLS = [];
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
const STRING_TYPE_NAME = "type.%ID%.name";
const LIST_UPDATED_TOPIC = "plugins-list-updated";
for (let name of ["LOG", "WARN", "ERROR"]) {
this.__defineGetter__(name, function() {
Components.utils.import("resource://gre/modules/addons/AddonLogging.jsm");
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.plugins";
LogManager.getLogger("addons.plugins", this);
return this[name];
});
}
// Create a new logger for use by the Addons Plugin Provider
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
function getIDHashForString(aStr) {
// return the two-digit hexadecimal code for a byte

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -24,18 +24,12 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise",
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
["LOG", "WARN", "ERROR"].forEach(function(aName) {
Object.defineProperty(this, aName, {
get: function logFuncGetter () {
Cu.import("resource://gre/modules/addons/AddonLogging.jsm");
LogManager.getLogger("addons.xpi-utils", this);
return this[aName];
},
configurable: true
});
}, this);
Cu.import("resource://gre/modules/Log.jsm");
const LOGGER_ID = "addons.xpi-utils";
// Create a new logger for use by the Addons XPI Provider Utils
// (Requires AddonManager.jsm)
let logger = Log.repository.getLogger(LOGGER_ID);
const KEY_PROFILEDIR = "ProfD";
const FILE_DATABASE = "extensions.sqlite";
@ -152,7 +146,7 @@ function makeSafe(aCallback) {
aCallback(...aArgs);
}
catch(ex) {
WARN("XPI Database callback failed", ex);
logger.warn("XPI Database callback failed", ex);
}
}
}
@ -195,7 +189,7 @@ function asyncMap(aObjects, aMethod, aCallback) {
});
}
catch (e) {
WARN("Async map function failed", e);
logger.warn("Async map function failed", e);
asyncMap_gotValue(aIndex, undefined);
}
});
@ -227,7 +221,7 @@ function resultRows(aStatement) {
* An error message
*/
function logSQLError(aError, aErrorString) {
ERROR("SQL error " + aError + ": " + aErrorString);
logger.error("SQL error " + aError + ": " + aErrorString);
}
/**
@ -442,7 +436,7 @@ this.XPIDatabase = {
count => {
// Update the XPIDB schema version preference the first time we successfully
// save the database.
LOG("XPI Database saved, setting schema version preference to " + DB_SCHEMA);
logger.debug("XPI Database saved, setting schema version preference to " + DB_SCHEMA);
Services.prefs.setIntPref(PREF_DB_SCHEMA, DB_SCHEMA);
// Reading the DB worked once, so we don't need the load error
this._loadError = null;
@ -450,7 +444,7 @@ this.XPIDatabase = {
error => {
// Need to try setting the schema version again later
this._schemaVersionSet = false;
WARN("Failed to save XPI database", error);
logger.warn("Failed to save XPI database", error);
// this._deferredSave.lastError has the most recent error so we don't
// need this any more
this._loadError = null;
@ -502,10 +496,10 @@ this.XPIDatabase = {
connection = Services.storage.openUnsharedDatabase(dbfile);
}
catch (e) {
WARN("Failed to open sqlite database " + dbfile.path + " for upgrade", e);
logger.warn("Failed to open sqlite database " + dbfile.path + " for upgrade", e);
return null;
}
LOG("Migrating data from sqlite");
logger.debug("Migrating data from sqlite");
let migrateData = this.getMigrateDataFromDatabase(connection);
connection.close();
return migrateData;
@ -535,7 +529,7 @@ this.XPIDatabase = {
let data = "";
try {
let readTimer = AddonManagerPrivate.simpleTimer("XPIDB_syncRead_MS");
LOG("Opening XPI database " + this.jsonFile.path);
logger.debug("Opening XPI database " + this.jsonFile.path);
fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
createInstance(Components.interfaces.nsIFileInputStream);
fstream.init(this.jsonFile, -1, 0, 0);
@ -555,7 +549,7 @@ this.XPIDatabase = {
this.parseDB(data, aRebuildOnError);
}
catch(e) {
ERROR("Failed to load XPI JSON data from profile", e);
logger.error("Failed to load XPI JSON data from profile", e);
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildReadFailed_MS");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
@ -601,7 +595,7 @@ this.XPIDatabase = {
if (!("schemaVersion" in inputAddons) || !("addons" in inputAddons)) {
parseTimer.done();
// Content of JSON file is bad, need to rebuild from scratch
ERROR("bad JSON file contents");
logger.error("bad JSON file contents");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "badJSON");
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildBadJSON_MS");
this.rebuildDatabase(aRebuildOnError);
@ -614,7 +608,7 @@ this.XPIDatabase = {
// don't know about (bug 902956)
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError",
"schemaMismatch-" + inputAddons.schemaVersion);
LOG("JSON schema mismatch: expected " + DB_SCHEMA +
logger.debug("JSON schema mismatch: expected " + DB_SCHEMA +
", actual " + inputAddons.schemaVersion);
// When we rev the schema of the JSON database, we need to make sure we
// force the DB to save so that the DB_SCHEMA value in the JSON file and
@ -629,7 +623,7 @@ this.XPIDatabase = {
};
parseTimer.done();
this.addonDB = addonDB;
LOG("Successfully read XPI database");
logger.debug("Successfully read XPI database");
this.initialized = true;
}
catch(e) {
@ -637,11 +631,11 @@ this.XPIDatabase = {
// parser, the xpcshell test harness fails the test for us: bug 870828
parseTimer.done();
if (e.name == "SyntaxError") {
ERROR("Syntax error parsing saved XPI JSON data");
logger.error("Syntax error parsing saved XPI JSON data");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "syntax");
}
else {
ERROR("Failed to load XPI JSON data from profile", e);
logger.error("Failed to load XPI JSON data from profile", e);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "other");
}
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildReadFailed_MS");
@ -659,7 +653,7 @@ this.XPIDatabase = {
let schemaVersion = Services.prefs.getIntPref(PREF_DB_SCHEMA);
if (schemaVersion <= LAST_SQLITE_DB_SCHEMA) {
// we should have an older SQLITE database
LOG("Attempting to upgrade from SQLITE database");
logger.debug("Attempting to upgrade from SQLITE database");
this.migrateData = this.getMigrateDataFromSQLITE();
}
else {
@ -684,7 +678,7 @@ this.XPIDatabase = {
*/
rebuildUnreadableDB: function(aError, aRebuildOnError) {
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildUnreadableDB_MS");
WARN("Extensions database " + this.jsonFile.path +
logger.warn("Extensions database " + this.jsonFile.path +
" exists but is not readable; rebuilding", aError);
// Remember the error message until we try and write at least once, so
// we know at shutdown time that there was a problem
@ -708,21 +702,21 @@ this.XPIDatabase = {
return this._dbPromise;
}
LOG("Starting async load of XPI database " + this.jsonFile.path);
logger.debug("Starting async load of XPI database " + this.jsonFile.path);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_async_load", XPIProvider.runPhase);
let readOptions = {
outExecutionDuration: 0
};
return this._dbPromise = OS.File.read(this.jsonFile.path, null, readOptions).then(
byteArray => {
LOG("Async JSON file read took " + readOptions.outExecutionDuration + " MS");
logger.debug("Async JSON file read took " + readOptions.outExecutionDuration + " MS");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_asyncRead_MS",
readOptions.outExecutionDuration);
if (this._addonDB) {
LOG("Synchronous load completed while waiting for async load");
logger.debug("Synchronous load completed while waiting for async load");
return this.addonDB;
}
LOG("Finished async read of XPI database, parsing...");
logger.debug("Finished async read of XPI database, parsing...");
let decodeTimer = AddonManagerPrivate.simpleTimer("XPIDB_decode_MS");
let decoder = new TextDecoder();
let data = decoder.decode(byteArray);
@ -733,7 +727,7 @@ this.XPIDatabase = {
.then(null,
error => {
if (this._addonDB) {
LOG("Synchronous load completed while waiting for async load");
logger.debug("Synchronous load completed while waiting for async load");
return this.addonDB;
}
if (error.becauseNoSuchFile) {
@ -762,7 +756,7 @@ this.XPIDatabase = {
if (XPIProvider.installStates && XPIProvider.installStates.length == 0) {
// No extensions installed, so we're done
LOG("Rebuilding XPI database with no extensions");
logger.debug("Rebuilding XPI database with no extensions");
return;
}
@ -772,12 +766,12 @@ this.XPIDatabase = {
this.activeBundles = this.getActiveBundles();
if (aRebuildOnError) {
WARN("Rebuilding add-ons database from installed extensions.");
logger.warn("Rebuilding add-ons database from installed extensions.");
try {
XPIProvider.processFileChanges(XPIProvider.installStates, {}, false);
}
catch (e) {
ERROR("Failed to rebuild XPI database from installed extensions", e);
logger.error("Failed to rebuild XPI database from installed extensions", e);
}
// Make sure to update the active add-ons and add-ons list on shutdown
Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS, true);
@ -814,7 +808,7 @@ this.XPIDatabase = {
bundles.push(parser.getString("ExtensionDirs", keys.getNext()));
}
catch (e) {
WARN("Failed to parse extensions.ini", e);
logger.warn("Failed to parse extensions.ini", e);
return null;
}
@ -838,7 +832,7 @@ this.XPIDatabase = {
if (!rdffile.exists())
return null;
LOG("Migrating data from " + FILE_OLD_DATABASE);
logger.debug("Migrating data from " + FILE_OLD_DATABASE);
let migrateData = {};
try {
@ -890,7 +884,7 @@ this.XPIDatabase = {
}
}
catch (e) {
WARN("Error reading " + FILE_OLD_DATABASE, e);
logger.warn("Error reading " + FILE_OLD_DATABASE, e);
migrateData = null;
}
@ -930,7 +924,7 @@ this.XPIDatabase = {
}
if (reqCount < REQUIRED.length) {
ERROR("Unable to read anything useful from the database");
logger.error("Unable to read anything useful from the database");
return null;
}
stmt.finalize();
@ -975,7 +969,7 @@ this.XPIDatabase = {
}
catch (e) {
// An error here means the schema is too different to read
ERROR("Error migrating data", e);
logger.error("Error migrating data", e);
return null;
}
finally {
@ -995,7 +989,7 @@ this.XPIDatabase = {
* all cleanup is done
*/
shutdown: function XPIDB_shutdown() {
LOG("shutdown");
logger.debug("shutdown");
if (this.initialized) {
// If our last database I/O had an error, try one last time to save.
if (this.lastError)
@ -1016,7 +1010,7 @@ this.XPIDatabase = {
// are finished cleaning up
let flushPromise = this.flush();
flushPromise.then(null, error => {
ERROR("Flush of XPI database failed", error);
logger.error("Flush of XPI database failed", error);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_shutdownFlush_failed", 1);
// If our last attempt to read or write the DB failed, force a new
// extensions.ini to be written to disk on the next startup
@ -1073,7 +1067,7 @@ this.XPIDatabase = {
})
.then(null,
error => {
ERROR("getAddonList failed", e);
logger.error("getAddonList failed", e);
makeSafe(aCallback)([]);
});
},
@ -1093,7 +1087,7 @@ this.XPIDatabase = {
})
.then(null,
error => {
ERROR("getAddon failed", e);
logger.error("getAddon failed", e);
makeSafe(aCallback)(null);
});
},
@ -1167,7 +1161,7 @@ this.XPIDatabase = {
// jank-tastic! Must synchronously load DB if the theme switches from
// an XPI theme to a lightweight theme before the DB has loaded,
// because we're called from sync XPIProvider.addonChanged
WARN("Synchronous load of XPI database due to getAddonsByType(" + aType + ")");
logger.warn("Synchronous load of XPI database due to getAddonsByType(" + aType + ")");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_byType", XPIProvider.runPhase);
this.syncLoadDB(true);
}
@ -1184,7 +1178,7 @@ this.XPIDatabase = {
getVisibleAddonForInternalName: function XPIDB_getVisibleAddonForInternalName(aInternalName) {
if (!this.addonDB) {
// This may be called when the DB hasn't otherwise been loaded
WARN("Synchronous load of XPI database due to getVisibleAddonForInternalName");
logger.warn("Synchronous load of XPI database due to getVisibleAddonForInternalName");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_forInternalName",
XPIProvider.runPhase);
this.syncLoadDB(true);
@ -1321,10 +1315,10 @@ this.XPIDatabase = {
* A callback to pass the DBAddonInternal to
*/
makeAddonVisible: function XPIDB_makeAddonVisible(aAddon) {
LOG("Make addon " + aAddon._key + " visible");
logger.debug("Make addon " + aAddon._key + " visible");
for (let [, otherAddon] of this.addonDB) {
if ((otherAddon.id == aAddon.id) && (otherAddon._key != aAddon._key)) {
LOG("Hide addon " + otherAddon._key);
logger.debug("Hide addon " + otherAddon._key);
otherAddon.visible = false;
}
}
@ -1378,7 +1372,7 @@ this.XPIDatabase = {
* The DBAddonInternal to update
*/
updateAddonActive: function XPIDB_updateAddonActive(aAddon, aActive) {
LOG("Updating active state for add-on " + aAddon.id + " to " + aActive);
logger.debug("Updating active state for add-on " + aAddon.id + " to " + aActive);
aAddon.active = aActive;
this.saveChanges();
@ -1389,13 +1383,13 @@ this.XPIDatabase = {
*/
updateActiveAddons: function XPIDB_updateActiveAddons() {
if (!this.addonDB) {
WARN("updateActiveAddons called when DB isn't loaded");
logger.warn("updateActiveAddons called when DB isn't loaded");
// force the DB to load
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_updateActive",
XPIProvider.runPhase);
this.syncLoadDB(true);
}
LOG("Updating add-on states");
logger.debug("Updating add-on states");
for (let [, addon] of this.addonDB) {
let newActive = (addon.visible && !addon.userDisabled &&
!addon.softDisabled && !addon.appDisabled &&
@ -1472,7 +1466,7 @@ this.XPIDatabase = {
}
if (fullCount > 0) {
LOG("Writing add-ons list");
logger.debug("Writing add-ons list");
try {
let addonsListTmp = FileUtils.getFile(KEY_PROFILEDIR, [FILE_XPI_ADDONS_LIST + ".tmp"],
@ -1485,19 +1479,19 @@ this.XPIDatabase = {
Services.prefs.setCharPref(PREF_EM_ENABLED_ADDONS, enabledAddons.join(","));
}
catch (e) {
ERROR("Failed to write add-ons list to " + addonsListTmp.parent + "/" +
logger.error("Failed to write add-ons list to " + addonsListTmp.parent + "/" +
FILE_XPI_ADDONS_LIST, e);
return false;
}
}
else {
if (addonsList.exists()) {
LOG("Deleting add-ons list");
logger.debug("Deleting add-ons list");
try {
addonsList.remove(false);
}
catch (e) {
ERROR("Failed to remove " + addonsList.path, e);
logger.error("Failed to remove " + addonsList.path, e);
return false;
}
}