Bug 1236380 - GMPStorage::mShutdown=true until Init() succeeds - r?cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 06 Jan 2016 15:47:11 +1100
changeset 319171 48ae04156db0fde074c8e5850b5f374d6a3c9352
parent 319164 9d6ffc7a08b6b47056eefe1e652710a3849adbf7
child 512563 02fbd1260acf1ac2880131b1871e1fb27bc927b4
push id8995
push usergsquelart@mozilla.com
push dateWed, 06 Jan 2016 04:55:33 +0000
reviewerscpearce
bugs1236380
milestone46.0a1
Bug 1236380 - GMPStorage::mShutdown=true until Init() succeeds - r?cpearce Initialize GMPStorage::mShutdown to true, so that if Init() has not completed yet or if it failed, other methods will not try and access a null mStorage.
dom/media/gmp/GMPStorageParent.cpp
dom/media/gmp/GMPStorageParent.h
--- a/dom/media/gmp/GMPStorageParent.cpp
+++ b/dom/media/gmp/GMPStorageParent.cpp
@@ -563,17 +563,17 @@ private:
 
   nsClassHashtable<nsCStringHashKey, Record> mRecords;
 };
 
 GMPStorageParent::GMPStorageParent(const nsCString& aNodeId,
                                    GMPParent* aPlugin)
   : mNodeId(aNodeId)
   , mPlugin(aPlugin)
-  , mShutdown(false)
+  , mShutdown(true)
 {
 }
 
 nsresult
 GMPStorageParent::Init()
 {
   LOGD(("GMPStorageParent[%p]::Init()", this));
 
@@ -597,16 +597,17 @@ GMPStorageParent::Init()
       NS_WARNING("Failed to initialize on disk GMP storage");
       return NS_ERROR_FAILURE;
     }
     mStorage = Move(storage);
   } else {
     mStorage = MakeUnique<GMPMemoryStorage>();
   }
 
+  mShutdown = false;
   return NS_OK;
 }
 
 bool
 GMPStorageParent::RecvOpen(const nsCString& aRecordName)
 {
   LOGD(("GMPStorageParent[%p]::RecvOpen(record='%s')",
        this, aRecordName.get()));
--- a/dom/media/gmp/GMPStorageParent.h
+++ b/dom/media/gmp/GMPStorageParent.h
@@ -49,15 +49,16 @@ protected:
 
 private:
   ~GMPStorageParent() {}
 
   UniquePtr<GMPStorage> mStorage;
 
   const nsCString mNodeId;
   RefPtr<GMPParent> mPlugin;
+  // True after Shutdown(), or if Init() has not completed successfully.
   bool mShutdown;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPStorageParent_h_