From 6736ff0657c66fce72d52c2e62072b4bd79350d7 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 8 Mar 2017 20:15:44 +0100 Subject: [PATCH] Bug 1299500 - Get rid of DeviceStorage API - part 4 - Navigator, r=ehsan --- dom/base/Navigator.cpp | 116 ------------------------------------ dom/base/Navigator.h | 16 ----- dom/webidl/Navigator.webidl | 10 ---- 3 files changed, 142 deletions(-) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 81deb30d3f54..4d75aa161c13 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -67,7 +67,6 @@ #include "nsIHttpChannel.h" #include "nsIHttpChannelInternal.h" #include "TimeManager.h" -#include "DeviceStorage.h" #include "nsStreamUtils.h" #include "WidgetUtils.h" #include "nsIPresentationService.h" @@ -279,15 +278,6 @@ Navigator::Invalidate() } #endif - uint32_t len = mDeviceStorageStores.Length(); - for (uint32_t i = 0; i < len; ++i) { - RefPtr ds = do_QueryReferent(mDeviceStorageStores[i]); - if (ds) { - ds->Shutdown(); - } - } - mDeviceStorageStores.Clear(); - if (mTimeManager) { mTimeManager = nullptr; } @@ -1032,112 +1022,6 @@ Navigator::RegisterProtocolHandler(const nsAString& aProtocol, mWindow->GetOuterWindow()); } -already_AddRefed -Navigator::FindDeviceStorage(const nsAString& aName, const nsAString& aType) -{ - auto i = mDeviceStorageStores.Length(); - while (i > 0) { - --i; - RefPtr storage = - do_QueryReferent(mDeviceStorageStores[i]); - if (storage) { - if (storage->Equals(mWindow, aName, aType)) { - return storage.forget(); - } - } else { - mDeviceStorageStores.RemoveElementAt(i); - } - } - return nullptr; -} - -already_AddRefed -Navigator::GetDeviceStorage(const nsAString& aType, ErrorResult& aRv) -{ - if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { - aRv.Throw(NS_ERROR_FAILURE); - return nullptr; - } - - nsString name; - nsDOMDeviceStorage::GetDefaultStorageName(aType, name); - RefPtr storage = FindDeviceStorage(name, aType); - if (storage) { - return storage.forget(); - } - - nsDOMDeviceStorage::CreateDeviceStorageFor(mWindow, aType, - getter_AddRefs(storage)); - - if (!storage) { - return nullptr; - } - - mDeviceStorageStores.AppendElement( - do_GetWeakReference(static_cast(storage))); - return storage.forget(); -} - -void -Navigator::GetDeviceStorages(const nsAString& aType, - nsTArray >& aStores, - ErrorResult& aRv) -{ - if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { - aRv.Throw(NS_ERROR_FAILURE); - return; - } - - nsDOMDeviceStorage::VolumeNameArray volumes; - nsDOMDeviceStorage::GetOrderedVolumeNames(aType, volumes); - if (volumes.IsEmpty()) { - RefPtr storage = GetDeviceStorage(aType, aRv); - if (storage) { - aStores.AppendElement(storage.forget()); - } - } else { - uint32_t len = volumes.Length(); - aStores.SetCapacity(len); - for (uint32_t i = 0; i < len; ++i) { - RefPtr storage = - GetDeviceStorageByNameAndType(volumes[i], aType, aRv); - if (aRv.Failed()) { - break; - } - - if (storage) { - aStores.AppendElement(storage.forget()); - } - } - } -} - -already_AddRefed -Navigator::GetDeviceStorageByNameAndType(const nsAString& aName, - const nsAString& aType, - ErrorResult& aRv) -{ - if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) { - aRv.Throw(NS_ERROR_FAILURE); - return nullptr; - } - - RefPtr storage = FindDeviceStorage(aName, aType); - if (storage) { - return storage.forget(); - } - nsDOMDeviceStorage::CreateDeviceStorageByNameAndType(mWindow, aName, aType, - getter_AddRefs(storage)); - - if (!storage) { - return nullptr; - } - - mDeviceStorageStores.AppendElement( - do_GetWeakReference(static_cast(storage))); - return storage.forget(); -} - Geolocation* Navigator::GetGeolocation(ErrorResult& aRv) { diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 2c8ab07eaee1..7200c57abe40 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -26,7 +26,6 @@ class nsPluginArray; class nsMimeTypeArray; class nsPIDOMWindowInner; class nsIDOMNavigatorSystemMessages; -class nsDOMDeviceStorage; class nsIPrincipal; class nsIURI; @@ -196,17 +195,6 @@ public: already_AddRefed RequestWakeLock(const nsAString &aTopic, ErrorResult& aRv); - already_AddRefed GetDeviceStorage(const nsAString& aType, - ErrorResult& aRv); - - void GetDeviceStorages(const nsAString& aType, - nsTArray >& aStores, - ErrorResult& aRv); - - already_AddRefed - GetDeviceStorageByNameAndType(const nsAString& aName, const nsAString& aType, - ErrorResult& aRv); - DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv); already_AddRefed MozTCPSocket(); network::Connection* GetConnection(ErrorResult& aRv); @@ -291,9 +279,6 @@ private: bool CheckPermission(const char* type); static bool CheckPermission(nsPIDOMWindowInner* aWindow, const char* aType); - already_AddRefed FindDeviceStorage(const nsAString& aName, - const nsAString& aType); - // This enum helps SendBeaconInternal to apply different behaviors to body // types. enum BeaconType { @@ -321,7 +306,6 @@ private: RefPtr mAudioChannelManager; #endif RefPtr mMediaDevices; - nsTArray mDeviceStorageStores; RefPtr mTimeManager; RefPtr mServiceWorkerContainer; nsCOMPtr mWindow; diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index f6e8559e4523..ac85c5ffb54a 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -245,16 +245,6 @@ partial interface Navigator { readonly attribute boolean cpuHasSSE2; }; -// nsIDOMNavigatorDeviceStorage -partial interface Navigator { - [Throws, Pref="device.storage.enabled"] - DeviceStorage? getDeviceStorage(DOMString type); - [Throws, Pref="device.storage.enabled"] - sequence getDeviceStorages(DOMString type); - [Throws, Pref="device.storage.enabled"] - DeviceStorage? getDeviceStorageByNameAndType(DOMString name, DOMString type); -}; - // nsIDOMNavigatorDesktopNotification partial interface Navigator { [Throws, Pref="notification.feature.enabled", UnsafeInPrerendering]