gecko/dom/devicestorage/nsDeviceStorage.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

140 lines
4.0 KiB
C++

/* 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 nsDeviceStorage_h
#define nsDeviceStorage_h
class nsPIDOMWindow;
#include "PCOMContentPermissionRequestChild.h"
#include "DOMRequest.h"
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsDOMClassInfoID.h"
#include "nsIClassInfo.h"
#include "nsIContentPermissionPrompt.h"
#include "nsIDOMDeviceStorageCursor.h"
#include "nsIDOMDeviceStorageStat.h"
#include "nsIDOMWindow.h"
#include "nsIURI.h"
#include "nsInterfaceHashtable.h"
#include "nsIPrincipal.h"
#include "nsString.h"
#include "nsWeakPtr.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIObserver.h"
#include "mozilla/Mutex.h"
#include "DeviceStorage.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"
#define POST_ERROR_EVENT_NOT_IMPLEMENTED "Not implemented"
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 Remove();
nsresult Write(nsIInputStream* aInputStream);
nsresult Write(InfallibleTArray<uint8_t>& bits);
void CollectFiles(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles, uint64_t aSince = 0);
void collectFilesInternal(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles, uint64_t aSince, nsAString& aRootPath);
static uint64_t DirectoryDiskUsage(nsIFile* aFile, uint64_t aSoFar = 0);
private:
void NormalizeFilePath();
void AppendRelativePath();
};
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,
nsIPrincipal* aPrincipal,
DeviceStorageFile* aFile,
uint64_t aSince);
nsTArray<nsRefPtr<DeviceStorageFile> > mFiles;
bool mOkToCallContinue;
uint64_t mSince;
virtual bool Recv__delete__(const bool& allow);
virtual void IPDLRelease();
private:
~nsDOMDeviceStorageCursor();
nsRefPtr<DeviceStorageFile> mFile;
nsCOMPtr<nsIPrincipal> mPrincipal;
};
class nsDOMDeviceStorageStat MOZ_FINAL
: public nsIDOMDeviceStorageStat
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMDEVICESTORAGESTAT
nsDOMDeviceStorageStat(uint64_t aFreeBytes, uint64_t aTotalBytes, nsAString& aState);
private:
~nsDOMDeviceStorageStat();
uint64_t mFreeBytes, mTotalBytes;
nsString mState;
};
//helpers
jsval StringToJsval(nsPIDOMWindow* aWindow, nsAString& aString);
jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile);
jsval InterfaceToJsval(nsPIDOMWindow* aWindow, nsISupports* aObject, const nsIID* aIID);
#ifdef MOZ_WIDGET_GONK
nsresult GetSDCardStatus(nsAString& aState);
#endif
#endif