Bug 782391 - Device Storage - Watch should also go through the permission prompt. r=sicking
authorDoug Turner <dougt@dougt.org>
Fri, 17 Aug 2012 19:43:00 -0700
changeset 102706 13efbdf35a8b713dd536208e97228c4b3703e2a6
parent 102705 77d2640d9892851b26fe4f531b6cb58f19d1a0bc
child 102707 d11657f18f85b6114c4571404fdaba2a3d150962
push id23303
push userryanvm@gmail.com
push dateSat, 18 Aug 2012 11:22:19 +0000
treeherdermozilla-central@9c48df21d744 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs782391
milestone17.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 782391 - Device Storage - Watch should also go through the permission prompt. r=sicking
dom/devicestorage/DeviceStorage.h
dom/devicestorage/nsDeviceStorage.cpp
--- a/dom/devicestorage/DeviceStorage.h
+++ b/dom/devicestorage/DeviceStorage.h
@@ -52,16 +52,17 @@ private:
                              nsIDOMDeviceStorageCursor** aRetval);
 
   PRInt32 mStorageType;
   nsCOMPtr<nsIFile> mFile;
 
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   bool mIsWatchingFile;
+  bool mAllowedToWatchFile;
 
   nsresult Notify(const char* aReason, nsIFile* aFile);
 
   friend class WatchFileEvent;
   friend class DeviceStorageRequest;
 
 #ifdef MOZ_WIDGET_GONK
   void DispatchMountChangeEvent(nsAString& aType);
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1327,17 +1327,18 @@ public:
 	  return NS_OK;
         }
         r = new StatFileEvent(mFile, mRequest);
         break;
       }
 
       case DEVICE_STORAGE_REQUEST_WATCH:
       {
-	// do something?
+	mDeviceStorage->mAllowedToWatchFile = true;
+	return NS_OK;
       }
     }
 
     if (r) {
       nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
       NS_ASSERTION(target, "Must have stream transport service");
       target->Dispatch(r, NS_DISPATCH_NORMAL);
     }
@@ -1416,16 +1417,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
   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()
   : mIsWatchingFile(false)
+  , mAllowedToWatchFile(false)
 { }
 
 nsresult
 nsDOMDeviceStorage::Init(nsPIDOMWindow* aWindow, const nsAString &aType)
 {
   NS_ASSERTION(aWindow, "Must have a content dom");
 
   SetRootFileForType(aType);
@@ -1857,16 +1859,20 @@ nsDOMDeviceStorage::Observe(nsISupports 
   }
 #endif
   return NS_OK;
 }
 
 nsresult
 nsDOMDeviceStorage::Notify(const char* aReason, nsIFile* aFile)
 {
+  if (!mAllowedToWatchFile) {
+    return NS_OK;
+  }
+
   if (!mFile) {
     return NS_ERROR_FAILURE;
   }
 
   nsString rootpath;
   nsresult rv = mFile->GetPath(rootpath);
   if (NS_FAILED(rv)) {
     return NS_OK;