Bug 777078 - Remove DeviceStorage .type. r=sicking
authorDoug Turner <dougt@dougt.org>
Wed, 01 Aug 2012 23:32:08 -0700
changeset 101178 d628a6d43f6c00a9b0d5eae5bda4cbf4addce109
parent 101177 d1a6847f6df33ded82c2e70a3181c2308ac40672
child 101179 cb017d0510296e4f873855f4c9ab09129a64a578
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-esr52@fd72dbbd6920 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs777078
milestone17.0a1
Bug 777078 - Remove DeviceStorage .type. r=sicking
dom/devicestorage/DeviceStorage.h
dom/devicestorage/nsDeviceStorage.cpp
dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl
--- a/dom/devicestorage/DeviceStorage.h
+++ b/dom/devicestorage/DeviceStorage.h
@@ -25,17 +25,17 @@ public:
   NS_DECL_NSIDOMEVENTTARGET
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceStorage, nsDOMEventTargetHelper)
   NS_DECL_EVENT_HANDLER(change)
 
   nsDOMDeviceStorage();
 
   nsresult Init(nsPIDOMWindow* aWindow, const nsAString &aType, const PRInt32 aIndex);
 
-  PRInt32 SetRootFileForType(const nsAString& aType, const PRInt32 aIndex);
+  void SetRootFileForType(const nsAString& aType, const PRInt32 aIndex);
 
   static void CreateDeviceStoragesFor(nsPIDOMWindow* aWin,
                                       const nsAString &aType,
                                       nsTArray<nsRefPtr<nsDOMDeviceStorage> > &aStores);
   void Shutdown();
 
 private:
   ~nsDOMDeviceStorage();
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -274,48 +274,43 @@ DeviceStorageFile::collectFilesInternal(
       aFiles.AppendElement(dsf);
     }
   }
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS0(DeviceStorageFile)
 
 
-// TODO - eventually, we will want to factor this method
-// out into different system specific subclasses (or
-// something)
-PRInt32
+void
 nsDOMDeviceStorage::SetRootFileForType(const nsAString& aType, const PRInt32 aIndex)
 {
-  PRInt32 typeResult = DEVICE_STORAGE_TYPE_DEFAULT;
-
   nsCOMPtr<nsIFile> f;
   nsCOMPtr<nsIProperties> dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
   NS_ASSERTION(dirService, "Must have directory service");
 
 #ifdef MOZ_WIDGET_GONK
   mFile = nullptr;
 
   nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
   if (!vs) {
-    return typeResult;
+    return;
   }
 
   nsCOMPtr<nsIVolume> v;
   vs->GetVolumeByPath(NS_LITERAL_STRING("/sdcard"), getter_AddRefs(v));
   
   if (!v) {
-    return typeResult;
+    return;
   }
 
   PRInt32 state;
   v->GetState(&state);
 
   if (state != nsIVolume::STATE_MOUNTED) {
-    return typeResult;
+    return;
   }
 #endif
 
   // Picture directory
   if (aType.Equals(NS_LITERAL_STRING("pictures"))) {
 #ifdef MOZ_WIDGET_GONK
     if (aIndex == 0) {
       NS_NewLocalFile(NS_LITERAL_STRING("/sdcard/DCIM"), false, getter_AddRefs(f));
@@ -375,17 +370,16 @@ nsDOMDeviceStorage::SetRootFileForType(c
 	f->AppendRelativeNativePath(NS_LITERAL_CSTRING("device-storage-testing"));
 	f->Create(nsIFile::DIRECTORY_TYPE, 0777);
        f->Normalize();
       }
     }
   } 
 
   mFile = f;
-  return typeResult;
 }
 
 static jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(aWindow, "Null Window");
 
   if (aFile->mEditable) {
@@ -1315,26 +1309,25 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceStorage)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDeviceStorage, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(nsDOMDeviceStorage, nsDOMEventTargetHelper)
 
 nsDOMDeviceStorage::nsDOMDeviceStorage()
- : mStorageType(DEVICE_STORAGE_TYPE_DEFAULT)
- , mIsWatchingFile(false)
+  : mIsWatchingFile(false)
 { }
 
 nsresult
 nsDOMDeviceStorage::Init(nsPIDOMWindow* aWindow, const nsAString &aType, const PRInt32 aIndex)
 {
   NS_ASSERTION(aWindow, "Must have a content dom");
 
-  mStorageType = SetRootFileForType(aType, aIndex);
+  SetRootFileForType(aType, aIndex);
   if (!mFile) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   BindToOwner(aWindow);
 
   // Grab the uri of the document
   nsCOMPtr<nsIDOMDocument> domdoc;
@@ -1383,34 +1376,16 @@ nsDOMDeviceStorage::CreateDeviceStorages
     rv = storage->Init(aWin, aType, index++);
     if (NS_FAILED(rv))
       break;
     aStores.AppendElement(storage);
   }
 }
 
 NS_IMETHODIMP
-nsDOMDeviceStorage::GetType(nsAString & aType)
-{
-  switch(mStorageType) {
-    case DEVICE_STORAGE_TYPE_EXTERNAL:
-      aType.AssignLiteral("external");
-      break;
-    case DEVICE_STORAGE_TYPE_SHARED:
-      aType.AssignLiteral("shared");
-      break;
-    case DEVICE_STORAGE_TYPE_DEFAULT:
-    default:
-      aType.AssignLiteral("default");
-      break;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsDOMDeviceStorage::Add(nsIDOMBlob *aBlob, nsIDOMDOMRequest * *_retval)
 {
   // possible race here w/ unique filename
   char buffer[128];
   NS_MakeRandomString(buffer, 128);
 
   nsString path;
   path.AssignWithConversion(nsDependentCString(buffer));
--- a/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl
+++ b/dom/interfaces/devicestorage/nsIDOMDeviceStorage.idl
@@ -10,24 +10,19 @@ interface nsIDOMDeviceStorageCursor;
 interface nsIDOMDeviceStorageChangeEvent;
 interface nsIDOMEventListener;
 
 dictionary DeviceStorageEnumerationParameters
 {
   jsval since;
 };
 
-[scriptable, uuid(f57450db-07df-44ac-bf34-7ee65fe17b26), builtinclass]
+[scriptable, uuid(3dbe0137-ca73-44c5-bcde-25c297bf7c65), builtinclass]
 interface nsIDOMDeviceStorage : nsIDOMEventTarget
 {
-    /*
-     * Hint as to what kind of storage this object is.
-     * May be "external", "shared", or "default".
-     */
-    readonly attribute DOMString type;
     attribute nsIDOMEventListener onchange;
     nsIDOMDOMRequest add(in nsIDOMBlob aBlob);
     nsIDOMDOMRequest addNamed(in nsIDOMBlob aBlob, in DOMString aName);
 
     [implicit_jscontext]
     nsIDOMDOMRequest get(in jsval aName);
 
     [implicit_jscontext]