зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299500 - Get rid of DeviceStorage API - part 4 - Navigator, r=ehsan
This commit is contained in:
Родитель
364dd3bee4
Коммит
6736ff0657
|
@ -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<nsDOMDeviceStorage> 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<nsDOMDeviceStorage>
|
||||
Navigator::FindDeviceStorage(const nsAString& aName, const nsAString& aType)
|
||||
{
|
||||
auto i = mDeviceStorageStores.Length();
|
||||
while (i > 0) {
|
||||
--i;
|
||||
RefPtr<nsDOMDeviceStorage> storage =
|
||||
do_QueryReferent(mDeviceStorageStores[i]);
|
||||
if (storage) {
|
||||
if (storage->Equals(mWindow, aName, aType)) {
|
||||
return storage.forget();
|
||||
}
|
||||
} else {
|
||||
mDeviceStorageStores.RemoveElementAt(i);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsDOMDeviceStorage>
|
||||
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<nsDOMDeviceStorage> 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<DOMEventTargetHelper*>(storage)));
|
||||
return storage.forget();
|
||||
}
|
||||
|
||||
void
|
||||
Navigator::GetDeviceStorages(const nsAString& aType,
|
||||
nsTArray<RefPtr<nsDOMDeviceStorage> >& 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<nsDOMDeviceStorage> 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<nsDOMDeviceStorage> storage =
|
||||
GetDeviceStorageByNameAndType(volumes[i], aType, aRv);
|
||||
if (aRv.Failed()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (storage) {
|
||||
aStores.AppendElement(storage.forget());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsDOMDeviceStorage>
|
||||
Navigator::GetDeviceStorageByNameAndType(const nsAString& aName,
|
||||
const nsAString& aType,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!mWindow || !mWindow->GetOuterWindow() || !mWindow->GetDocShell()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<nsDOMDeviceStorage> 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<DOMEventTargetHelper*>(storage)));
|
||||
return storage.forget();
|
||||
}
|
||||
|
||||
Geolocation*
|
||||
Navigator::GetGeolocation(ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -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<WakeLock> RequestWakeLock(const nsAString &aTopic,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsDOMDeviceStorage> GetDeviceStorage(const nsAString& aType,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void GetDeviceStorages(const nsAString& aType,
|
||||
nsTArray<RefPtr<nsDOMDeviceStorage> >& aStores,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<nsDOMDeviceStorage>
|
||||
GetDeviceStorageByNameAndType(const nsAString& aName, const nsAString& aType,
|
||||
ErrorResult& aRv);
|
||||
|
||||
DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
|
||||
already_AddRefed<LegacyMozTCPSocket> 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<nsDOMDeviceStorage> 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<system::AudioChannelManager> mAudioChannelManager;
|
||||
#endif
|
||||
RefPtr<MediaDevices> mMediaDevices;
|
||||
nsTArray<nsWeakPtr> mDeviceStorageStores;
|
||||
RefPtr<time::TimeManager> mTimeManager;
|
||||
RefPtr<ServiceWorkerContainer> mServiceWorkerContainer;
|
||||
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
||||
|
|
|
@ -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<DeviceStorage> getDeviceStorages(DOMString type);
|
||||
[Throws, Pref="device.storage.enabled"]
|
||||
DeviceStorage? getDeviceStorageByNameAndType(DOMString name, DOMString type);
|
||||
};
|
||||
|
||||
// nsIDOMNavigatorDesktopNotification
|
||||
partial interface Navigator {
|
||||
[Throws, Pref="notification.feature.enabled", UnsafeInPrerendering]
|
||||
|
|
Загрузка…
Ссылка в новой задаче