Bug 1341138 - Move LogToConsole from GMPCDMProxy to GMPUtils. r?gerald draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 21 Feb 2017 13:44:58 +1300
changeset 487145 2d82338b77271e84a1c2d000fef0902311803fa4
parent 487144 70528873123bbc3d5ea427b0493ece2fe5e5dd09
child 487617 f405ff6bcf980809dae5ee588937900c8219f1a7
push id46150
push userbmo:cpearce@mozilla.com
push dateTue, 21 Feb 2017 00:50:12 +0000
reviewersgerald
bugs1341138
milestone54.0a1
Bug 1341138 - Move LogToConsole from GMPCDMProxy to GMPUtils. r?gerald This means we can reuse LogToConsole inside the new CDM decoder backend. This change also makes GMPUtils.cpp build in non-unified build mode. MozReview-Commit-ID: AFkdHIos4X2
dom/media/gmp/GMPCDMProxy.cpp
dom/media/gmp/GMPService.h
dom/media/gmp/GMPUtils.cpp
dom/media/gmp/GMPUtils.h
--- a/dom/media/gmp/GMPCDMProxy.cpp
+++ b/dom/media/gmp/GMPCDMProxy.cpp
@@ -7,27 +7,25 @@
 #include "GMPCDMProxy.h"
 #include "mozilla/EMEUtils.h"
 #include "mozilla/PodOperations.h"
 
 #include "mozilla/dom/MediaKeys.h"
 #include "mozilla/dom/MediaKeySession.h"
 
 #include "mozIGeckoMediaPluginService.h"
-#include "nsContentCID.h"
-#include "nsIConsoleService.h"
 #include "nsPrintfCString.h"
-#include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "prenv.h"
 #include "GMPCDMCallbackProxy.h"
 #include "GMPService.h"
 #include "MainThreadUtils.h"
 #include "MediaData.h"
 #include "DecryptJob.h"
+#include "GMPUtils.h"
 
 namespace mozilla {
 
 GMPCDMProxy::GMPCDMProxy(dom::MediaKeys* aKeys,
                          const nsAString& aKeySystem,
                          GMPCrashHelper* aCrashHelper,
                          bool aDistinctiveIdentifierRequired,
                          bool aPersistentStateRequired)
@@ -632,29 +630,16 @@ void
 GMPCDMProxy::OnDecrypted(uint32_t aId,
                          DecryptStatus aResult,
                          const nsTArray<uint8_t>& aDecryptedData)
 {
   MOZ_ASSERT(IsOnOwnerThread());
   gmp_Decrypted(aId, aResult, aDecryptedData);
 }
 
-static void
-LogToConsole(const nsAString& aMsg)
-{
-  nsCOMPtr<nsIConsoleService> console(
-    do_GetService("@mozilla.org/consoleservice;1"));
-  if (!console) {
-    NS_WARNING("Failed to log message to console.");
-    return;
-  }
-  nsAutoString msg(aMsg);
-  console->LogStringMessage(msg.get());
-}
-
 void
 GMPCDMProxy::OnSessionError(const nsAString& aSessionId,
                          nsresult aException,
                          uint32_t aSystemCode,
                          const nsAString& aMsg)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mKeys.IsNull()) {
--- a/dom/media/gmp/GMPService.h
+++ b/dom/media/gmp/GMPService.h
@@ -18,16 +18,17 @@
 #include "nsThreadUtils.h"
 #include "nsIDocument.h"
 #include "nsIWeakReference.h"
 #include "mozilla/AbstractThread.h"
 #include "nsClassHashtable.h"
 #include "nsISupportsImpl.h"
 #include "mozilla/MozPromise.h"
 #include "GMPContentParent.h"
+#include "GMPCrashHelper.h"
 
 template <class> struct already_AddRefed;
 
 namespace mozilla {
 
 class GMPCrashHelper;
 
 extern LogModule* GetGMPLog();
--- a/dom/media/gmp/GMPUtils.cpp
+++ b/dom/media/gmp/GMPUtils.cpp
@@ -7,16 +7,19 @@
 #include "GMPUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIFile.h"
 #include "nsCOMPtr.h"
 #include "nsLiteralString.h"
 #include "nsCRTGlue.h"
 #include "mozilla/Base64.h"
 #include "nsISimpleEnumerator.h"
+#include "prio.h"
+#include "nsIConsoleService.h"
+#include "mozIGeckoMediaPluginService.h"
 
 namespace mozilla {
 
 void
 SplitAt(const char* aDelims,
         const nsACString& aInput,
         nsTArray<nsCString>& aOutTokens)
 {
@@ -209,10 +212,22 @@ HaveGMPFor(const nsCString& aAPI,
 
   bool hasPlugin = false;
   if (NS_FAILED(mps->HasPluginForAPI(aAPI, &aTags, &hasPlugin))) {
     return false;
   }
   return hasPlugin;
 }
 
+void
+LogToConsole(const nsAString& aMsg)
+{
+  nsCOMPtr<nsIConsoleService> console(
+    do_GetService("@mozilla.org/consoleservice;1"));
+  if (!console) {
+    NS_WARNING("Failed to log message to console.");
+    return;
+  }
+  nsAutoString msg(aMsg);
+  console->LogStringMessage(msg.get());
+}
 
 } // namespace mozilla
--- a/dom/media/gmp/GMPUtils.h
+++ b/dom/media/gmp/GMPUtils.h
@@ -73,11 +73,14 @@ bool
 ReadIntoString(nsIFile* aFile,
                nsCString& aOutDst,
                size_t aMaxLength);
 
 bool
 HaveGMPFor(const nsCString& aAPI,
            nsTArray<nsCString>&& aTags);
 
+void
+LogToConsole(const nsAString& aMsg);
+
 } // namespace mozilla
 
 #endif