author | Gabriele Svelto <gsvelto@mozilla.com> |
Wed, 16 Sep 2015 22:29:56 +0200 | |
changeset 263391 | ffd40920af0c9020488448939e550637c563b5ed |
parent 263390 | 88bfad4990d8a7908fd8162e7480f50b3ce54b5b |
child 263392 | a29828c4d7be167a1334d9de4309057e462edb56 |
push id | 65295 |
push user | archaeopteryx@coole-files.de |
push date | Sat, 19 Sep 2015 09:20:06 +0000 |
treeherder | mozilla-inbound@11c096c410a7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dhylands, bzbarsky |
bugs | 1204618 |
milestone | 43.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/devicestorage/DeviceStorage.h +++ b/dom/devicestorage/DeviceStorage.h @@ -244,16 +244,17 @@ public: already_AddRefed<DOMRequest> CreateFileDescriptor(const nsAString& aPath, DeviceStorageFileDescriptor* aDSFD, ErrorResult& aRv); bool CanBeMounted(); bool CanBeFormatted(); bool CanBeShared(); bool IsRemovable(); + bool LowDiskSpace(); bool Default(); void GetStorageName(nsAString& aStorageName); already_AddRefed<Promise> GetRoot(ErrorResult& aRv); static void CreateDeviceStorageFor(nsPIDOMWindow* aWin,
--- a/dom/devicestorage/DeviceStorageStatics.cpp +++ b/dom/devicestorage/DeviceStorageStatics.cpp @@ -67,16 +67,17 @@ DeviceStorageStatics::InitializeDirs() } MOZ_ASSERT(sInstance->mInitialized); } DeviceStorageStatics::DeviceStorageStatics() : mInitialized(false) , mPromptTesting(false) + , mLowDiskSpace(false) { DS_LOG_INFO(""); } DeviceStorageStatics::~DeviceStorageStatics() { DS_LOG_INFO(""); } @@ -353,16 +354,26 @@ DeviceStorageStatics::IsPromptTesting() { StaticMutexAutoLock lock(sMutex); if (NS_WARN_IF(!sInstance)) { return false; } return sInstance->mPromptTesting; } +/* static */ bool +DeviceStorageStatics::LowDiskSpace() +{ + StaticMutexAutoLock lock(sMutex); + if (NS_WARN_IF(!sInstance)) { + return false; + } + return sInstance->mLowDiskSpace; +} + /* static */ void DeviceStorageStatics::GetWritableName(nsString& aName) { StaticMutexAutoLock lock(sMutex); if (NS_WARN_IF(!sInstance)) { aName.Truncate(); return; } @@ -600,37 +611,39 @@ DeviceStorageStatics::Observe(nsISupport while (i > 0) { --i; mListeners[i]->OnFileWatcherUpdate(data, file); } return NS_OK; } if (!strcmp(aTopic, kDiskSpaceWatcher)) { - // 'disk-space-watcher' notifications are sent when there is a modification - // of a file in a specific location while a low device storage situation - // exists or after recovery of a low storage situation. For Firefox OS, - // these notifications are specific for apps storage. - bool lowDiskSpace = false; - if (!NS_strcmp(aData, MOZ_UTF16("full"))) { - lowDiskSpace = true; - } else if (NS_strcmp(aData, MOZ_UTF16("free"))) { - return NS_OK; - } - StaticMutexAutoLock lock(sMutex); if (NS_WARN_IF(!sInstance)) { return NS_OK; } + // 'disk-space-watcher' notifications are sent when there is a modification + // of a file in a specific location while a low device storage situation + // exists or after recovery of a low storage situation. For Firefox OS, + // these notifications are specific for apps storage. + if (!NS_strcmp(aData, MOZ_UTF16("full"))) { + sInstance->mLowDiskSpace = true; + } else if (!NS_strcmp(aData, MOZ_UTF16("free"))) { + sInstance->mLowDiskSpace = false; + } else { + return NS_OK; + } + + uint32_t i = mListeners.Length(); - DS_LOG_INFO("disk space %d (%u)", lowDiskSpace, i); + DS_LOG_INFO("disk space %d (%u)", sInstance->mLowDiskSpace, i); while (i > 0) { --i; - mListeners[i]->OnDiskSpaceWatcher(lowDiskSpace); + mListeners[i]->OnDiskSpaceWatcher(sInstance->mLowDiskSpace); } return NS_OK; } if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) { StaticMutexAutoLock lock(sMutex); if (NS_WARN_IF(!sInstance)) { return NS_OK;
--- a/dom/devicestorage/DeviceStorageStatics.h +++ b/dom/devicestorage/DeviceStorageStatics.h @@ -25,16 +25,17 @@ public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER static void Initialize(); static void InitializeDirs(); static void AddListener(nsDOMDeviceStorage* aListener); static void RemoveListener(nsDOMDeviceStorage* aListener); + static bool LowDiskSpace(); static bool IsPromptTesting(); static void GetWritableName(nsString& aName); static void SetWritableName(const nsAString& aName); static bool HasOverrideRootDir(); static already_AddRefed<nsIFile> GetAppsDir(); static already_AddRefed<nsIFile> GetCrashesDir(); static already_AddRefed<nsIFile> GetPicturesDir(); @@ -87,16 +88,17 @@ private: nsCOMPtr<nsIThread> mOwningThread; }; nsTArray<nsRefPtr<ListenerWrapper> > mListeners; nsCOMPtr<nsIFile> mDirs[TYPE_COUNT]; bool mInitialized; bool mPromptTesting; + bool mLowDiskSpace; nsString mWritableName; static StaticRefPtr<DeviceStorageStatics> sInstance; static StaticMutex sMutex; }; } // namespace devicestorage } // namespace dom
--- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -3369,16 +3369,22 @@ nsDOMDeviceStorage::CanBeShared() } bool nsDOMDeviceStorage::IsRemovable() { return mIsRemovable; } +bool +nsDOMDeviceStorage::LowDiskSpace() +{ + return DeviceStorageStatics::LowDiskSpace(); +} + already_AddRefed<Promise> nsDOMDeviceStorage::GetRoot(ErrorResult& aRv) { if (!mFileSystem) { mFileSystem = new DeviceStorageFileSystem(mStorageType, mStorageName); mFileSystem->Init(this); } return mozilla::dom::Directory::GetRoot(mFileSystem, aRv);
--- a/dom/webidl/DeviceStorage.webidl +++ b/dom/webidl/DeviceStorage.webidl @@ -81,12 +81,15 @@ interface DeviceStorage : EventTarget { // Determines if this storage area is the one which will be used by default // for storing new files. readonly attribute boolean default; // Indicates if the storage area denoted by storageName is removable readonly attribute boolean isRemovable; + // True if the storage area is close to being full + readonly attribute boolean lowDiskSpace; + [NewObject] // XXXbz what type does this really return? Promise<any> getRoot(); };