зеркало из https://github.com/mozilla/gecko-dev.git
Bug 761930 - Multi-process support for Device Storage. r=sicking
This commit is contained in:
Родитель
11e349f7d9
Коммит
2eff5553d0
|
@ -0,0 +1,104 @@
|
|||
/* -*- 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 "DeviceStorageRequestChild.h"
|
||||
#include "nsDeviceStorage.h"
|
||||
#include "nsDOMFile.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace devicestorage {
|
||||
|
||||
DeviceStorageRequestChild::DeviceStorageRequestChild()
|
||||
{
|
||||
MOZ_COUNT_CTOR(DeviceStorageRequestChild);
|
||||
}
|
||||
|
||||
DeviceStorageRequestChild::DeviceStorageRequestChild(DOMRequest* aRequest,
|
||||
DeviceStorageFile* aFile)
|
||||
: mRequest(aRequest)
|
||||
, mFile(aFile)
|
||||
{
|
||||
MOZ_COUNT_CTOR(DeviceStorageRequestChild);
|
||||
}
|
||||
|
||||
DeviceStorageRequestChild::~DeviceStorageRequestChild() {
|
||||
MOZ_COUNT_DTOR(DeviceStorageRequestChild);
|
||||
}
|
||||
bool
|
||||
DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aValue)
|
||||
{
|
||||
switch (aValue.type()) {
|
||||
|
||||
case DeviceStorageResponseValue::TErrorResponse:
|
||||
{
|
||||
ErrorResponse r = aValue;
|
||||
mRequest->FireError(r.error());
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageResponseValue::TSuccessResponse:
|
||||
{
|
||||
jsval result = StringToJsval(mRequest->GetOwner(), mFile->mPath);
|
||||
mRequest->FireSuccess(result);
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageResponseValue::TBlobResponse:
|
||||
{
|
||||
BlobResponse r = aValue;
|
||||
|
||||
// I am going to hell for this. bent says he'll save me.
|
||||
const InfallibleTArray<PRUint8> bits = r.bits();
|
||||
void* buffer = PR_Malloc(bits.Length());
|
||||
memcpy(buffer, (void*) bits.Elements(), bits.Length());
|
||||
|
||||
nsString mimeType;
|
||||
mimeType.AssignWithConversion(r.contentType());
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMMemoryFile(buffer,
|
||||
bits.Length(),
|
||||
mFile->mPath,
|
||||
mimeType);
|
||||
|
||||
jsval result = BlobToJsval(mRequest->GetOwner(), blob);
|
||||
mRequest->FireSuccess(result);
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageResponseValue::TEnumerationResponse:
|
||||
{
|
||||
EnumerationResponse r = aValue;
|
||||
nsDOMDeviceStorageCursor* cursor = static_cast<nsDOMDeviceStorageCursor*>(mRequest.get());
|
||||
|
||||
PRUint32 count = r.paths().Length();
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(r.paths()[i].fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(f);
|
||||
dsf->SetPath(r.paths()[i].path());
|
||||
cursor->mFiles.AppendElement(dsf);
|
||||
}
|
||||
|
||||
nsCOMPtr<ContinueCursorEvent> event = new ContinueCursorEvent(cursor);
|
||||
NS_DispatchToMainThread(event);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
NS_RUNTIMEABORT("not reached");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace devicestorage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_devicestorage_DeviceStorageRequestChild_h
|
||||
#define mozilla_dom_devicestorage_DeviceStorageRequestChild_h
|
||||
|
||||
#include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h"
|
||||
#include "DOMRequest.h"
|
||||
#include "nsDeviceStorage.h"
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace devicestorage {
|
||||
|
||||
class DeviceStorageRequestChild : public PDeviceStorageRequestChild
|
||||
{
|
||||
public:
|
||||
DeviceStorageRequestChild();
|
||||
DeviceStorageRequestChild(DOMRequest* aRequest, DeviceStorageFile* aFile);
|
||||
~DeviceStorageRequestChild();
|
||||
|
||||
virtual bool Recv__delete__(const DeviceStorageResponseValue& value);
|
||||
|
||||
private:
|
||||
nsRefPtr<DOMRequest> mRequest;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
};
|
||||
|
||||
} // namespace devicestorage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -0,0 +1,360 @@
|
|||
/* -*- 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"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace devicestorage {
|
||||
|
||||
DeviceStorageRequestParent::DeviceStorageRequestParent(const DeviceStorageParams& aParams)
|
||||
{
|
||||
MOZ_COUNT_CTOR(DeviceStorageRequestParent);
|
||||
|
||||
switch (aParams.type()) {
|
||||
case DeviceStorageParams::TDeviceStorageAddParams:
|
||||
{
|
||||
DeviceStorageAddParams p = aParams;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(f);
|
||||
nsRefPtr<WriteFileEvent> r = new WriteFileEvent(this, dsf, p.bits());
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(target, "Must have stream transport service");
|
||||
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageParams::TDeviceStorageGetParams:
|
||||
{
|
||||
DeviceStorageGetParams p = aParams;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(f);
|
||||
nsRefPtr<ReadFileEvent> r = new ReadFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(target, "Must have stream transport service");
|
||||
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageParams::TDeviceStorageDeleteParams:
|
||||
{
|
||||
DeviceStorageDeleteParams p = aParams;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(f);
|
||||
nsRefPtr<DeleteFileEvent> r = new DeleteFileEvent(this, dsf);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(target, "Must have stream transport service");
|
||||
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
break;
|
||||
}
|
||||
|
||||
case DeviceStorageParams::TDeviceStorageEnumerationParams:
|
||||
{
|
||||
DeviceStorageEnumerationParams p = aParams;
|
||||
|
||||
nsCOMPtr<nsIFile> f;
|
||||
NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
|
||||
|
||||
nsRefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(f);
|
||||
nsRefPtr<EnumerateFileEvent> r = new EnumerateFileEvent(this, dsf, p.since());
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(target, "Must have stream transport service");
|
||||
target->Dispatch(r, NS_DISPATCH_NORMAL);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
NS_RUNTIMEABORT("not reached");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::~DeviceStorageRequestParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(DeviceStorageRequestParent);
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostErrorEvent::PostErrorEvent(DeviceStorageRequestParent* aParent,
|
||||
const char* aError)
|
||||
: mParent(aParent)
|
||||
{
|
||||
mError.AssignWithConversion(aError);
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostErrorEvent::~PostErrorEvent() {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::PostErrorEvent::Run() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
ErrorResponse response(mError);
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
DeviceStorageRequestParent::PostSuccessEvent::PostSuccessEvent(DeviceStorageRequestParent* aParent)
|
||||
: mParent(aParent)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostSuccessEvent::~PostSuccessEvent() {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::PostSuccessEvent::Run() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
SuccessResponse response;
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostBlobSuccessEvent::PostBlobSuccessEvent(DeviceStorageRequestParent* aParent,
|
||||
void* aBuffer,
|
||||
PRUint32 aLength,
|
||||
nsACString& aMimeType)
|
||||
: mParent(aParent)
|
||||
, mMimeType(aMimeType)
|
||||
{
|
||||
mBits.SetCapacity(aLength);
|
||||
void* bits = mBits.Elements();
|
||||
memcpy(bits, aBuffer, aLength);
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostBlobSuccessEvent::~PostBlobSuccessEvent() {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::PostBlobSuccessEvent::Run() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
BlobResponse response(mBits, mMimeType);
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostEnumerationSuccessEvent::PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
|
||||
InfallibleTArray<DeviceStorageFileValue>& aPaths)
|
||||
: mParent(aParent)
|
||||
, mPaths(aPaths)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostEnumerationSuccessEvent::~PostEnumerationSuccessEvent() {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::PostEnumerationSuccessEvent::Run() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
EnumerationResponse response(mPaths);
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::WriteFileEvent::WriteFileEvent(DeviceStorageRequestParent* aParent,
|
||||
DeviceStorageFile* aFile,
|
||||
InfallibleTArray<PRUint8>& aBits)
|
||||
: mParent(aParent)
|
||||
, mFile(aFile)
|
||||
, mBits(aBits)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::WriteFileEvent::~WriteFileEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::WriteFileEvent::Run()
|
||||
{
|
||||
nsRefPtr<nsRunnable> r;
|
||||
nsresult rv = mFile->Write(mBits);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
DeviceStorageRequestParent::DeleteFileEvent::DeleteFileEvent(DeviceStorageRequestParent* aParent,
|
||||
DeviceStorageFile* aFile)
|
||||
: mParent(aParent)
|
||||
, mFile(aFile)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::DeleteFileEvent::~DeleteFileEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::DeleteFileEvent::Run()
|
||||
{
|
||||
mFile->mFile->Remove(true);
|
||||
|
||||
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);
|
||||
}
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::ReadFileEvent::ReadFileEvent(DeviceStorageRequestParent* aParent,
|
||||
DeviceStorageFile* aFile)
|
||||
: mParent(aParent)
|
||||
, mFile(aFile)
|
||||
{
|
||||
nsCOMPtr<nsIMIMEService> mimeService = do_GetService(NS_MIMESERVICE_CONTRACTID);
|
||||
if (mimeService) {
|
||||
nsresult rv = mimeService->GetTypeFromFile(mFile->mFile, mMimeType);
|
||||
if (NS_FAILED(rv)) {
|
||||
mMimeType.Truncate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::ReadFileEvent::~ReadFileEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::ReadFileEvent::Run()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
PRInt64 fileSize;
|
||||
nsresult rv = mFile->mFile->GetFileSize(&fileSize);
|
||||
if (NS_FAILED(rv)) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRFileDesc *fileHandle;
|
||||
rv = mFile->mFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fileHandle);
|
||||
|
||||
// i am going to hell. this is temp until bent provides seralizaiton of blobs.
|
||||
void* buf = (void*) malloc(fileSize);
|
||||
PRInt32 read = PR_Read(fileHandle, buf, fileSize);
|
||||
if (read != fileSize) {
|
||||
r = new PostErrorEvent(mParent, POST_ERROR_EVENT_UNKNOWN);
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
r = new PostBlobSuccessEvent(mParent, buf, fileSize, mMimeType);
|
||||
|
||||
PR_Free(buf);
|
||||
PR_Close(fileHandle);
|
||||
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::EnumerateFileEvent::EnumerateFileEvent(DeviceStorageRequestParent* aParent,
|
||||
DeviceStorageFile* aFile,
|
||||
PRUint32 aSince)
|
||||
: mParent(aParent)
|
||||
, mFile(aFile)
|
||||
, mSince(aSince)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::EnumerateFileEvent::~EnumerateFileEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::EnumerateFileEvent::Run()
|
||||
{
|
||||
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(fullpath, files[i]->mPath);
|
||||
values.AppendElement(dsvf);
|
||||
}
|
||||
|
||||
r = new PostEnumerationSuccessEvent(mParent, values);
|
||||
NS_DispatchToMainThread(r);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
DeviceStorageRequestParent::PostPathResultEvent::PostPathResultEvent(DeviceStorageRequestParent* aParent,
|
||||
const nsAString& aPath)
|
||||
: mParent(aParent)
|
||||
, mPath(aPath)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceStorageRequestParent::PostPathResultEvent::~PostPathResultEvent()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DeviceStorageRequestParent::PostPathResultEvent::Run()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
SuccessResponse response;
|
||||
unused << mParent->Send__delete__(mParent, response);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
} // namespace devicestorage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,136 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_devicestorage_DeviceStorageRequestParent_h
|
||||
#define mozilla_dom_devicestorage_DeviceStorageRequestParent_h
|
||||
|
||||
#include "mozilla/dom/devicestorage/PDeviceStorageRequestParent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsDeviceStorage.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace devicestorage {
|
||||
|
||||
class DeviceStorageRequestParent : public PDeviceStorageRequestParent
|
||||
{
|
||||
public:
|
||||
DeviceStorageRequestParent(const DeviceStorageParams& aParams);
|
||||
~DeviceStorageRequestParent();
|
||||
|
||||
private:
|
||||
class PostErrorEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PostErrorEvent(DeviceStorageRequestParent* aParent, const char* aError);
|
||||
~PostErrorEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsString mError;
|
||||
};
|
||||
|
||||
class PostSuccessEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PostSuccessEvent(DeviceStorageRequestParent* aParent);
|
||||
~PostSuccessEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
};
|
||||
|
||||
class PostBlobSuccessEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PostBlobSuccessEvent(DeviceStorageRequestParent* aParent, void* aBuffer, PRUint32 aLength, nsACString& aMimeType);
|
||||
~PostBlobSuccessEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
InfallibleTArray<PRUint8> mBits;
|
||||
nsCString mMimeType;
|
||||
};
|
||||
|
||||
class PostEnumerationSuccessEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent, InfallibleTArray<DeviceStorageFileValue>& aPaths);
|
||||
~PostEnumerationSuccessEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
InfallibleTArray<DeviceStorageFileValue> mPaths;
|
||||
};
|
||||
|
||||
class WriteFileEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
WriteFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile, InfallibleTArray<PRUint8>& aBits);
|
||||
~WriteFileEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
InfallibleTArray<PRUint8> mBits; // another copy?
|
||||
};
|
||||
|
||||
class DeleteFileEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DeleteFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile);
|
||||
~DeleteFileEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
};
|
||||
|
||||
class ReadFileEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ReadFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile);
|
||||
~ReadFileEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
nsCString mMimeType;
|
||||
};
|
||||
|
||||
class EnumerateFileEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
EnumerateFileEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile, PRUint32 aSince);
|
||||
~EnumerateFileEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
PRUint32 mSince;
|
||||
};
|
||||
|
||||
class PostPathResultEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
PostPathResultEvent(DeviceStorageRequestParent* aParent, const nsAString& aPath);
|
||||
~PostPathResultEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
DeviceStorageRequestParent* mParent;
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
InfallibleTArray<PRUint8> mBits;
|
||||
nsString mPath;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace devicestorage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -17,8 +17,17 @@ FORCE_STATIC_LIB = 1
|
|||
|
||||
include $(topsrcdir)/dom/dom-config.mk
|
||||
|
||||
EXPORTS_NAMESPACES = mozilla/dom/devicestorage
|
||||
|
||||
EXPORTS_mozilla/dom/devicestorage = \
|
||||
DeviceStorageRequestChild.h \
|
||||
DeviceStorageRequestParent.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceStorage.cpp \
|
||||
DeviceStorageRequestParent.cpp \
|
||||
DeviceStorageRequestChild.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
@ -32,7 +41,7 @@ LOCAL_INCLUDES = \
|
|||
-I$(topsrcdir)/content/events/src \
|
||||
$(NULL)
|
||||
|
||||
TEST_DIRS += test
|
||||
TEST_DIRS += test ipc
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C++; tab-width: 8; 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 protocol PContent;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace devicestorage {
|
||||
|
||||
|
||||
struct ErrorResponse
|
||||
{
|
||||
nsString error;
|
||||
};
|
||||
|
||||
struct SuccessResponse
|
||||
{
|
||||
};
|
||||
|
||||
struct BlobResponse
|
||||
{
|
||||
// todo going away
|
||||
PRUint8[] bits;
|
||||
nsCString contentType;
|
||||
};
|
||||
|
||||
struct DeviceStorageFileValue
|
||||
{
|
||||
// todo going away
|
||||
nsString fullpath;
|
||||
nsString path;
|
||||
};
|
||||
|
||||
struct EnumerationResponse
|
||||
{
|
||||
DeviceStorageFileValue[] paths;
|
||||
// todo bent PBlob
|
||||
};
|
||||
|
||||
union DeviceStorageResponseValue
|
||||
{
|
||||
ErrorResponse;
|
||||
SuccessResponse;
|
||||
BlobResponse;
|
||||
EnumerationResponse;
|
||||
};
|
||||
|
||||
sync protocol PDeviceStorageRequest {
|
||||
manager PContent;
|
||||
child:
|
||||
__delete__(DeviceStorageResponseValue response);
|
||||
};
|
||||
|
||||
} // namespace devicestorage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,26 @@
|
|||
# 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/.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = dom/devicestorage/ipc
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
|
||||
TEST_FILES = \
|
||||
test_ipc.html \
|
||||
../test/devicestorage_common.js \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
libs:: $(TEST_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") \
|
||||
$(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)\
|
|
@ -0,0 +1,160 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for OOP DeviceStorage</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.7">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function iframeScriptFirst() {
|
||||
content.wrappedJSObject.RunSet.reloadAndRunAll({
|
||||
preventDefault: function() { }
|
||||
});
|
||||
}
|
||||
|
||||
function iframeScriptSecond() {
|
||||
let TestRunner = content.wrappedJSObject.TestRunner;
|
||||
|
||||
let oldComplete = TestRunner.onComplete;
|
||||
|
||||
TestRunner.onComplete = function() {
|
||||
TestRunner.onComplete = oldComplete;
|
||||
|
||||
sendAsyncMessage("test:DeviceStorage:ipcTestComplete", {
|
||||
result: JSON.stringify(TestRunner._failedTests)
|
||||
});
|
||||
|
||||
if (oldComplete) {
|
||||
oldComplete();
|
||||
}
|
||||
};
|
||||
|
||||
let oldLog = TestRunner.log;
|
||||
TestRunner.log = function(msg) {
|
||||
sendAsyncMessage("test:DeviceStorage:ipcTestMessage", { msg: msg });
|
||||
}
|
||||
}
|
||||
|
||||
let regex = /^(TEST-PASS|TEST-UNEXPECTED-PASS|TEST-KNOWN-FAIL|TEST-UNEXPECTED-FAIL|TEST-DEBUG-INFO) \| ([^\|]+) \|(.*)/;
|
||||
|
||||
function onTestMessage(data) {
|
||||
let message = data.json.msg;
|
||||
let match = regex.exec(message);
|
||||
if (match) {
|
||||
let state = match[1];
|
||||
let details = match[2] + " | " + match[3];
|
||||
|
||||
switch (state) {
|
||||
case "TEST-PASS":
|
||||
case "TEST-KNOWN-FAIL":
|
||||
ok(true, details);
|
||||
break;
|
||||
|
||||
case "TEST-UNEXPECTED-FAIL":
|
||||
case "TEST-UNEXPECTED-PASS":
|
||||
ok(false, details);
|
||||
break;
|
||||
|
||||
case "TEST-DEBUG-INFO":
|
||||
default:
|
||||
info(details);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onTestComplete() {
|
||||
let comp = SpecialPowers.wrap(Components);
|
||||
SimpleTest.executeSoon(function () { SimpleTest.finish(); });
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
let iframe = document.createElement("iframe");
|
||||
iframe.mozbrowser = true;
|
||||
iframe.id = "iframe";
|
||||
iframe.style.width = "100%";
|
||||
iframe.style.height = "1000px";
|
||||
|
||||
function iframeLoadSecond() {
|
||||
ok(true, "Got second iframe load event.");
|
||||
iframe.removeEventListener("mozbrowserloadend", iframeLoadSecond);
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.loadFrameScript("data:,(" + iframeScriptSecond.toString() + ")();",
|
||||
false);
|
||||
}
|
||||
|
||||
function iframeLoadFirst() {
|
||||
ok(true, "Got first iframe load event.");
|
||||
iframe.removeEventListener("mozbrowserloadend", iframeLoadFirst);
|
||||
iframe.addEventListener("mozbrowserloadend", iframeLoadSecond);
|
||||
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
|
||||
let comp = SpecialPowers.wrap(Components);
|
||||
|
||||
let spObserver =
|
||||
comp.classes["@mozilla.org/special-powers-observer;1"]
|
||||
.getService(comp.interfaces.nsIFrameMessageListener);
|
||||
|
||||
mm.addMessageListener("SPPrefService", spObserver);
|
||||
mm.addMessageListener("SPProcessCrashService", spObserver);
|
||||
mm.addMessageListener("SPPingService", spObserver);
|
||||
mm.addMessageListener("SpecialPowers.Quit", spObserver);
|
||||
mm.addMessageListener("SPPermissionManager", spObserver);
|
||||
|
||||
mm.addMessageListener("test:DeviceStorage:ipcTestMessage", onTestMessage);
|
||||
mm.addMessageListener("test:DeviceStorage:ipcTestComplete", onTestComplete);
|
||||
|
||||
let specialPowersBase = "chrome://specialpowers/content/";
|
||||
mm.loadFrameScript(specialPowersBase + "MozillaLogger.js", false);
|
||||
mm.loadFrameScript(specialPowersBase + "specialpowersAPI.js", false);
|
||||
mm.loadFrameScript(specialPowersBase + "specialpowers.js", false);
|
||||
|
||||
mm.loadFrameScript("data:,(" + iframeScriptFirst.toString() + ")();", false);
|
||||
}
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", iframeLoadFirst);
|
||||
|
||||
// Strip this filename and one directory level and then add "/test".
|
||||
let href = window.location.href;
|
||||
href = href.substring(0, href.lastIndexOf('/'));
|
||||
href = href.substring(0, href.lastIndexOf('/'));
|
||||
iframe.src = href + "/test?consoleLevel=INFO";
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
addEventListener("load", function() {
|
||||
let whitelist;
|
||||
try {
|
||||
whitelist =
|
||||
SpecialPowers.getCharPref("dom.mozBrowserFramesWhitelist") + ", ";
|
||||
} catch (e) {
|
||||
whitelist = "";
|
||||
}
|
||||
|
||||
whitelist += window.location.protocol + "//" + window.location.host;
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
|
||||
["device.storage.enabled", true],
|
||||
["device.storage.testing", true],
|
||||
["device.storage.prompt.testing", true],
|
||||
|
||||
["dom.ipc.browser_frames.oop_by_default", true],
|
||||
["dom.mozBrowserFramesEnabled", true],
|
||||
["browser.pageThumbs.enabled", false],
|
||||
["dom.mozBrowserFramesWhitelist", whitelist]
|
||||
]
|
||||
}, runTests);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,7 @@
|
|||
# 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/.
|
||||
|
||||
IPDLSRCS = \
|
||||
PDeviceStorageRequest.ipdl \
|
||||
$(NULL)
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -7,19 +7,64 @@
|
|||
|
||||
class nsPIDOMWindow;
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h"
|
||||
|
||||
|
||||
#include "DOMRequest.h"
|
||||
#include "PCOMContentPermissionRequestChild.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/PContentPermissionRequestChild.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIContentPermissionPrompt.h"
|
||||
#include "nsIDOMDeviceStorage.h"
|
||||
#include "nsIDOMDeviceStorageCursor.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
|
||||
#define POST_ERROR_EVENT_FILE_DOES_NOT_EXIST "File location doesn't exists"
|
||||
#define POST_ERROR_EVENT_FILE_NOT_ENUMERABLE "File location is not enumerable"
|
||||
#define POST_ERROR_EVENT_PERMISSION_DENIED "Permission Denied"
|
||||
#define POST_ERROR_EVENT_ILLEGAL_FILE_NAME "Illegal file name"
|
||||
#define POST_ERROR_EVENT_UNKNOWN "Unknown"
|
||||
#define POST_ERROR_EVENT_NON_STRING_TYPE_UNSUPPORTED "Non-string type unsupported"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
class DeviceStorageFile MOZ_FINAL : public nsISupports {
|
||||
public:
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
nsString mPath;
|
||||
bool mEditable;
|
||||
|
||||
DeviceStorageFile(nsIFile* aFile, const nsAString& aPath);
|
||||
DeviceStorageFile(nsIFile* aFile);
|
||||
void SetPath(const nsAString& aPath);
|
||||
void SetEditable(bool aEditable);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// 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();
|
||||
|
||||
nsresult Write(nsIDOMBlob* blob);
|
||||
nsresult Write(InfallibleTArray<PRUint8>& bits);
|
||||
void CollectFiles(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles, PRUint64 aSince = 0);
|
||||
void collectFilesInternal(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles, PRUint64 aSince, nsAString& aRootPath);
|
||||
|
||||
private:
|
||||
void NormalizeFilePath();
|
||||
void AppendRelativePath();
|
||||
};
|
||||
|
||||
class nsDOMDeviceStorage MOZ_FINAL : public nsIDOMDeviceStorage
|
||||
{
|
||||
|
@ -38,7 +83,6 @@ public:
|
|||
private:
|
||||
~nsDOMDeviceStorage();
|
||||
|
||||
|
||||
nsresult GetInternal(const JS::Value & aName, JSContext* aCx, nsIDOMDOMRequest * *_retval NS_OUTPARAM, bool aEditable);
|
||||
|
||||
nsresult EnumerateInternal(const JS::Value & aName, const JS::Value & aOptions, JSContext* aCx, PRUint8 aArgc, bool aEditable, nsIDOMDeviceStorageCursor** aRetval);
|
||||
|
@ -57,4 +101,52 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
class ContinueCursorEvent MOZ_FINAL: public nsRunnable
|
||||
{
|
||||
public:
|
||||
ContinueCursorEvent(nsRefPtr<DOMRequest>& aRequest);
|
||||
ContinueCursorEvent(DOMRequest* aRequest);
|
||||
~ContinueCursorEvent();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
nsRefPtr<DOMRequest> mRequest;
|
||||
};
|
||||
|
||||
class nsDOMDeviceStorageCursor MOZ_FINAL
|
||||
: public nsIDOMDeviceStorageCursor
|
||||
, public DOMRequest
|
||||
, public nsIContentPermissionRequest
|
||||
, public PCOMContentPermissionRequestChild
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSICONTENTPERMISSIONREQUEST
|
||||
NS_DECL_NSIDOMDEVICESTORAGECURSOR
|
||||
|
||||
nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
|
||||
nsIURI* aURI,
|
||||
DeviceStorageFile* aFile,
|
||||
PRUint64 aSince);
|
||||
|
||||
|
||||
nsTArray<nsRefPtr<DeviceStorageFile> > mFiles;
|
||||
bool mOkToCallContinue;
|
||||
PRUint64 mSince;
|
||||
|
||||
virtual bool Recv__delete__(const bool& allow);
|
||||
virtual void IPDLRelease();
|
||||
|
||||
private:
|
||||
~nsDOMDeviceStorageCursor();
|
||||
|
||||
nsRefPtr<DeviceStorageFile> mFile;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
};
|
||||
|
||||
//helpers
|
||||
jsval StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString);
|
||||
jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile, bool aEditable);
|
||||
jsval BlobToJsval(nsPIDOMWindow* aWindow, nsIDOMBlob* aBlob);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,7 @@ function deleteError(e) {
|
|||
|
||||
function addOverwritingSuccess(e) {
|
||||
ok(false, "addOverwritingSuccess was called.");
|
||||
devicestorage_cleanup();
|
||||
}
|
||||
|
||||
function addOverwritingError(e) {
|
||||
|
|
|
@ -79,12 +79,14 @@
|
|||
#endif
|
||||
|
||||
#include "mozilla/dom/sms/SmsChild.h"
|
||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
||||
|
||||
using namespace mozilla::hal_sandbox;
|
||||
using namespace mozilla::ipc;
|
||||
using namespace mozilla::net;
|
||||
using namespace mozilla::places;
|
||||
using namespace mozilla::docshell;
|
||||
using namespace mozilla::dom::devicestorage;
|
||||
using namespace mozilla::dom::sms;
|
||||
using namespace mozilla::dom::indexedDB;
|
||||
|
||||
|
@ -486,6 +488,19 @@ ContentChild::DeallocPAudio(PAudioChild* doomed)
|
|||
return true;
|
||||
}
|
||||
|
||||
PDeviceStorageRequestChild*
|
||||
ContentChild::AllocPDeviceStorageRequest(const DeviceStorageParams& aParams)
|
||||
{
|
||||
return new DeviceStorageRequestChild();
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::DeallocPDeviceStorageRequest(PDeviceStorageRequestChild* aDeviceStorage)
|
||||
{
|
||||
delete aDeviceStorage;
|
||||
return true;
|
||||
}
|
||||
|
||||
PNeckoChild*
|
||||
ContentChild::AllocPNecko()
|
||||
{
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
const bool& aIsBrowserFrame);
|
||||
virtual bool DeallocPBrowser(PBrowserChild*);
|
||||
|
||||
virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
||||
virtual bool DeallocPDeviceStorageRequest(PDeviceStorageRequestChild*);
|
||||
|
||||
virtual PCrashReporterChild*
|
||||
AllocPCrashReporter(const mozilla::dom::NativeThreadId& id,
|
||||
const PRUint32& processType);
|
||||
|
|
|
@ -76,8 +76,13 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/dom/sms/SmsParent.h"
|
||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
|
||||
#include "nsDebugImpl.h"
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "IDBFactory.h"
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "IndexedDBParent.h"
|
||||
|
@ -92,6 +97,7 @@ using namespace mozilla::net;
|
|||
using namespace mozilla::places;
|
||||
using mozilla::unused; // heh
|
||||
using base::KillProcess;
|
||||
using namespace mozilla::dom::devicestorage;
|
||||
using namespace mozilla::dom::sms;
|
||||
using namespace mozilla::dom::indexedDB;
|
||||
|
||||
|
@ -775,6 +781,19 @@ ContentParent::DeallocPBrowser(PBrowserParent* frame)
|
|||
return true;
|
||||
}
|
||||
|
||||
PDeviceStorageRequestParent*
|
||||
ContentParent::AllocPDeviceStorageRequest(const DeviceStorageParams& aParams)
|
||||
{
|
||||
return new DeviceStorageRequestParent(aParams);
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::DeallocPDeviceStorageRequest(PDeviceStorageRequestParent* doomed)
|
||||
{
|
||||
delete doomed;
|
||||
return true;
|
||||
}
|
||||
|
||||
PCrashReporterParent*
|
||||
ContentParent::AllocPCrashReporter(const NativeThreadId& tid,
|
||||
const PRUint32& processType)
|
||||
|
|
|
@ -110,6 +110,9 @@ private:
|
|||
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame);
|
||||
virtual bool DeallocPBrowser(PBrowserParent* frame);
|
||||
|
||||
virtual PDeviceStorageRequestParent* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
||||
virtual bool DeallocPDeviceStorageRequest(PDeviceStorageRequestParent*);
|
||||
|
||||
virtual PCrashReporterParent* AllocPCrashReporter(const NativeThreadId& tid,
|
||||
const PRUint32& processType);
|
||||
virtual bool DeallocPCrashReporter(PCrashReporterParent* crashreporter);
|
||||
|
|
|
@ -77,6 +77,7 @@ LOCAL_INCLUDES += \
|
|||
-I$(topsrcdir)/toolkit/xre \
|
||||
-I$(topsrcdir)/hal/sandbox \
|
||||
-I$(topsrcdir)/dom/sms/src/ipc \
|
||||
-I$(topsrcdir)/dom/devicestorage \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -DBIN_SUFFIX='"$(BIN_SUFFIX)"'
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
include protocol PAudio;
|
||||
include protocol PBrowser;
|
||||
include protocol PCrashReporter;
|
||||
include protocol PDeviceStorageRequest;
|
||||
include protocol PExternalHelperApp;
|
||||
include protocol PHal;
|
||||
include protocol PIndexedDB;
|
||||
|
@ -65,6 +66,36 @@ struct FontListEntry {
|
|||
PRUint8 index;
|
||||
};
|
||||
|
||||
struct DeviceStorageAddParams
|
||||
{
|
||||
nsString fullpath;
|
||||
PRUint8[] bits;
|
||||
};
|
||||
|
||||
struct DeviceStorageGetParams
|
||||
{
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageDeleteParams
|
||||
{
|
||||
nsString fullpath;
|
||||
};
|
||||
|
||||
struct DeviceStorageEnumerationParams
|
||||
{
|
||||
nsString fullpath;
|
||||
PRUint32 since;
|
||||
};
|
||||
|
||||
union DeviceStorageParams
|
||||
{
|
||||
DeviceStorageAddParams;
|
||||
DeviceStorageGetParams;
|
||||
DeviceStorageDeleteParams;
|
||||
DeviceStorageEnumerationParams;
|
||||
};
|
||||
|
||||
rpc protocol PContent
|
||||
{
|
||||
manages PAudio;
|
||||
|
@ -132,6 +163,8 @@ child:
|
|||
parent:
|
||||
PAudio(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat);
|
||||
|
||||
PDeviceStorageRequest(DeviceStorageParams params);
|
||||
|
||||
sync PCrashReporter(NativeThreadId tid, PRUint32 processType);
|
||||
|
||||
PHal();
|
||||
|
|
|
@ -23,6 +23,7 @@ EXPORT_LIBRARY = 1
|
|||
##
|
||||
IPDLDIRS = \
|
||||
uriloader/exthandler \
|
||||
dom/devicestorage \
|
||||
dom/indexedDB/ipc \
|
||||
dom/plugins/ipc \
|
||||
dom/ipc \
|
||||
|
|
Загрузка…
Ссылка в новой задаче