Bug 1299500 - Get rid of DeviceStorage API - part 2 - DeviceStorageChangeEvent, r=ehsan, a=lizzard
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Mar 2017 20:15:44 +0100
changeset 379240 71d55c22894809ad6f7efddea305dcfe38cd357d
parent 379239 188a791aec8b47c1ca529856833f0a6bf0752746
child 379241 c51eb9dcfded22debfaea75a848de2d5759ee232
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan, lizzard
bugs1299500
milestone53.0
Bug 1299500 - Get rid of DeviceStorage API - part 2 - DeviceStorageChangeEvent, r=ehsan, a=lizzard
dom/devicestorage/nsDeviceStorage.cpp
dom/events/test/test_all_synthetic_events.html
dom/webidl/DeviceStorageChangeEvent.webidl
dom/webidl/moz.build
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -6,17 +6,16 @@
 
 #include "nsDeviceStorage.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/DeviceStorageBinding.h"
-#include "mozilla/dom/DeviceStorageChangeEvent.h"
 #include "mozilla/dom/DeviceStorageFileSystem.h"
 #include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h"
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/FileSystemUtils.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/dom/PBrowserChild.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
 #include "mozilla/dom/Promise.h"
@@ -3535,86 +3534,38 @@ nsDOMDeviceStorage::EnumerateInternal(co
 }
 
 void
 nsDOMDeviceStorage::OnWritableNameChanged()
 {
   nsAdoptingString DefaultLocation;
   GetDefaultStorageName(mStorageType, DefaultLocation);
 
-  DeviceStorageChangeEventInit init;
-  init.mBubbles = true;
-  init.mCancelable = false;
-  init.mPath = DefaultLocation;
-
-  if (mIsDefaultLocation) {
-    init.mReason.AssignLiteral("default-location-changed");
-  } else {
-    init.mReason.AssignLiteral("became-default-location");
-  }
-
-  RefPtr<DeviceStorageChangeEvent> event =
-    DeviceStorageChangeEvent::Constructor(this,
-                                          NS_LITERAL_STRING(STORAGE_CHANGE_EVENT),
-                                          init);
-  event->SetTrusted(true);
-
-  bool ignore;
-  DispatchEvent(event, &ignore);
   mIsDefaultLocation = Default();
 }
 
 #ifdef MOZ_WIDGET_GONK
 void
 nsDOMDeviceStorage::DispatchStatusChangeEvent(nsAString& aStatus)
 {
   if (aStatus == mLastStatus) {
     // We've already sent this status, don't bother sending it again.
     return;
   }
   mLastStatus = aStatus;
-
-  DeviceStorageChangeEventInit init;
-  init.mBubbles = true;
-  init.mCancelable = false;
-  init.mPath = mStorageName;
-  init.mReason = aStatus;
-
-  RefPtr<DeviceStorageChangeEvent> event =
-    DeviceStorageChangeEvent::Constructor(this,
-                                          NS_LITERAL_STRING(STORAGE_CHANGE_EVENT),
-                                          init);
-  event->SetTrusted(true);
-
-  bool ignore;
-  DispatchEvent(event, &ignore);
 }
 
 void
 nsDOMDeviceStorage::DispatchStorageStatusChangeEvent(nsAString& aStorageStatus)
 {
   if (aStorageStatus == mLastStorageStatus) {
      // We've already sent this status, don't bother sending it again.
     return;
   }
   mLastStorageStatus = aStorageStatus;
-
-  DeviceStorageChangeEventInit init;
-  init.mBubbles = true;
-  init.mCancelable = false;
-  init.mPath = mStorageName;
-  init.mReason = aStorageStatus;
-
-  RefPtr<DeviceStorageChangeEvent> event =
-    DeviceStorageChangeEvent::Constructor(this, NS_LITERAL_STRING("storage-state-change"),
-                                          init);
-  event->SetTrusted(true);
-
-  bool ignore;
-  DispatchEvent(event, &ignore);
 }
 #endif
 
 void
 nsDOMDeviceStorage::OnFileWatcherUpdate(const nsCString& aData, DeviceStorageFile* aFile)
 {
   MOZ_ASSERT(IsOwningThread());
   Notify(aData.get(), aFile);
@@ -3679,30 +3630,16 @@ nsDOMDeviceStorage::Notify(const char* a
   }
 
   if (!mStorageType.Equals(aFile->mStorageType) ||
       !mStorageName.Equals(aFile->mStorageName)) {
     // Ignore this
     return NS_OK;
   }
 
-  DeviceStorageChangeEventInit init;
-  init.mBubbles = true;
-  init.mCancelable = false;
-  aFile->GetFullPath(init.mPath);
-  init.mReason.AssignWithConversion(aReason);
-
-  RefPtr<DeviceStorageChangeEvent> event =
-    DeviceStorageChangeEvent::Constructor(this,
-                                          NS_LITERAL_STRING(STORAGE_CHANGE_EVENT),
-                                          init);
-  event->SetTrusted(true);
-
-  bool ignore;
-  DispatchEvent(event, &ignore);
   return NS_OK;
 }
 
 void
 nsDOMDeviceStorage::EventListenerWasAdded(const nsAString& aType,
                                           ErrorResult& aRv,
                                           JSCompartment* aCompartment)
 {
--- a/dom/events/test/test_all_synthetic_events.html
+++ b/dom/events/test/test_all_synthetic_events.html
@@ -111,20 +111,16 @@ const kEventConstructors = {
   DeviceOrientationEvent:                    { create: function (aName, aProps) {
                                                          return new DeviceOrientationEvent(aName, aProps);
                                                        },
                                              },
   DeviceProximityEvent:                      { create: function (aName, aProps) {
                                                          return new DeviceProximityEvent(aName, aProps);
                                                        },
                                              },
-  DeviceStorageChangeEvent:                  { create: function (aName, aProps) {
-                                                         return new DeviceStorageChangeEvent(aName, aProps);
-                                                       },
-                                             },
   DownloadEvent:                             { create: function (aName, aProps) {
                                                          return new DownloadEvent(aName, aProps);
                                                        },
                                              },
   DragEvent:                                 { create: function (aName, aProps) {
                                                          var e = document.createEvent("dragevent");
                                                          e.initDragEvent(aName, aProps.bubbles, aProps.cancelable,
                                                                          aProps.view, aProps.detail,
deleted file mode 100644
--- a/dom/webidl/DeviceStorageChangeEvent.webidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- Mode: IDL; 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/.
- */
-
-[Constructor(DOMString type, optional DeviceStorageChangeEventInit eventInitDict),
- Pref="device.storage.enabled"]
-interface DeviceStorageChangeEvent : Event
-{
-  readonly attribute DOMString? path;
-  readonly attribute DOMString? reason;
-};
-
-dictionary DeviceStorageChangeEventInit : EventInit
-{
-  DOMString path = "";
-  DOMString reason = "";
-};
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -653,17 +653,16 @@ if CONFIG['MOZ_WEBSPEECH']:
         'SpeechSynthesisUtterance.webidl',
         'SpeechSynthesisVoice.webidl',
     ]
 
 WEBIDL_FILES += [
     'CloseEvent.webidl',
     'CustomEvent.webidl',
     'DeviceOrientationEvent.webidl',
-    'DeviceStorageChangeEvent.webidl',
     'HashChangeEvent.webidl',
     'PageTransitionEvent.webidl',
     'PopStateEvent.webidl',
     'PopupBlockedEvent.webidl',
     'ProgressEvent.webidl',
     'RecordErrorEvent.webidl',
     'StyleRuleChangeEvent.webidl',
     'StyleSheetApplicableStateChangeEvent.webidl',
@@ -694,17 +693,16 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'AnimationPlaybackEvent.webidl',
     'AutocompleteErrorEvent.webidl',
     'BlobEvent.webidl',
     'CaretStateChangedEvent.webidl',
     'CloseEvent.webidl',
     'DeviceLightEvent.webidl',
     'DeviceOrientationEvent.webidl',
     'DeviceProximityEvent.webidl',
-    'DeviceStorageChangeEvent.webidl',
     'ErrorEvent.webidl',
     'FontFaceSetLoadEvent.webidl',
     'GamepadAxisMoveEvent.webidl',
     'GamepadButtonEvent.webidl',
     'GamepadEvent.webidl',
     'GroupedHistoryEvent.webidl',
     'HashChangeEvent.webidl',
     'HiddenPluginEvent.webidl',