Bug 783398 - DeviceStorage makes calls to nsVolumeService from the IOThread. r=dhylands

--HG--
extra : rebase_source : 8f3fef5b349f5810e256f8f5f4b6217854a03518
This commit is contained in:
Doug Turner 2012-08-16 16:03:06 -07:00
Родитель 7a4f588fcb
Коммит 6866ddaadb
3 изменённых файлов: 29 добавлений и 33 удалений

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

@ -316,18 +316,8 @@ DeviceStorageRequestParent::StatFileEvent::CancelableRun()
NS_DispatchToMainThread(r);
return NS_OK;
}
nsString state;
state.Assign(NS_LITERAL_STRING("available"));
#ifdef MOZ_WIDGET_GONK
rv = GetSDCardStatus(state);
if (NS_FAILED(rv)) {
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
NS_DispatchToMainThread(r);
return NS_OK;
}
#endif
r = new PostStatResultEvent(mParent, diskUsage, freeSpace, state);
r = new PostStatResultEvent(mParent, diskUsage, freeSpace);
NS_DispatchToMainThread(r);
return NS_OK;
}
@ -447,12 +437,10 @@ DeviceStorageRequestParent::PostPathResultEvent::CancelableRun()
DeviceStorageRequestParent::PostStatResultEvent::PostStatResultEvent(DeviceStorageRequestParent* aParent,
PRInt64 aFreeBytes,
PRInt64 aTotalBytes,
nsAString& aState)
PRInt64 aTotalBytes)
: CancelableRunnable(aParent)
, mFreeBytes(aFreeBytes)
, mTotalBytes(aTotalBytes)
, mState(aState)
{
}
@ -465,7 +453,16 @@ DeviceStorageRequestParent::PostStatResultEvent::CancelableRun()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
StatStorageResponse response(mFreeBytes, mTotalBytes, mState);
nsString state;
state.Assign(NS_LITERAL_STRING("available"));
#ifdef MOZ_WIDGET_GONK
nsresult rv = GetSDCardStatus(state);
if (NS_FAILED(rv)) {
state.Assign(NS_LITERAL_STRING("unavailable"));
}
#endif
StatStorageResponse response(mFreeBytes, mTotalBytes, state);
unused << mParent->Send__delete__(mParent, response);
return NS_OK;
}

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

@ -175,13 +175,11 @@ private:
public:
PostStatResultEvent(DeviceStorageRequestParent* aParent,
PRInt64 aFreeBytes,
PRInt64 aTotalBytes,
nsAString& aState);
PRInt64 aTotalBytes);
virtual ~PostStatResultEvent();
virtual nsresult CancelableRun();
private:
PRInt64 mFreeBytes, mTotalBytes;
nsString mState;
};
protected:

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

@ -856,10 +856,9 @@ nsDOMDeviceStorageCursor::IPDLRelease()
class PostStatResultEvent : public nsRunnable
{
public:
PostStatResultEvent(nsRefPtr<DOMRequest>& aRequest, PRInt64 aFreeBytes, PRInt64 aTotalBytes, nsAString& aState)
PostStatResultEvent(nsRefPtr<DOMRequest>& aRequest, PRInt64 aFreeBytes, PRInt64 aTotalBytes)
: mFreeBytes(aFreeBytes)
, mTotalBytes(aTotalBytes)
, mState(aState)
{
mRequest.swap(aRequest);
}
@ -870,7 +869,18 @@ public:
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<nsIDOMDeviceStorageStat> domstat = new nsDOMDeviceStorageStat(mFreeBytes, mTotalBytes, mState);
nsString state;
state.Assign(NS_LITERAL_STRING("available"));
#ifdef MOZ_WIDGET_GONK
nsresult rv = GetSDCardStatus(state);
if (NS_FAILED(rv)) {
mRequest->FireError(NS_ERROR_FAILURE);
mRequest = nullptr;
return NS_OK;
}
#endif
nsRefPtr<nsIDOMDeviceStorageStat> domstat = new nsDOMDeviceStorageStat(mFreeBytes, mTotalBytes, state);
jsval result = InterfaceToJsval(mRequest->GetOwner(),
domstat,
@ -1069,17 +1079,8 @@ public:
NS_DispatchToMainThread(r);
return NS_OK;
}
nsString state;
state.Assign(NS_LITERAL_STRING("available"));
#ifdef MOZ_WIDGET_GONK
rv = GetSDCardStatus(state);
if (NS_FAILED(rv)) {
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_UNKNOWN, mFile);
NS_DispatchToMainThread(r);
return NS_OK;
}
#endif
r = new PostStatResultEvent(mRequest, diskUsage, freeSpace, state);
r = new PostStatResultEvent(mRequest, diskUsage, freeSpace);
NS_DispatchToMainThread(r);
return NS_OK;
}