Bug 1299500 - Get rid of DeviceStorage API - part 2 - DeviceStorageChangeEvent, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 08 Mar 2017 20:15:44 +0100
changeset 346610 41cbf92cfad2d34768272a5a4dedf9758d92a5a4
parent 346609 92606f748fcb41826443bf226c824929b5c39100
child 346611 07ed303b1e3ee01e9c1850ff2d1a2c11f1ba1e21
push id31472
push userkwierso@gmail.com
push dateThu, 09 Mar 2017 01:08:10 +0000
treeherdermozilla-central@19289cc8bf6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1299500
milestone55.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
Bug 1299500 - Get rid of DeviceStorage API - part 2 - DeviceStorageChangeEvent, r=ehsan
dom/devicestorage/nsDeviceStorage.cpp
dom/events/test/test_all_synthetic_events.html
dom/tests/mochitest/general/test_interfaces.js
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/FileBlobImpl.h"
 #include "mozilla/dom/FileSystemUtils.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/dom/PBrowserChild.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
@@ -3537,86 +3536,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);
@@ -3681,30 +3632,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,
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -281,18 +281,16 @@ var interfaceNamesInGlobalScope =
     "DeviceOrientationEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DeviceProximityEvent",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     { name: "DeviceStorageAreaListener", desktop: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     { name: "DeviceStorage", desktop: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    { name: "DeviceStorageChangeEvent", desktop: false},
-// IMPORTANT: Do not change this list without review from a DOM peer!
     "Directory",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Document",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DocumentFragment",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DocumentTimeline", release: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
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
@@ -1017,17 +1017,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',
@@ -1063,17 +1062,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',