2012-06-20 03:14:39 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "DeviceStorageRequestParent.h"
|
|
|
|
#include "nsDOMFile.h"
|
|
|
|
#include "nsIMIMEService.h"
|
|
|
|
#include "nsCExternalHandlerService.h"
|
|
|
|
#include "mozilla/unused.h"
|
2012-08-10 02:41:18 +04:00
|
|
|
#include "mozilla/dom/ipc/Blob.h"
|
|
|
|
#include "ContentParent.h"
|
|
|
|
#include "nsProxyRelease.h"
|
2012-12-22 15:53:38 +04:00
|
|
|
#include "AppProcessChecker.h"
|
2012-11-30 09:41:40 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsNetCID.h"
|
2012-06-20 03:14:39 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace devicestorage {
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::DeviceStorageRequestParent(
|
|
|
|
const DeviceStorageParams& aParams)
|
2012-11-30 09:41:40 +04:00
|
|
|
: mParams(aParams)
|
|
|
|
, mMutex("DeviceStorageRequestParent::mMutex")
|
2012-08-28 19:39:22 +04:00
|
|
|
, mActorDestoryed(false)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DeviceStorageRequestParent);
|
2013-05-03 03:26:31 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DebugOnly<DeviceStorageUsedSpaceCache*> usedSpaceCache
|
|
|
|
= DeviceStorageUsedSpaceCache::CreateOrGet();
|
2013-05-03 03:26:31 +04:00
|
|
|
NS_ASSERTION(usedSpaceCache, "DeviceStorageUsedSpaceCache is null");
|
2012-11-30 09:41:40 +04:00
|
|
|
}
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2012-11-30 09:41:40 +04:00
|
|
|
void
|
|
|
|
DeviceStorageRequestParent::Dispatch()
|
|
|
|
{
|
|
|
|
switch (mParams.type()) {
|
2012-06-20 03:14:39 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageAddParams:
|
|
|
|
{
|
2012-11-30 09:41:40 +04:00
|
|
|
DeviceStorageAddParams p = mParams;
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName(), p.relpath());
|
2012-08-10 02:41:18 +04:00
|
|
|
|
|
|
|
BlobParent* bp = static_cast<BlobParent*>(p.blobParent());
|
|
|
|
nsCOMPtr<nsIDOMBlob> blob = bp->GetBlob();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
|
|
blob->GetInternalStream(getter_AddRefs(stream));
|
|
|
|
|
|
|
|
nsRefPtr<CancelableRunnable> r = new WriteFileEvent(this, dsf, stream);
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> target
|
|
|
|
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(target, "Must have stream transport service");
|
|
|
|
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageGetParams:
|
|
|
|
{
|
2012-11-30 09:41:40 +04:00
|
|
|
DeviceStorageGetParams p = mParams;
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
2013-08-03 03:35:16 +04:00
|
|
|
new DeviceStorageFile(p.type(), p.storageName(),
|
|
|
|
p.rootDir(), p.relpath());
|
2012-08-10 02:41:18 +04:00
|
|
|
nsRefPtr<CancelableRunnable> r = new ReadFileEvent(this, dsf);
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> target
|
|
|
|
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(target, "Must have stream transport service");
|
|
|
|
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageDeleteParams:
|
|
|
|
{
|
2012-11-30 09:41:40 +04:00
|
|
|
DeviceStorageDeleteParams p = mParams;
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName(), p.relpath());
|
2012-08-10 02:41:18 +04:00
|
|
|
nsRefPtr<CancelableRunnable> r = new DeleteFileEvent(this, dsf);
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> target
|
|
|
|
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(target, "Must have stream transport service");
|
|
|
|
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageFreeSpaceParams:
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageFreeSpaceParams p = mParams;
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName());
|
2013-01-25 23:05:24 +04:00
|
|
|
nsRefPtr<FreeSpaceFileEvent> r = new FreeSpaceFileEvent(this, dsf);
|
2012-07-31 23:28:23 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> target
|
|
|
|
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
2012-07-31 23:28:23 +04:00
|
|
|
NS_ASSERTION(target, "Must have stream transport service");
|
|
|
|
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageUsedSpaceParams:
|
|
|
|
{
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageUsedSpaceCache* usedSpaceCache
|
|
|
|
= DeviceStorageUsedSpaceCache::CreateOrGet();
|
2013-05-03 03:26:31 +04:00
|
|
|
NS_ASSERTION(usedSpaceCache, "DeviceStorageUsedSpaceCache is null");
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageUsedSpaceParams p = mParams;
|
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName());
|
2013-01-25 23:05:24 +04:00
|
|
|
nsRefPtr<UsedSpaceFileEvent> r = new UsedSpaceFileEvent(this, dsf);
|
|
|
|
|
2013-05-03 03:26:31 +04:00
|
|
|
usedSpaceCache->Dispatch(r);
|
2013-01-25 23:05:24 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageAvailableParams:
|
|
|
|
{
|
2013-04-02 23:52:21 +04:00
|
|
|
DeviceStorageAvailableParams p = mParams;
|
2013-04-18 18:13:23 +04:00
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName());
|
2013-08-03 03:35:16 +04:00
|
|
|
nsRefPtr<PostAvailableResultEvent> r
|
|
|
|
= new PostAvailableResultEvent(this, dsf);
|
2013-01-25 23:05:24 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:11:58 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageFormatParams:
|
|
|
|
{
|
|
|
|
DeviceStorageFormatParams p = mParams;
|
|
|
|
|
|
|
|
nsRefPtr<DeviceStorageFile> dsf =
|
|
|
|
new DeviceStorageFile(p.type(), p.storageName());
|
|
|
|
nsRefPtr<PostFormatResultEvent> r
|
|
|
|
= new PostFormatResultEvent(this, dsf);
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageEnumerationParams:
|
|
|
|
{
|
2012-11-30 09:41:40 +04:00
|
|
|
DeviceStorageEnumerationParams p = mParams;
|
2013-05-11 13:10:18 +04:00
|
|
|
nsRefPtr<DeviceStorageFile> dsf
|
2013-08-03 03:35:16 +04:00
|
|
|
= new DeviceStorageFile(p.type(), p.storageName(),
|
|
|
|
p.rootdir(), NS_LITERAL_STRING(""));
|
|
|
|
nsRefPtr<CancelableRunnable> r
|
|
|
|
= new EnumerateFileEvent(this, dsf, p.since());
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIEventTarget> target
|
|
|
|
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(target, "Must have stream transport service");
|
|
|
|
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-30 09:41:40 +04:00
|
|
|
bool
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::EnsureRequiredPermissions(
|
|
|
|
mozilla::dom::ContentParent* aParent)
|
2012-11-30 09:41:40 +04:00
|
|
|
{
|
|
|
|
if (mozilla::Preferences::GetBool("device.storage.testing", false)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString type;
|
|
|
|
DeviceStorageRequestType requestType;
|
|
|
|
|
|
|
|
switch (mParams.type())
|
|
|
|
{
|
|
|
|
case DeviceStorageParams::TDeviceStorageAddParams:
|
|
|
|
{
|
|
|
|
DeviceStorageAddParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_CREATE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageGetParams:
|
|
|
|
{
|
|
|
|
DeviceStorageGetParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_READ;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageDeleteParams:
|
|
|
|
{
|
|
|
|
DeviceStorageDeleteParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_DELETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageFreeSpaceParams:
|
|
|
|
{
|
|
|
|
DeviceStorageFreeSpaceParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_FREE_SPACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageUsedSpaceParams:
|
|
|
|
{
|
|
|
|
DeviceStorageUsedSpaceParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_FREE_SPACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeviceStorageParams::TDeviceStorageAvailableParams:
|
2012-11-30 09:41:40 +04:00
|
|
|
{
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageAvailableParams p = mParams;
|
2012-11-30 09:41:40 +04:00
|
|
|
type = p.type();
|
2013-01-25 23:05:24 +04:00
|
|
|
requestType = DEVICE_STORAGE_REQUEST_AVAILABLE;
|
2012-11-30 09:41:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:11:58 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageFormatParams:
|
|
|
|
{
|
|
|
|
DeviceStorageFormatParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_FORMAT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-11-30 09:41:40 +04:00
|
|
|
case DeviceStorageParams::TDeviceStorageEnumerationParams:
|
|
|
|
{
|
|
|
|
DeviceStorageEnumerationParams p = mParams;
|
|
|
|
type = p.type();
|
|
|
|
requestType = DEVICE_STORAGE_REQUEST_READ;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The 'apps' type is special. We only want this exposed
|
|
|
|
// if the caller has the "webapps-manage" permission.
|
|
|
|
if (type.EqualsLiteral("apps")) {
|
|
|
|
if (!AssertAppProcessPermission(aParent, "webapps-manage")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString permissionName;
|
2013-08-03 03:35:16 +04:00
|
|
|
nsresult rv = DeviceStorageTypeChecker::GetPermissionForType(type,
|
|
|
|
permissionName);
|
2012-11-30 09:41:40 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString access;
|
|
|
|
rv = DeviceStorageTypeChecker::GetAccessForRequest(requestType, access);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
permissionName.AppendLiteral("-");
|
|
|
|
permissionName.Append(access);
|
|
|
|
|
|
|
|
if (!AssertAppProcessPermission(aParent, permissionName.get())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
DeviceStorageRequestParent::~DeviceStorageRequestParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DeviceStorageRequestParent);
|
|
|
|
}
|
|
|
|
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_IMPL_ADDREF(DeviceStorageRequestParent)
|
|
|
|
NS_IMPL_RELEASE(DeviceStorageRequestParent)
|
2012-08-10 02:41:18 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
DeviceStorageRequestParent::ActorDestroy(ActorDestroyReason)
|
|
|
|
{
|
2012-08-28 19:39:22 +04:00
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
mActorDestoryed = true;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t count = mRunnables.Length();
|
|
|
|
for (int32_t index = 0; index < count; index++) {
|
2012-08-10 02:41:18 +04:00
|
|
|
mRunnables[index]->Cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostFreeSpaceResultEvent::PostFreeSpaceResultEvent(
|
|
|
|
DeviceStorageRequestParent* aParent,
|
|
|
|
uint64_t aFreeSpace)
|
2013-01-25 23:05:24 +04:00
|
|
|
: CancelableRunnable(aParent)
|
|
|
|
, mFreeSpace(aFreeSpace)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostFreeSpaceResultEvent::
|
|
|
|
~PostFreeSpaceResultEvent() {}
|
2013-01-25 23:05:24 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostFreeSpaceResultEvent::CancelableRun() {
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
FreeSpaceStorageResponse response(mFreeSpace);
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostUsedSpaceResultEvent::
|
|
|
|
PostUsedSpaceResultEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
const nsAString& aType,
|
|
|
|
uint64_t aUsedSpace)
|
2013-01-25 23:05:24 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2013-05-03 03:26:31 +04:00
|
|
|
, mType(aType)
|
2013-01-25 23:05:24 +04:00
|
|
|
, mUsedSpace(aUsedSpace)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostUsedSpaceResultEvent::
|
|
|
|
~PostUsedSpaceResultEvent() {}
|
2013-01-25 23:05:24 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostUsedSpaceResultEvent::CancelableRun() {
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
UsedSpaceStorageResponse response(mUsedSpace);
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostErrorEvent::
|
|
|
|
PostErrorEvent(DeviceStorageRequestParent* aParent, const char* aError)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2012-08-10 02:41:18 +04:00
|
|
|
CopyASCIItoUTF16(aError, mError);
|
2012-06-20 03:14:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::PostErrorEvent::~PostErrorEvent() {}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostErrorEvent::CancelableRun() {
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
ErrorResponse response(mError);
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostSuccessEvent::
|
|
|
|
PostSuccessEvent(DeviceStorageRequestParent* aParent)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::PostSuccessEvent::~PostSuccessEvent() {}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostSuccessEvent::CancelableRun() {
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
SuccessResponse response;
|
2013-01-25 23:05:24 +04:00
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
2012-06-20 03:14:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostBlobSuccessEvent::
|
|
|
|
PostBlobSuccessEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile,
|
|
|
|
uint32_t aLength,
|
|
|
|
nsACString& aMimeType,
|
|
|
|
uint64_t aLastModifiedDate)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
|
|
|
, mLength(aLength)
|
2012-10-18 22:29:32 +04:00
|
|
|
, mLastModificationDate(aLastModifiedDate)
|
2012-08-10 02:41:18 +04:00
|
|
|
, mFile(aFile)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mMimeType(aMimeType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::PostBlobSuccessEvent::~PostBlobSuccessEvent() {}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() {
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsString mime;
|
|
|
|
CopyASCIItoUTF16(mMimeType, mime);
|
|
|
|
|
2013-08-03 03:34:59 +04:00
|
|
|
nsString fullPath;
|
|
|
|
mFile->GetFullPath(fullPath);
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(fullPath, mime, mLength,
|
|
|
|
mFile->mFile,
|
|
|
|
mLastModificationDate);
|
2012-08-10 02:41:18 +04:00
|
|
|
|
|
|
|
ContentParent* cp = static_cast<ContentParent*>(mParent->Manager());
|
|
|
|
BlobParent* actor = cp->GetOrCreateActorForBlob(blob);
|
2013-01-18 00:33:42 +04:00
|
|
|
if (!actor) {
|
|
|
|
ErrorResponse response(NS_LITERAL_STRING(POST_ERROR_EVENT_UNKNOWN));
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-08-10 02:41:18 +04:00
|
|
|
|
|
|
|
BlobResponse response;
|
|
|
|
response.blobParent() = actor;
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
2012-06-20 03:14:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostEnumerationSuccessEvent::
|
|
|
|
PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
const nsAString& aStorageType,
|
|
|
|
const nsAString& aRelPath,
|
|
|
|
InfallibleTArray<DeviceStorageFileValue>& aPaths)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2013-04-18 18:13:23 +04:00
|
|
|
, mStorageType(aStorageType)
|
|
|
|
, mRelPath(aRelPath)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mPaths(aPaths)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostEnumerationSuccessEvent::
|
|
|
|
~PostEnumerationSuccessEvent() {}
|
2012-06-20 03:14:39 +04:00
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostEnumerationSuccessEvent::CancelableRun() {
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2013-04-18 18:13:23 +04:00
|
|
|
EnumerationResponse response(mStorageType, mRelPath, mPaths);
|
2013-01-25 23:05:24 +04:00
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
2012-06-20 03:14:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::WriteFileEvent::
|
|
|
|
WriteFileEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile,
|
|
|
|
nsIInputStream* aInputStream)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mFile(aFile)
|
2012-08-10 02:41:18 +04:00
|
|
|
, mInputStream(aInputStream)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::WriteFileEvent::~WriteFileEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::WriteFileEvent::CancelableRun()
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2012-08-10 02:41:18 +04:00
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
nsRefPtr<nsRunnable> r;
|
2012-08-10 02:41:18 +04:00
|
|
|
|
|
|
|
if (!mInputStream) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-13 19:20:14 +04:00
|
|
|
bool check = false;
|
|
|
|
mFile->mFile->Exists(&check);
|
|
|
|
if (check) {
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<PostErrorEvent> event
|
|
|
|
= new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_EXISTS);
|
2012-10-13 19:20:14 +04:00
|
|
|
NS_DispatchToMainThread(event);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult rv = mFile->Write(mInputStream);
|
2012-06-20 03:14:39 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = new PostPathResultEvent(mParent, mFile->mPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::DeleteFileEvent::
|
|
|
|
DeleteFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mFile(aFile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::DeleteFileEvent::~DeleteFileEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::DeleteFileEvent::CancelableRun()
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2012-07-31 23:28:23 +04:00
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-08-18 06:43:00 +04:00
|
|
|
mFile->Remove();
|
2012-06-20 03:14:39 +04:00
|
|
|
|
|
|
|
nsRefPtr<nsRunnable> r;
|
|
|
|
|
|
|
|
bool check = false;
|
|
|
|
mFile->mFile->Exists(&check);
|
|
|
|
if (check) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = new PostPathResultEvent(mParent, mFile->mPath);
|
|
|
|
}
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::FreeSpaceFileEvent::
|
|
|
|
FreeSpaceFileEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile)
|
2012-07-31 23:28:23 +04:00
|
|
|
: CancelableRunnable(aParent)
|
|
|
|
, mFile(aFile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageRequestParent::FreeSpaceFileEvent::~FreeSpaceFileEvent()
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageRequestParent::FreeSpaceFileEvent::CancelableRun()
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2012-08-31 07:15:32 +04:00
|
|
|
int64_t freeSpace = 0;
|
2013-05-11 13:10:18 +04:00
|
|
|
if (mFile) {
|
|
|
|
mFile->GetDiskFreeSpace(&freeSpace);
|
2012-07-31 23:28:23 +04:00
|
|
|
}
|
2012-09-14 09:37:00 +04:00
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsCOMPtr<nsIRunnable> r;
|
2013-05-03 03:26:31 +04:00
|
|
|
r = new PostFreeSpaceResultEvent(mParent, static_cast<uint64_t>(freeSpace));
|
2013-01-25 23:05:24 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::UsedSpaceFileEvent::
|
|
|
|
UsedSpaceFileEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile)
|
2013-01-25 23:05:24 +04:00
|
|
|
: CancelableRunnable(aParent)
|
|
|
|
, mFile(aFile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::UsedSpaceFileEvent::~UsedSpaceFileEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::UsedSpaceFileEvent::CancelableRun()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
uint64_t picturesUsage = 0, videosUsage = 0, musicUsage = 0, totalUsage = 0;
|
|
|
|
mFile->AccumDiskUsage(&picturesUsage, &videosUsage,
|
|
|
|
&musicUsage, &totalUsage);
|
2013-01-25 23:05:24 +04:00
|
|
|
nsCOMPtr<nsIRunnable> r;
|
2013-05-11 13:10:18 +04:00
|
|
|
if (mFile->mStorageType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
|
2013-08-03 03:35:16 +04:00
|
|
|
r = new PostUsedSpaceResultEvent(mParent, mFile->mStorageType,
|
|
|
|
picturesUsage);
|
2013-05-11 13:10:18 +04:00
|
|
|
}
|
2013-05-11 13:10:18 +04:00
|
|
|
else if (mFile->mStorageType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
|
|
|
|
r = new PostUsedSpaceResultEvent(mParent, mFile->mStorageType, videosUsage);
|
|
|
|
}
|
|
|
|
else if (mFile->mStorageType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
|
|
|
|
r = new PostUsedSpaceResultEvent(mParent, mFile->mStorageType, musicUsage);
|
2013-05-11 17:47:37 +04:00
|
|
|
} else {
|
2013-05-11 13:10:18 +04:00
|
|
|
r = new PostUsedSpaceResultEvent(mParent, mFile->mStorageType, totalUsage);
|
2013-05-03 03:26:31 +04:00
|
|
|
}
|
2012-07-31 23:28:23 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::ReadFileEvent::
|
|
|
|
ReadFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mFile(aFile)
|
|
|
|
{
|
2013-08-03 03:35:16 +04:00
|
|
|
nsCOMPtr<nsIMIMEService> mimeService
|
|
|
|
= do_GetService(NS_MIMESERVICE_CONTRACTID);
|
2012-06-20 03:14:39 +04:00
|
|
|
if (mimeService) {
|
|
|
|
nsresult rv = mimeService->GetTypeFromFile(mFile->mFile, mMimeType);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mMimeType.Truncate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::ReadFileEvent::~ReadFileEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::ReadFileEvent::CancelableRun()
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2012-07-31 23:28:23 +04:00
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
nsCOMPtr<nsIRunnable> r;
|
|
|
|
bool check = false;
|
|
|
|
mFile->mFile->Exists(&check);
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
if (!check) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_FILE_DOES_NOT_EXIST);
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t fileSize;
|
2012-06-20 03:14:39 +04:00
|
|
|
nsresult rv = mFile->mFile->GetFileSize(&fileSize);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-18 22:29:32 +04:00
|
|
|
PRTime modDate;
|
|
|
|
rv = mFile->mFile->GetLastModifiedTime(&modDate);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
r = new PostBlobSuccessEvent(mParent, mFile, static_cast<uint64_t>(fileSize),
|
|
|
|
mMimeType, modDate);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::EnumerateFileEvent::
|
|
|
|
EnumerateFileEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile,
|
|
|
|
uint64_t aSince)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mFile(aFile)
|
|
|
|
, mSince(aSince)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::EnumerateFileEvent::~EnumerateFileEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2012-07-31 23:28:23 +04:00
|
|
|
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
2012-08-10 02:41:18 +04:00
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
nsCOMPtr<nsIRunnable> r;
|
2013-05-11 13:10:18 +04:00
|
|
|
if (mFile->mFile) {
|
|
|
|
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;
|
|
|
|
}
|
2012-06-20 03:14:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<nsRefPtr<DeviceStorageFile> > files;
|
|
|
|
mFile->CollectFiles(files, mSince);
|
|
|
|
|
|
|
|
InfallibleTArray<DeviceStorageFileValue> values;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count = files.Length();
|
|
|
|
for (uint32_t i = 0; i < count; i++) {
|
2013-05-11 13:10:18 +04:00
|
|
|
DeviceStorageFileValue dsvf(files[i]->mStorageName, files[i]->mPath);
|
2012-06-20 03:14:39 +04:00
|
|
|
values.AppendElement(dsvf);
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
r = new PostEnumerationSuccessEvent(mParent, mFile->mStorageType,
|
|
|
|
mFile->mRootDir, values);
|
2012-06-20 03:14:39 +04:00
|
|
|
NS_DispatchToMainThread(r);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostPathResultEvent::
|
|
|
|
PostPathResultEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
const nsAString& aPath)
|
2012-08-10 02:41:18 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2012-06-20 03:14:39 +04:00
|
|
|
, mPath(aPath)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::PostPathResultEvent::~PostPathResultEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-10 02:41:18 +04:00
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostPathResultEvent::CancelableRun()
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
SuccessResponse response;
|
2013-01-25 23:05:24 +04:00
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
2012-06-20 03:14:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostAvailableResultEvent::
|
|
|
|
PostAvailableResultEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile)
|
2012-07-31 23:28:23 +04:00
|
|
|
: CancelableRunnable(aParent)
|
2013-04-18 18:13:23 +04:00
|
|
|
, mFile(aFile)
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:35:16 +04:00
|
|
|
DeviceStorageRequestParent::PostAvailableResultEvent::
|
|
|
|
~PostAvailableResultEvent()
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2013-01-25 23:05:24 +04:00
|
|
|
DeviceStorageRequestParent::PostAvailableResultEvent::CancelableRun()
|
2012-07-31 23:28:23 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
2013-05-11 13:10:18 +04:00
|
|
|
nsString state = NS_LITERAL_STRING("unavailable");
|
|
|
|
if (mFile) {
|
|
|
|
mFile->GetStatus(state);
|
2012-08-17 03:03:06 +04:00
|
|
|
}
|
|
|
|
|
2013-01-25 23:05:24 +04:00
|
|
|
AvailableStorageResponse response(state);
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
2012-07-31 23:28:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:11:58 +04:00
|
|
|
DeviceStorageRequestParent::PostFormatResultEvent::
|
|
|
|
PostFormatResultEvent(DeviceStorageRequestParent* aParent,
|
|
|
|
DeviceStorageFile* aFile)
|
|
|
|
: CancelableRunnable(aParent)
|
|
|
|
, mFile(aFile)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceStorageRequestParent::PostFormatResultEvent::
|
|
|
|
~PostFormatResultEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
DeviceStorageRequestParent::PostFormatResultEvent::CancelableRun()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
nsString state = NS_LITERAL_STRING("unavailable");
|
|
|
|
if (mFile) {
|
|
|
|
mFile->DoFormat(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
FormatStorageResponse response(state);
|
|
|
|
unused << mParent->Send__delete__(mParent, response);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
} // namespace devicestorage
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|