Bug 910808 - Remove call to retrieve preference while not on the main thread. r=khuey

--HG--
extra : rebase_source : a813c3a680c42c712237059104a82c66f7e7bde3
This commit is contained in:
Dave Hylands 2013-09-03 16:10:38 -07:00
parent 311695772f
commit 32104aa352

View File

@ -74,7 +74,7 @@ StaticAutoPtr<DeviceStorageUsedSpaceCache>
DeviceStorageUsedSpaceCache::DeviceStorageUsedSpaceCache()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
mIOThread = new LazyIdleThread(
DEFAULT_THREAD_TIMEOUT_MS,
@ -93,7 +93,7 @@ DeviceStorageUsedSpaceCache::CreateOrGet()
return sDeviceStorageUsedSpaceCache;
}
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
sDeviceStorageUsedSpaceCache = new DeviceStorageUsedSpaceCache();
ClearOnShutdown(&sDeviceStorageUsedSpaceCache);
@ -208,8 +208,7 @@ DeviceStorageTypeChecker::CreateOrGet()
return sDeviceStorageTypeChecker;
}
NS_ASSERTION(NS_IsMainThread(),
"This can only be created on the main thread!");
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIStringBundleService> stringService
= mozilla::services::GetStringBundleService();
@ -473,7 +472,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
nsString data;
CopyASCIItoUTF16(mType, data);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
@ -585,7 +584,7 @@ InitDirs()
if (sDirs) {
return;
}
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
sDirs = new GlobalDirs;
ClearOnShutdown(&sDirs);
@ -765,7 +764,7 @@ DeviceStorageFile::GetRootDirectoryForType(const nsAString& aStorageType,
}
// in testing, we default all device storage types to a temp directory
if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
if (f && sDirs->temp) {
f = sDirs->temp;
}
@ -998,7 +997,7 @@ DeviceStorageFile::Write(InfallibleTArray<uint8_t>& aBits)
nsresult
DeviceStorageFile::Remove()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
if (!mFile) {
return NS_ERROR_FAILURE;
@ -1027,7 +1026,7 @@ DeviceStorageFile::Remove()
nsresult
DeviceStorageFile::CalculateMimeType()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
nsAutoCString mimeType;
nsCOMPtr<nsIMIMEService> mimeService =
@ -1047,7 +1046,7 @@ DeviceStorageFile::CalculateMimeType()
nsresult
DeviceStorageFile::CalculateSizeAndModifiedDate()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
int64_t fileSize;
nsresult rv = mFile->GetFileSize(&fileSize);
@ -1343,6 +1342,8 @@ void
nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aStorageType,
const nsAString& aStorageName)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIFile> f;
DeviceStorageFile::GetRootDirectoryForType(aStorageType,
aStorageName,
@ -1387,7 +1388,7 @@ InterfaceToJsval(nsPIDOMWindow* aWindow,
JS::Value
nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
NS_ASSERTION(aWindow, "Null Window");
if (!aFile) {
@ -1417,7 +1418,7 @@ nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
JS::Value StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
NS_ASSERTION(aWindow, "Null Window");
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aWindow);
@ -1510,7 +1511,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
mRequest->FireError(mError);
mRequest = nullptr;
return NS_OK;
@ -1534,7 +1535,7 @@ ContinueCursorEvent::ContinueCursorEvent(DOMRequest* aRequest)
already_AddRefed<DeviceStorageFile>
ContinueCursorEvent::GetNextFile()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
nsDOMDeviceStorageCursor* cursor
= static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
@ -1629,7 +1630,7 @@ public:
~InitCursorEvent() {}
NS_IMETHOD Run() {
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
if (mFile->mFile) {
bool check;
@ -1823,7 +1824,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
nsString state = NS_LITERAL_STRING("unavailable");
if (mFile) {
@ -1868,7 +1869,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
AutoJSContext cx;
JS::Rooted<JS::Value> result(cx, JSVAL_NULL);
@ -1910,7 +1911,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
nsCOMPtr<nsIInputStream> stream;
mBlob->GetInternalStream(getter_AddRefs(stream));
@ -1964,7 +1965,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
nsRefPtr<nsRunnable> r;
if (!mFile->mEditable) {
@ -2008,7 +2009,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
mFile->Remove();
nsRefPtr<nsRunnable> r;
@ -2045,7 +2046,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
uint64_t picturesUsage = 0, videosUsage = 0, musicUsage = 0, totalUsage = 0;
mFile->AccumDiskUsage(&picturesUsage, &videosUsage,
@ -2084,7 +2085,7 @@ public:
NS_IMETHOD Run()
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(!NS_IsMainThread());
int64_t freeSpace = 0;
if (mFile) {
@ -2142,6 +2143,7 @@ public:
nsIContentPermissionRequest)
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
if (mozilla::Preferences::GetBool("device.storage.prompt.testing", false)) {
Allow();
@ -2548,7 +2550,7 @@ nsDOMDeviceStorage::~nsDOMDeviceStorage()
void
nsDOMDeviceStorage::Shutdown()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
if (!mStorageName.IsEmpty()) {
UnregisterForSDCardChanges(this);
@ -3139,6 +3141,8 @@ nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath,
const EnumerationParameters& aOptions,
bool aEditable, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) {
aRv.Throw(NS_ERROR_UNEXPECTED);
@ -3234,7 +3238,7 @@ nsDOMDeviceStorage::Observe(nsISupports *aSubject,
const char *aTopic,
const PRUnichar *aData)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(NS_IsMainThread());
if (!strcmp(aTopic, "file-watcher-update")) {