LCOV - code coverage report
Current view: top level - dom/plugins/ipc - PluginProcessParent.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 9 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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: sw=4 ts=4 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             : #ifndef dom_plugins_PluginProcessParent_h
       8             : #define dom_plugins_PluginProcessParent_h 1
       9             : 
      10             : #include "mozilla/Attributes.h"
      11             : #include "base/basictypes.h"
      12             : 
      13             : #include "base/file_path.h"
      14             : #include "base/task.h"
      15             : #include "base/thread.h"
      16             : #include "chrome/common/child_process_host.h"
      17             : 
      18             : #include "mozilla/ipc/GeckoChildProcessHost.h"
      19             : #include "mozilla/ipc/TaskFactory.h"
      20             : #include "mozilla/UniquePtr.h"
      21             : #include "nsCOMPtr.h"
      22             : #include "nsIRunnable.h"
      23             : 
      24             : namespace mozilla {
      25             : namespace plugins {
      26             : 
      27           0 : class LaunchCompleteTask : public Runnable
      28             : {
      29             : public:
      30           0 :   LaunchCompleteTask()
      31           0 :     : Runnable("plugins::LaunchCompleteTask")
      32           0 :     , mLaunchSucceeded(false)
      33             :   {
      34           0 :     }
      35             : 
      36           0 :     void SetLaunchSucceeded() { mLaunchSucceeded = true; }
      37             : 
      38             : protected:
      39             :     bool mLaunchSucceeded;
      40             : };
      41             : 
      42             : class PluginProcessParent : public mozilla::ipc::GeckoChildProcessHost
      43             : {
      44             : public:
      45             :     explicit PluginProcessParent(const std::string& aPluginFilePath);
      46             :     ~PluginProcessParent();
      47             : 
      48             :     /**
      49             :      * Launch the plugin process. If the process fails to launch,
      50             :      * this method will return false.
      51             :      *
      52             :      * @param aLaunchCompleteTask Task that is executed on the main
      53             :      * thread once the asynchonous launch has completed.
      54             :      * @param aSandboxLevel Determines the strength of the sandbox.
      55             :      * <= 0 means no sandbox.
      56             :      */
      57             :     bool Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask = UniquePtr<LaunchCompleteTask>(),
      58             :                 int32_t aSandboxLevel = 0);
      59             : 
      60             :     void Delete();
      61             : 
      62           0 :     virtual bool CanShutdown() override
      63             :     {
      64           0 :         return true;
      65             :     }
      66             : 
      67           0 :     const std::string& GetPluginFilePath() { return mPluginFilePath; }
      68             : 
      69             :     using mozilla::ipc::GeckoChildProcessHost::GetChannel;
      70             : 
      71             :     virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0) override;
      72             : 
      73             :     virtual void OnChannelConnected(int32_t peer_pid) override;
      74             :     virtual void OnChannelError() override;
      75             : 
      76             :     bool IsConnected();
      77             : 
      78             :     static bool IsPluginProcessId(base::ProcessId procId);
      79             : 
      80             : private:
      81             :     void RunLaunchCompleteTask();
      82             : 
      83             :     std::string mPluginFilePath;
      84             :     ipc::TaskFactory<PluginProcessParent> mTaskFactory;
      85             :     UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
      86             :     MessageLoop* mMainMsgLoop;
      87             : #ifdef XP_WIN
      88             :     typedef nsTHashtable<nsUint32HashKey> PidSet;
      89             :     // Set of PIDs for all plugin child processes or NULL if empty.
      90             :     static PidSet* sPidSet;
      91             :     uint32_t mChildPid;
      92             : #endif
      93             : 
      94             :     DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
      95             : };
      96             : 
      97             : 
      98             : } // namespace plugins
      99             : } // namespace mozilla
     100             : 
     101             : #endif // ifndef dom_plugins_PluginProcessParent_h

Generated by: LCOV version 1.13