Bug 1038855, part 2 - Use an nsRefPtr for CompositorChild::SharedFrameMetricsData::mBuffer. r=bjacob
authorAndrew McCreight <continuation@gmail.com>
Wed, 16 Jul 2014 12:39:03 -0700
changeset 194425 2bf6c098623d9f8e95e9d86e1a8a1721fb6583d7
parent 194424 f60bdae3c097a3dfa3e40976da5df953b738a76f
child 194426 74034d6b6ae6d550c6b482bd79a595f8c527d87d
push id46350
push useramccreight@mozilla.com
push dateWed, 16 Jul 2014 19:39:21 +0000
treeherdermozilla-inbound@74034d6b6ae6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs1038855
milestone33.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 1038855, part 2 - Use an nsRefPtr for CompositorChild::SharedFrameMetricsData::mBuffer. r=bjacob
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorChild.h
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -207,32 +207,31 @@ CompositorChild::RecvReleaseSharedCompos
   }
   return true;
 }
 
 CompositorChild::SharedFrameMetricsData::SharedFrameMetricsData(
     const ipc::SharedMemoryBasic::Handle& metrics,
     const CrossProcessMutexHandle& handle,
     const uint32_t& aAPZCId) :
-    mBuffer(nullptr),
     mMutex(nullptr),
     mAPZCId(aAPZCId)
 {
   mBuffer = new ipc::SharedMemoryBasic(metrics);
   mBuffer->Map(sizeof(FrameMetrics));
   mMutex = new CrossProcessMutex(handle);
   MOZ_COUNT_CTOR(SharedFrameMetricsData);
 }
 
 CompositorChild::SharedFrameMetricsData::~SharedFrameMetricsData()
 {
   // When the hash table deletes the class, delete
   // the shared memory and mutex.
   delete mMutex;
-  delete mBuffer;
+  mBuffer = nullptr;
   MOZ_COUNT_DTOR(SharedFrameMetricsData);
 }
 
 void
 CompositorChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aFrame)
 {
   FrameMetrics* frame = static_cast<FrameMetrics*>(mBuffer->memory());
   MOZ_ASSERT(frame);
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -95,17 +95,17 @@ private:
 
     void CopyFrameMetrics(FrameMetrics* aFrame);
     FrameMetrics::ViewID GetViewID();
     uint32_t GetAPZCId();
 
   private:
     // Pointer to the class that allows access to the shared memory that contains
     // the shared FrameMetrics
-    mozilla::ipc::SharedMemoryBasic* mBuffer;
+    nsRefPtr<mozilla::ipc::SharedMemoryBasic> mBuffer;
     CrossProcessMutex* mMutex;
     // Unique ID of the APZC that is sharing the FrameMetrics
     uint32_t mAPZCId;
   };
 
   nsRefPtr<ClientLayerManager> mLayerManager;
 
   // The ViewID of the FrameMetrics is used as the key for this hash table.