nsresult DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun() { NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!"); nsCOMPtr<nsIRunnable> r; bool check = false; mFile->mFile->Exists(&check); if (!check) { r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST); NS_DispatchToMainThread(r); return NS_OK; } nsTArray<nsRefPtr<DeviceStorageFile> > files; mFile->CollectFiles(files, mSince); InfallibleTArray<DeviceStorageFileValue> values; PRUint32 count = files.Length(); for (PRUint32 i = 0; i < count; i++) { nsString fullpath; files[i]->mFile->GetPath(fullpath); DeviceStorageFileValue dsvf(files[i]->mPath, fullpath); values.AppendElement(dsvf); } r = new PostEnumerationSuccessEvent(mParent, values); NS_DispatchToMainThread(r); return NS_OK; }
nsresult DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun() { MOZ_ASSERT(!NS_IsMainThread()); if (mFile->mFile) { bool check = false; mFile->mFile->Exists(&check); if (!check) { return NS_DispatchToMainThread( new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST)); } } nsTArray<RefPtr<DeviceStorageFile> > files; mFile->CollectFiles(files, mSince); InfallibleTArray<DeviceStorageFileValue> values; uint32_t count = files.Length(); for (uint32_t i = 0; i < count; i++) { DeviceStorageFileValue dsvf(files[i]->mStorageName, files[i]->mPath); values.AppendElement(dsvf); } return NS_DispatchToMainThread( new PostEnumerationSuccessEvent(mParent, mFile->mStorageType, mFile->mRootDir, values)); }