Bug 1062981 - Disable bfcache for pages active MediaManager. r=smaug, r=jesup, a=lmandel
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 05 Sep 2014 16:02:54 -0400
changeset 216703 46abad0899f9
parent 216702 02474d192901
child 216704 8e9b139e30b9
push id3883
push userryanvm@gmail.com
push date2014-09-11 20:34 +0000
treeherdermozilla-beta@d4082d3a082c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, jesup, lmandel
bugs1062981
milestone33.0
Bug 1062981 - Disable bfcache for pages active MediaManager. r=smaug, r=jesup, a=lmandel
content/base/src/nsDocument.cpp
dom/media/MediaManager.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -145,16 +145,19 @@
 #include "mozilla/dom/StyleSheetApplicableStateChangeEvent.h"
 #include "nsJSUtils.h"
 #include "nsFrameLoader.h"
 #include "nsEscape.h"
 #include "nsObjectLoadingContent.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "mozilla/dom/HTMLLinkElement.h"
 #include "mozilla/dom/HTMLMediaElement.h"
+#ifdef MOZ_MEDIA_NAVIGATOR
+#include "mozilla/MediaManager.h"
+#endif // MOZ_MEDIA_NAVIGATOR
 #ifdef MOZ_WEBRTC
 #include "IPeerConnection.h"
 #endif // MOZ_WEBRTC
 
 #include "mozAutoDocUpdate.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/dom/EncodingUtils.h"
 #include "mozilla/dom/quota/QuotaManager.h"
@@ -8450,16 +8453,24 @@ nsDocument::CanSavePresentation(nsIReque
 
   // Check if we have running offline storage transactions
   quota::QuotaManager* quotaManager =
     win ? quota::QuotaManager::Get() : nullptr;
   if (quotaManager && quotaManager->HasOpenTransactions(win)) {
    return false;
   }
 
+#ifdef MOZ_MEDIA_NAVIGATOR
+  // Check if we have active GetUserMedia use
+  if (MediaManager::Exists() && win &&
+      MediaManager::Get()->IsWindowStillActive(win->WindowID())) {
+    return false;
+  }
+#endif // MOZ_MEDIA_NAVIGATOR
+
 #ifdef MOZ_WEBRTC
   // Check if we have active PeerConnections
   nsCOMPtr<IPeerConnectionManager> pcManager =
     do_GetService(IPEERCONNECTION_MANAGER_CONTRACTID);
 
   if (pcManager && win) {
     bool active;
     pcManager->HasActivePeerConnection(win->WindowID(), &active);
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -533,16 +533,21 @@ class MediaManager MOZ_FINAL : public ns
 public:
   static already_AddRefed<MediaManager> GetInstance();
 
   // NOTE: never Dispatch(....,NS_DISPATCH_SYNC) to the MediaManager
   // thread from the MainThread, as we NS_DISPATCH_SYNC to MainThread
   // from MediaManager thread.
   static MediaManager* Get();
 
+  static bool Exists()
+  {
+    return !!sSingleton;
+  }
+
   static nsIThread* GetThread() {
     return Get()->mMediaThread;
   }
 
   static nsresult NotifyRecordingStatusChange(nsPIDOMWindow* aWindow,
                                               const nsString& aMsg,
                                               const bool& aIsAudio,
                                               const bool& aIsVideo);