зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8f7ef60b6f5a (bug 860934) for mochitest asserts and crashes.
This commit is contained in:
Родитель
dd5be82e7b
Коммит
1afb8a0017
|
@ -29,9 +29,7 @@
|
|||
#include "nsIOutputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#define TARGET_ROOT "/sdcard/"
|
||||
#define TARGET_SUBDIR "downloads/bluetooth/"
|
||||
#define TARGET_FOLDER TARGET_ROOT TARGET_SUBDIR
|
||||
#define TARGET_FOLDER "/sdcard/downloads/bluetooth/"
|
||||
|
||||
USING_BLUETOOTH_NAMESPACE
|
||||
using namespace mozilla;
|
||||
|
@ -563,11 +561,6 @@ BluetoothOppManager::CreateFile()
|
|||
*/
|
||||
f->GetLeafName(sFileName);
|
||||
|
||||
nsString fullFileName;
|
||||
f->GetPath(fullFileName);
|
||||
MOZ_ASSERT(StringBeginsWith(fullFileName, NS_LITERAL_STRING(TARGET_ROOT)));
|
||||
nsDependentSubstring storagePath = Substring(fullFileName, strlen(TARGET_ROOT));
|
||||
|
||||
mDsFile = nullptr;
|
||||
|
||||
nsCOMPtr<nsIMIMEService> mimeSvc = do_GetService(NS_MIMESERVICE_CONTRACTID);
|
||||
|
@ -577,11 +570,11 @@ BluetoothOppManager::CreateFile()
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("image/"))) {
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("pictures"), storagePath);
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("pictures"), f);
|
||||
} else if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("video/"))) {
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("movies"), storagePath);
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("movies"), f);
|
||||
} else if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("audio/"))) {
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("music"), storagePath);
|
||||
mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("music"), f);
|
||||
} else {
|
||||
NS_WARNING("Couldn't recognize the mimetype of received file.");
|
||||
}
|
||||
|
|
|
@ -905,8 +905,7 @@ nsGonkCameraControl::StartRecordingImpl(StartRecordingTask* aStartRecording)
|
|||
*/
|
||||
nsCOMPtr<nsIFile> filename = aStartRecording->mFolder;
|
||||
filename->AppendRelativePath(aStartRecording->mFilename);
|
||||
mVideoFile = new DeviceStorageFile(NS_LITERAL_STRING("videos"),
|
||||
aStartRecording->mFilename);
|
||||
mVideoFile = new DeviceStorageFile(NS_LITERAL_STRING("videos"), filename);
|
||||
|
||||
nsAutoCString nativeFilename;
|
||||
filename->GetNativePath(nativeFilename);
|
||||
|
|
|
@ -20,18 +20,10 @@ public:
|
|||
nsCOMPtr<nsIFile> mFile;
|
||||
nsString mPath;
|
||||
nsString mStorageType;
|
||||
nsString mRootDir;
|
||||
bool mEditable;
|
||||
|
||||
// Used when the path will be set later via SetPath.
|
||||
DeviceStorageFile(const nsAString& aStorageType);
|
||||
// Used for non-enumeration purposes.
|
||||
DeviceStorageFile(const nsAString& aStorageType, const nsAString& aPath);
|
||||
// Used for enumerations. When you call Enumerate, you can pass in a directory to enumerate
|
||||
// and the results that are returned are relative to that directory, files related to an
|
||||
// enumeration need to know the "root of the enumeration" directory.
|
||||
DeviceStorageFile(const nsAString& aStorageType, const nsAString& aRootDir, const nsAString& aPath);
|
||||
|
||||
DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile, const nsAString& aPath);
|
||||
DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile);
|
||||
void SetPath(const nsAString& aPath);
|
||||
void SetEditable(bool aEditable);
|
||||
|
||||
|
@ -40,7 +32,6 @@ public:
|
|||
// we want to make sure that the names of file can't reach
|
||||
// outside of the type of storage the user asked for.
|
||||
bool IsSafePath();
|
||||
bool IsSafePath(const nsAString& aPath);
|
||||
|
||||
nsresult Remove();
|
||||
nsresult Write(nsIInputStream* aInputStream);
|
||||
|
@ -49,13 +40,10 @@ public:
|
|||
void collectFilesInternal(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles, PRTime aSince, nsAString& aRootPath);
|
||||
|
||||
static void DirectoryDiskUsage(nsIFile* aFile, uint64_t* aSoFar, const nsAString& aStorageType);
|
||||
static void GetRootDirectoryForType(const nsAString& aType,
|
||||
const nsAString& aVolName,
|
||||
nsIFile** aFile);
|
||||
|
||||
private:
|
||||
void Init(const nsAString& aStorageType);
|
||||
void NormalizeFilePath();
|
||||
void AppendRelativePath(const nsAString& aPath);
|
||||
void AppendRelativePath();
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -100,9 +100,14 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal
|
|||
|
||||
uint32_t count = r.paths().Length();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(r.type(),
|
||||
r.relpath(),
|
||||
r.paths()[i].name());
|
||||
nsCOMPtr<nsIFile> f;
|
||||
nsresult rv = NS_NewLocalFile(r.paths()[i].fullpath(), false, getter_AddRefs(f));
|
||||
if (NS_FAILED(rv)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(r.paths()[i].type(), f);
|
||||
dsf->SetPath(r.paths()[i].name());
|
||||
cursor->mFiles.AppendElement(dsf);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,10 @@ DeviceStorageRequestParent::Dispatch()
|
|||
{
|
||||
DeviceStorageAddParams p = mParams;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath());
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
|
||||
BlobParent* bp = static_cast<BlobParent*>(p.blobParent());
|
||||
nsCOMPtr<nsIDOMBlob> blob = bp->GetBlob();
|
||||
|
@ -53,7 +56,12 @@ DeviceStorageRequestParent::Dispatch()
|
|||
case DeviceStorageParams::TDeviceStorageGetParams:
|
||||
{
|
||||
DeviceStorageGetParams p = mParams;
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.rootDir(), p.relpath());
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
dsf->SetPath(p.name());
|
||||
nsRefPtr<CancelableRunnable> r = new ReadFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
|
@ -66,7 +74,10 @@ DeviceStorageRequestParent::Dispatch()
|
|||
{
|
||||
DeviceStorageDeleteParams p = mParams;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath());
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
nsRefPtr<CancelableRunnable> r = new DeleteFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
|
@ -79,7 +90,10 @@ DeviceStorageRequestParent::Dispatch()
|
|||
{
|
||||
DeviceStorageFreeSpaceParams p = mParams;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath());
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
nsRefPtr<FreeSpaceFileEvent> r = new FreeSpaceFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
|
@ -92,7 +106,10 @@ DeviceStorageRequestParent::Dispatch()
|
|||
{
|
||||
DeviceStorageUsedSpaceParams p = mParams;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath());
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
nsRefPtr<UsedSpaceFileEvent> r = new UsedSpaceFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
|
@ -104,9 +121,7 @@ DeviceStorageRequestParent::Dispatch()
|
|||
case DeviceStorageParams::TDeviceStorageAvailableParams:
|
||||
{
|
||||
DeviceStorageAvailableParams p = mParams;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath());
|
||||
nsRefPtr<PostAvailableResultEvent> r = new PostAvailableResultEvent(this, dsf);
|
||||
nsRefPtr<PostAvailableResultEvent> r = new PostAvailableResultEvent(this, p.fullpath());
|
||||
NS_DispatchToMainThread(r);
|
||||
break;
|
||||
}
|
||||
|
@ -114,7 +129,11 @@ DeviceStorageRequestParent::Dispatch()
|
|||
case DeviceStorageParams::TDeviceStorageEnumerationParams:
|
||||
{
|
||||
DeviceStorageEnumerationParams p = mParams;
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), p.relpath(), NS_LITERAL_STRING(""));
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(p.type(), f);
|
||||
nsRefPtr<CancelableRunnable> r = new EnumerateFileEvent(this, dsf, p.since());
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
|
@ -363,12 +382,8 @@ DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() {
|
|||
}
|
||||
|
||||
DeviceStorageRequestParent::PostEnumerationSuccessEvent::PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
|
||||
const nsAString& aStorageType,
|
||||
const nsAString& aRelPath,
|
||||
InfallibleTArray<DeviceStorageFileValue>& aPaths)
|
||||
: CancelableRunnable(aParent)
|
||||
, mStorageType(aStorageType)
|
||||
, mRelPath(aRelPath)
|
||||
, mPaths(aPaths)
|
||||
{
|
||||
}
|
||||
|
@ -379,7 +394,7 @@ nsresult
|
|||
DeviceStorageRequestParent::PostEnumerationSuccessEvent::CancelableRun() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
EnumerationResponse response(mStorageType, mRelPath, mPaths);
|
||||
EnumerationResponse response(mPaths);
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -606,11 +621,13 @@ DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
|
|||
|
||||
uint32_t count = files.Length();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
DeviceStorageFileValue dsvf(files[i]->mPath);
|
||||
nsString fullpath;
|
||||
files[i]->mFile->GetPath(fullpath);
|
||||
DeviceStorageFileValue dsvf(mFile->mStorageType, files[i]->mPath, fullpath);
|
||||
values.AppendElement(dsvf);
|
||||
}
|
||||
|
||||
r = new PostEnumerationSuccessEvent(mParent, mFile->mStorageType, mFile->mRootDir, values);
|
||||
r = new PostEnumerationSuccessEvent(mParent, values);
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -638,9 +655,9 @@ DeviceStorageRequestParent::PostPathResultEvent::CancelableRun()
|
|||
}
|
||||
|
||||
DeviceStorageRequestParent::PostAvailableResultEvent::PostAvailableResultEvent(DeviceStorageRequestParent* aParent,
|
||||
DeviceStorageFile* aFile)
|
||||
const nsAString &aPath)
|
||||
: CancelableRunnable(aParent)
|
||||
, mFile(aFile)
|
||||
, mPath(aPath)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -656,7 +673,7 @@ DeviceStorageRequestParent::PostAvailableResultEvent::CancelableRun()
|
|||
nsString state;
|
||||
state.Assign(NS_LITERAL_STRING("available"));
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsresult rv = GetSDCardStatus(mFile->mPath, state);
|
||||
nsresult rv = GetSDCardStatus(mPath, state);
|
||||
if (NS_FAILED(rv)) {
|
||||
state.Assign(NS_LITERAL_STRING("unavailable"));
|
||||
}
|
||||
|
|
|
@ -105,15 +105,10 @@ private:
|
|||
class PostEnumerationSuccessEvent : public CancelableRunnable
|
||||
{
|
||||
public:
|
||||
PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
|
||||
const nsAString& aStorageType,
|
||||
const nsAString& aRelPath,
|
||||
InfallibleTArray<DeviceStorageFileValue>& aPaths);
|
||||
PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent, InfallibleTArray<DeviceStorageFileValue>& aPaths);
|
||||
virtual ~PostEnumerationSuccessEvent();
|
||||
virtual nsresult CancelableRun();
|
||||
private:
|
||||
const nsString mStorageType;
|
||||
const nsString mRelPath;
|
||||
InfallibleTArray<DeviceStorageFileValue> mPaths;
|
||||
};
|
||||
|
||||
|
@ -216,11 +211,11 @@ private:
|
|||
class PostAvailableResultEvent : public CancelableRunnable
|
||||
{
|
||||
public:
|
||||
PostAvailableResultEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile);
|
||||
PostAvailableResultEvent(DeviceStorageRequestParent* aParent, const nsAString& aPath);
|
||||
virtual ~PostAvailableResultEvent();
|
||||
virtual nsresult CancelableRun();
|
||||
private:
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
nsString mPath;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
|
@ -27,13 +27,13 @@ struct BlobResponse
|
|||
|
||||
struct DeviceStorageFileValue
|
||||
{
|
||||
nsString type;
|
||||
nsString name;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct EnumerationResponse
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
DeviceStorageFileValue[] paths;
|
||||
};
|
||||
|
||||
|
|
|
@ -311,151 +311,35 @@ private:
|
|||
};
|
||||
|
||||
DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
|
||||
const nsAString& aRootDir,
|
||||
const nsAString& aPath)
|
||||
: mPath(aPath)
|
||||
, mStorageType(aStorageType)
|
||||
, mRootDir(aRootDir)
|
||||
, mEditable(false)
|
||||
{
|
||||
Init(aStorageType);
|
||||
AppendRelativePath(mRootDir);
|
||||
if (!mPath.EqualsLiteral("")) {
|
||||
AppendRelativePath(mPath);
|
||||
}
|
||||
NormalizeFilePath();
|
||||
}
|
||||
|
||||
DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
|
||||
nsIFile* aFile,
|
||||
const nsAString& aPath)
|
||||
: mPath(aPath)
|
||||
, mStorageType(aStorageType)
|
||||
, mEditable(false)
|
||||
{
|
||||
Init(aStorageType);
|
||||
AppendRelativePath(aPath);
|
||||
NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
|
||||
// always take a clone
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aFile->Clone(getter_AddRefs(mFile));
|
||||
|
||||
AppendRelativePath();
|
||||
NormalizeFilePath();
|
||||
}
|
||||
|
||||
DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType)
|
||||
: mStorageType(aStorageType)
|
||||
, mEditable(false)
|
||||
{
|
||||
Init(aStorageType);
|
||||
}
|
||||
|
||||
void
|
||||
DeviceStorageFile::Init(const nsAString& aStorageType)
|
||||
{
|
||||
// The hard-coded sdcard below will change as part of bug 858416
|
||||
DeviceStorageFile::GetRootDirectoryForType(aStorageType,
|
||||
NS_LITERAL_STRING("sdcard"),
|
||||
getter_AddRefs(mFile));
|
||||
|
||||
DebugOnly<DeviceStorageTypeChecker*> typeChecker = DeviceStorageTypeChecker::CreateOrGet();
|
||||
NS_ASSERTION(typeChecker, "DeviceStorageTypeChecker is null");
|
||||
}
|
||||
|
||||
void
|
||||
DeviceStorageFile::GetRootDirectoryForType(const nsAString &aType, const
|
||||
nsAString &aVolName,
|
||||
nsIFile** aFile)
|
||||
DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile)
|
||||
: mStorageType(aStorageType)
|
||||
, mEditable(false)
|
||||
{
|
||||
nsCOMPtr<nsIFile> f;
|
||||
nsCOMPtr<nsIProperties> dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(dirService, "Must have directory service");
|
||||
NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
|
||||
// always take a clone
|
||||
nsCOMPtr<nsIFile> file;
|
||||
aFile->Clone(getter_AddRefs(mFile));
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsString volMountPoint(NS_LITERAL_STRING("/sdcard"));
|
||||
if (!aVolName.EqualsLiteral("")) {
|
||||
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
|
||||
if (vs) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIVolume> vol;
|
||||
rv = vs->GetVolumeByName(aVolName, getter_AddRefs(vol));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
vol->GetMountPoint(volMountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Picture directory
|
||||
if (aType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Video directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Music directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Apps directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_APPS)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/data"), false, getter_AddRefs(f));
|
||||
#else
|
||||
dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("webapps"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// default SDCard
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#else
|
||||
// Eventually, on desktop, we want to do something smarter -- for example,
|
||||
// detect when an sdcard is inserted, and use that instead of this.
|
||||
dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("fake-sdcard"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// in testing, we default all device storage types to a temp directory
|
||||
if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
|
||||
dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("device-storage-testing"));
|
||||
f->Create(nsIFile::DIRECTORY_TYPE, 0777);
|
||||
f->Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aFile = f.get());
|
||||
DebugOnly<DeviceStorageTypeChecker*> typeChecker = DeviceStorageTypeChecker::CreateOrGet();
|
||||
NS_ASSERTION(typeChecker, "DeviceStorageTypeChecker is null");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -473,16 +357,10 @@ DeviceStorageFile::SetEditable(bool aEditable) {
|
|||
// outside of the type of storage the user asked for.
|
||||
bool
|
||||
DeviceStorageFile::IsSafePath()
|
||||
{
|
||||
return IsSafePath(mRootDir) && IsSafePath(mPath);
|
||||
}
|
||||
|
||||
bool
|
||||
DeviceStorageFile::IsSafePath(const nsAString& aPath)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aPath.BeginReading(start);
|
||||
aPath.EndReading(end);
|
||||
mPath.BeginReading(start);
|
||||
mPath.EndReading(end);
|
||||
|
||||
// if the path has a ~ or \ in it, return false.
|
||||
NS_NAMED_LITERAL_STRING(tilde, "~");
|
||||
|
@ -492,7 +370,7 @@ DeviceStorageFile::IsSafePath(const nsAString& aPath)
|
|||
return false;
|
||||
}
|
||||
// split on /. if any token is "", ., or .., return false.
|
||||
NS_ConvertUTF16toUTF8 cname(aPath);
|
||||
NS_ConvertUTF16toUTF8 cname(mPath);
|
||||
char* buffer = cname.BeginWriting();
|
||||
const char* token;
|
||||
|
||||
|
@ -519,12 +397,12 @@ DeviceStorageFile::NormalizeFilePath() {
|
|||
}
|
||||
|
||||
void
|
||||
DeviceStorageFile::AppendRelativePath(const nsAString& aPath) {
|
||||
DeviceStorageFile::AppendRelativePath() {
|
||||
#if defined(XP_WIN)
|
||||
// replace forward slashes with backslashes,
|
||||
// since nsLocalFileWin chokes on them
|
||||
nsString temp;
|
||||
temp.Assign(aPath);
|
||||
temp.Assign(mPath);
|
||||
|
||||
PRUnichar* cur = temp.BeginWriting();
|
||||
PRUnichar* end = temp.EndWriting();
|
||||
|
@ -535,7 +413,7 @@ DeviceStorageFile::AppendRelativePath(const nsAString& aPath) {
|
|||
}
|
||||
mFile->AppendRelativePath(temp);
|
||||
#else
|
||||
mFile->AppendRelativePath(aPath);
|
||||
mFile->AppendRelativePath(mPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -657,6 +535,7 @@ DeviceStorageFile::CollectFiles(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles,
|
|||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return collectFilesInternal(aFiles, aSince, rootPath);
|
||||
}
|
||||
|
||||
|
@ -705,10 +584,12 @@ DeviceStorageFile::collectFilesInternal(nsTArray<nsRefPtr<DeviceStorageFile> > &
|
|||
nsDependentSubstring newPath = Substring(fullpath, len);
|
||||
|
||||
if (isDir) {
|
||||
DeviceStorageFile dsf(mStorageType, mRootDir, newPath);
|
||||
DeviceStorageFile dsf(mStorageType, f);
|
||||
dsf.SetPath(newPath);
|
||||
dsf.collectFilesInternal(aFiles, aSince, aRootPath);
|
||||
} else if (isFile) {
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDir, newPath);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, f);
|
||||
dsf->SetPath(newPath);
|
||||
aFiles.AppendElement(dsf);
|
||||
}
|
||||
}
|
||||
|
@ -824,13 +705,11 @@ UnregisterForSDCardChanges(nsIObserver* aObserver)
|
|||
#endif
|
||||
|
||||
void
|
||||
nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType,
|
||||
const nsAString& aVolName)
|
||||
nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType, const nsAString& aVolName)
|
||||
{
|
||||
nsCOMPtr<nsIFile> f;
|
||||
DeviceStorageFile::GetRootDirectoryForType(aType,
|
||||
aVolName,
|
||||
getter_AddRefs(f));
|
||||
nsCOMPtr<nsIProperties> dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(dirService, "Must have directory service");
|
||||
|
||||
mVolumeName = NS_LITERAL_STRING("");
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
|
@ -847,7 +726,84 @@ nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Picture directory
|
||||
if (aType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Video directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Music directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#elif defined (MOZ_WIDGET_COCOA)
|
||||
dirService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_UNIX)
|
||||
dirService->Get(NS_UNIX_XDG_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#elif defined (XP_WIN)
|
||||
dirService->Get(NS_WIN_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Apps directory
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_APPS)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(NS_LITERAL_STRING("/data"), false, getter_AddRefs(f));
|
||||
#else
|
||||
dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("webapps"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// default SDCard
|
||||
else if (aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
|
||||
#else
|
||||
// Eventually, on desktop, we want to do something smarter -- for example,
|
||||
// detect when an sdcard is inserted, and use that instead of this.
|
||||
dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("fake-sdcard"));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// in testing, we default all device storage types to a temp directory
|
||||
if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
|
||||
dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
|
||||
if (f) {
|
||||
f->AppendRelativeNativePath(NS_LITERAL_CSTRING("device-storage-testing"));
|
||||
f->Create(nsIFile::DIRECTORY_TYPE, 0777);
|
||||
f->Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
RegisterForSDCardChanges(this);
|
||||
#endif
|
||||
|
||||
|
@ -1069,13 +1025,20 @@ ContinueCursorEvent::Continue()
|
|||
return;
|
||||
}
|
||||
|
||||
nsString fullpath;
|
||||
nsresult rv = file->mFile->GetPath(fullpath);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(false, "GetPath failed to return a valid path");
|
||||
return;
|
||||
}
|
||||
|
||||
nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
|
||||
nsString cursorStorageType;
|
||||
cursor->GetStorageType(cursorStorageType);
|
||||
|
||||
DeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, file);
|
||||
child->SetCallback(cursor);
|
||||
DeviceStorageGetParams params(cursorStorageType, file->mRootDir, file->mPath);
|
||||
DeviceStorageGetParams params(cursorStorageType, file->mPath, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
mRequest = nullptr;
|
||||
}
|
||||
|
@ -1216,8 +1179,17 @@ nsDOMDeviceStorageCursor::Allow()
|
|||
}
|
||||
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
|
||||
nsString fullpath;
|
||||
nsresult rv = mFile->mFile->GetPath(fullpath);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// just do nothing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(this, mFile);
|
||||
DeviceStorageEnumerationParams params(mFile->mStorageType, mFile->mRootDir, mSince);
|
||||
DeviceStorageEnumerationParams params(mFile->mStorageType, fullpath, mSince);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1677,6 +1649,14 @@ public:
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsString fullpath;
|
||||
nsresult rv = mFile->mFile->GetPath(fullpath);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// just do nothing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch(mRequestType) {
|
||||
case DEVICE_STORAGE_REQUEST_CREATE:
|
||||
{
|
||||
|
@ -1706,7 +1686,8 @@ public:
|
|||
DeviceStorageAddParams params;
|
||||
params.blobChild() = actor;
|
||||
params.type() = mFile->mStorageType;
|
||||
params.relpath() = mFile->mPath;
|
||||
params.name() = mFile->mPath;
|
||||
params.fullpath() = fullpath;
|
||||
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
|
@ -1732,7 +1713,7 @@ public:
|
|||
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
DeviceStorageGetParams params(mFile->mStorageType, mFile->mRootDir, mFile->mPath);
|
||||
DeviceStorageGetParams params(mFile->mStorageType, mFile->mPath, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1756,7 +1737,7 @@ public:
|
|||
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
DeviceStorageDeleteParams params(mFile->mStorageType, mFile->mPath);
|
||||
DeviceStorageDeleteParams params(mFile->mStorageType, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1768,7 +1749,7 @@ public:
|
|||
{
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
DeviceStorageFreeSpaceParams params(mFile->mStorageType, mFile->mPath);
|
||||
DeviceStorageFreeSpaceParams params(mFile->mStorageType, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1780,7 +1761,7 @@ public:
|
|||
{
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
DeviceStorageUsedSpaceParams params(mFile->mStorageType, mFile->mPath);
|
||||
DeviceStorageUsedSpaceParams params(mFile->mStorageType, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1792,7 +1773,7 @@ public:
|
|||
{
|
||||
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
|
||||
DeviceStorageAvailableParams params(mFile->mStorageType, mFile->mPath);
|
||||
DeviceStorageAvailableParams params(mFile->mStorageType, fullpath);
|
||||
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2042,7 +2023,7 @@ nsDOMDeviceStorage::AddNamed(nsIDOMBlob *aBlob,
|
|||
|
||||
nsCOMPtr<nsIRunnable> r;
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, aPath);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, aPath);
|
||||
if (!dsf->IsSafePath()) {
|
||||
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
|
||||
} else if (!typeChecker->Check(mStorageType, dsf->mFile) ||
|
||||
|
@ -2098,7 +2079,7 @@ nsDOMDeviceStorage::GetInternal(const JS::Value & aPath,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, path);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
|
||||
dsf->SetEditable(aEditable);
|
||||
if (!dsf->IsSafePath()) {
|
||||
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
|
||||
|
@ -2131,7 +2112,7 @@ nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMReq
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, path);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
|
||||
|
||||
if (!dsf->IsSafePath()) {
|
||||
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
|
||||
|
@ -2155,7 +2136,7 @@ nsDOMDeviceStorage::FreeSpace(nsIDOMDOMRequest** aRetval)
|
|||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
NS_ADDREF(*aRetval = request);
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
|
||||
nsCOMPtr<nsIRunnable> r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_FREE_SPACE,
|
||||
win,
|
||||
mPrincipal,
|
||||
|
@ -2176,7 +2157,7 @@ nsDOMDeviceStorage::UsedSpace(nsIDOMDOMRequest** aRetval)
|
|||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
NS_ADDREF(*aRetval = request);
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
|
||||
nsCOMPtr<nsIRunnable> r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_USED_SPACE,
|
||||
win,
|
||||
mPrincipal,
|
||||
|
@ -2197,7 +2178,7 @@ nsDOMDeviceStorage::Available(nsIDOMDOMRequest** aRetval)
|
|||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
NS_ADDREF(*aRetval = request);
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
|
||||
nsCOMPtr<nsIRunnable> r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_AVAILABLE,
|
||||
win,
|
||||
mPrincipal,
|
||||
|
@ -2297,7 +2278,7 @@ nsDOMDeviceStorage::EnumerateInternal(const JS::Value & aName,
|
|||
since = ExtractDateFromOptions(aCx, aOptions);
|
||||
}
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, path, NS_LITERAL_STRING(""));
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
|
||||
dsf->SetEditable(aEditable);
|
||||
|
||||
nsRefPtr<nsDOMDeviceStorageCursor> cursor = new nsDOMDeviceStorageCursor(win, mPrincipal,
|
||||
|
@ -2471,7 +2452,7 @@ nsDOMDeviceStorage::AddEventListener(const nsAString & aType,
|
|||
}
|
||||
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
|
||||
nsCOMPtr<nsIRunnable> r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_WATCH,
|
||||
win, mPrincipal, dsf, request, this);
|
||||
NS_DispatchToMainThread(r);
|
||||
|
@ -2492,7 +2473,7 @@ nsDOMDeviceStorage::AddEventListener(const nsAString & aType,
|
|||
}
|
||||
|
||||
nsRefPtr<DOMRequest> request = new DOMRequest(win);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType);
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
|
||||
nsCOMPtr<nsIRunnable> r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_WATCH,
|
||||
win, mPrincipal, dsf, request, this);
|
||||
NS_DispatchToMainThread(r);
|
||||
|
|
|
@ -1176,7 +1176,10 @@ ContentChild::RecvLastPrivateDocShellDestroyed()
|
|||
bool
|
||||
ContentChild::RecvFilePathUpdate(const nsString& type, const nsString& path, const nsCString& aReason)
|
||||
{
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(type, path);
|
||||
nsCOMPtr<nsIFile> file;
|
||||
NS_NewLocalFile(path, false, getter_AddRefs(file));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(type, file);
|
||||
|
||||
nsString reason;
|
||||
CopyASCIItoUTF16(aReason, reason);
|
||||
|
|
|
@ -1531,7 +1531,10 @@ ContentParent::Observe(nsISupports* aSubject,
|
|||
CopyUTF16toUTF8(aData, creason);
|
||||
DeviceStorageFile* file = static_cast<DeviceStorageFile*>(aSubject);
|
||||
|
||||
unused << SendFilePathUpdate(file->mStorageType, file->mPath, creason);
|
||||
nsString path;
|
||||
file->mFile->GetPath(path);
|
||||
|
||||
unused << SendFilePathUpdate(file->mStorageType, path, creason);
|
||||
}
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
else if(!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) {
|
||||
|
@ -2346,11 +2349,15 @@ ContentParent::RecvAsyncMessage(const nsString& aMsg,
|
|||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvFilePathUpdateNotify(const nsString& aType,
|
||||
const nsString& aFilePath,
|
||||
const nsCString& aReason)
|
||||
ContentParent::RecvFilePathUpdateNotify(const nsString& aType, const nsString& aFilePath, const nsCString& aReason)
|
||||
{
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aType, aFilePath);
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsresult rv = NS_NewLocalFile(aFilePath, false, getter_AddRefs(file));
|
||||
if (NS_FAILED(rv)) {
|
||||
// ignore
|
||||
return true;
|
||||
}
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aType, file);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs) {
|
||||
|
|
|
@ -63,45 +63,46 @@ struct FontListEntry {
|
|||
struct DeviceStorageFreeSpaceParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageUsedSpaceParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageAvailableParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageAddParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
PBlob blob;
|
||||
nsString name;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageGetParams
|
||||
{
|
||||
nsString type;
|
||||
nsString rootDir;
|
||||
nsString relpath;
|
||||
nsString name;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageDeleteParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageEnumerationParams
|
||||
{
|
||||
nsString type;
|
||||
nsString relpath;
|
||||
nsString fullpath;
|
||||
uint64_t since;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче