LCOV - code coverage report
Current view: top level - dom/media/gmp - GMPProcessParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 23 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             :  * vim: sw=2 ts=2 et :
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "GMPProcessParent.h"
       8             : #include "GMPUtils.h"
       9             : #include "nsIFile.h"
      10             : #include "nsIRunnable.h"
      11             : #if defined(XP_WIN) && defined(MOZ_SANDBOX)
      12             : #include "WinUtils.h"
      13             : #endif
      14             : #include "GMPLog.h"
      15             : 
      16             : #include "base/string_util.h"
      17             : #include "base/process_util.h"
      18             : 
      19             : #include <string>
      20             : 
      21             : using std::vector;
      22             : using std::string;
      23             : 
      24             : using mozilla::gmp::GMPProcessParent;
      25             : using mozilla::ipc::GeckoChildProcessHost;
      26             : using base::ProcessArchitecture;
      27             : 
      28             : namespace mozilla {
      29             : namespace gmp {
      30             : 
      31           0 : GMPProcessParent::GMPProcessParent(const std::string& aGMPPath)
      32             : : GeckoChildProcessHost(GeckoProcessType_GMPlugin),
      33           0 :   mGMPPath(aGMPPath)
      34             : {
      35           0 :   MOZ_COUNT_CTOR(GMPProcessParent);
      36           0 : }
      37             : 
      38           0 : GMPProcessParent::~GMPProcessParent()
      39             : {
      40           0 :   MOZ_COUNT_DTOR(GMPProcessParent);
      41           0 : }
      42             : 
      43             : bool
      44           0 : GMPProcessParent::Launch(int32_t aTimeoutMs)
      45             : {
      46           0 :   vector<string> args;
      47             : 
      48             : #if defined(XP_WIN) && defined(MOZ_SANDBOX)
      49             :   std::wstring wGMPPath = UTF8ToWide(mGMPPath.c_str());
      50             : 
      51             :   // The sandbox doesn't allow file system rules where the paths contain
      52             :   // symbolic links or junction points. Sometimes the Users folder has been
      53             :   // moved to another drive using a junction point, so allow for this specific
      54             :   // case. See bug 1236680 for details.
      55             :   if (!widget::WinUtils::ResolveJunctionPointsAndSymLinks(wGMPPath)) {
      56             :     GMP_LOG("ResolveJunctionPointsAndSymLinks failed for GMP path=%S",
      57             :             wGMPPath.c_str());
      58             :     NS_WARNING("ResolveJunctionPointsAndSymLinks failed for GMP path.");
      59             :     return false;
      60             :   }
      61             :   GMP_LOG("GMPProcessParent::Launch() resolved path to %S", wGMPPath.c_str());
      62             : 
      63             :   // If the GMP path is a network path that is not mapped to a drive letter,
      64             :   // then we need to fix the path format for the sandbox rule.
      65             :   wchar_t volPath[MAX_PATH];
      66             :   if (::GetVolumePathNameW(wGMPPath.c_str(), volPath, MAX_PATH) &&
      67             :       ::GetDriveTypeW(volPath) == DRIVE_REMOTE &&
      68             :       wGMPPath.compare(0, 2, L"\\\\") == 0) {
      69             :     std::wstring sandboxGMPPath(wGMPPath);
      70             :     sandboxGMPPath.insert(1, L"??\\UNC");
      71             :     mAllowedFilesRead.push_back(sandboxGMPPath + L"\\*");
      72             :   } else {
      73             :     mAllowedFilesRead.push_back(wGMPPath + L"\\*");
      74             :   }
      75             : 
      76             :   args.push_back(WideToUTF8(wGMPPath));
      77             : #else
      78           0 :   args.push_back(mGMPPath);
      79             : #endif
      80             : 
      81           0 :   return SyncLaunch(args, aTimeoutMs, base::GetCurrentProcessArchitecture());
      82             : }
      83             : 
      84             : void
      85           0 : GMPProcessParent::Delete(nsCOMPtr<nsIRunnable> aCallback)
      86             : {
      87           0 :   mDeletedCallback = aCallback;
      88           0 :   XRE_GetIOMessageLoop()->PostTask(NewNonOwningRunnableMethod(
      89           0 :     "gmp::GMPProcessParent::DoDelete", this, &GMPProcessParent::DoDelete));
      90           0 : }
      91             : 
      92             : void
      93           0 : GMPProcessParent::DoDelete()
      94             : {
      95           0 :   MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
      96           0 :   Join();
      97             : 
      98           0 :   if (mDeletedCallback) {
      99           0 :     mDeletedCallback->Run();
     100             :   }
     101             : 
     102           0 :   delete this;
     103           0 : }
     104             : 
     105             : } // namespace gmp
     106             : } // namespace mozilla

Generated by: LCOV version 1.13