Bug 1306493 - Part 5: Make we only have one VRMockDisplay in tests; r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Wed, 15 Mar 2017 13:50:34 +0800
changeset 348143 b34efbb33ad6c5b9f2950c85c399669c56fa92e2
parent 348142 1f6c8b941701bb07aee0702eb11ceb92cbba22ce
child 348144 ad24ad035ca8209b9944681bf04c3d8197c57553
push id88164
push usercbook@mozilla.com
push dateFri, 17 Mar 2017 13:55:35 +0000
treeherdermozilla-inbound@e46c08babe02 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1306493
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 1306493 - Part 5: Make we only have one VRMockDisplay in tests; r=kip MozReview-Commit-ID: ACIszhHGUiQ
gfx/vr/ipc/VRManagerChild.cpp
gfx/vr/ipc/VRManagerChild.h
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -40,16 +40,17 @@ void ReleaseVRManagerParentSingleton() {
 VRManagerChild::VRManagerChild()
   : TextureForwarder()
   , mDisplaysInitialized(false)
   , mInputFrameID(-1)
   , mMessageLoop(MessageLoop::current())
   , mFrameRequestCallbackCounter(0)
   , mBackend(layers::LayersBackend::LAYERS_NONE)
   , mPromiseID(0)
+  , mVRMockDisplay(nullptr)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mStartTimeStamp = TimeStamp::Now();
 }
 
 VRManagerChild::~VRManagerChild()
 {
@@ -514,17 +515,21 @@ VRManagerChild::RecvReplyCreateVRService
                                                     const uint32_t& aPromiseID,
                                                     const uint32_t& aDeviceID)
 {
   RefPtr<dom::Promise> p;
   if (!mPromiseList.Get(aPromiseID, getter_AddRefs(p))) {
     MOZ_CRASH("We should always have a promise.");
   }
 
-  p->MaybeResolve(new VRMockDisplay(aID, aDeviceID));
+  // We only allow one VRMockDisplay in VR tests.
+  if (!mVRMockDisplay) {
+    mVRMockDisplay = new VRMockDisplay(aID, aDeviceID);
+  }
+  p->MaybeResolve(mVRMockDisplay);
   mPromiseList.Remove(aPromiseID);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 VRManagerChild::RecvReplyCreateVRServiceTestController(const nsCString& aID,
                                                        const uint32_t& aPromiseID,
                                                        const uint32_t& aDeviceID)
--- a/gfx/vr/ipc/VRManagerChild.h
+++ b/gfx/vr/ipc/VRManagerChild.h
@@ -16,16 +16,17 @@
 #include "mozilla/layers/TextureForwarder.h"
 
 namespace mozilla {
 namespace dom {
 class GamepadManager;
 class Navigator;
 class VRDisplay;
 class VREventObserver;
+class VRMockDisplay;
 } // namespace dom
 namespace layers {
 class TextureClient;
 }
 namespace gfx {
 class VRLayerChild;
 class VRDisplayClient;
 
@@ -182,16 +183,17 @@ private:
   * It defer calling of TextureClient recycle callback.
   */
   nsDataHashtable<nsUint64HashKey, RefPtr<layers::TextureClient> > mTexturesWaitingRecycled;
 
   layers::LayersBackend mBackend;
   RefPtr<layers::SyncObject> mSyncObject;
   uint32_t mPromiseID;
   nsRefPtrHashtable<nsUint32HashKey, dom::Promise> mPromiseList;
+  RefPtr<dom::VRMockDisplay> mVRMockDisplay;
 
   DISALLOW_COPY_AND_ASSIGN(VRManagerChild);
 };
 
 } // namespace mozilla
 } // namespace gfx
 
 #endif // MOZILLA_GFX_VR_VRMANAGERCHILD_H