2009-06-30 11:51:05 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
#ifndef dom_plugins_PluginProcessParent_h
|
|
|
|
#define dom_plugins_PluginProcessParent_h 1
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-07-02 09:54:22 -07:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "base/file_path.h"
|
2014-12-29 15:13:28 -08:00
|
|
|
#include "base/task.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
#include "base/thread.h"
|
|
|
|
#include "base/waitable_event.h"
|
|
|
|
#include "chrome/common/child_process_host.h"
|
|
|
|
|
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2014-12-29 15:13:28 -08:00
|
|
|
#include "mozilla/UniquePtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIRunnable.h"
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
2014-12-29 15:13:28 -08:00
|
|
|
|
|
|
|
class LaunchCompleteTask : public Task
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LaunchCompleteTask()
|
|
|
|
: mLaunchSucceeded(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLaunchSucceeded() { mLaunchSucceeded = true; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool mLaunchSucceeded;
|
|
|
|
};
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2010-08-27 06:32:45 -07:00
|
|
|
class PluginProcessParent : public mozilla::ipc::GeckoChildProcessHost
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 15:26:43 -07:00
|
|
|
explicit PluginProcessParent(const std::string& aPluginFilePath);
|
2009-06-30 11:51:05 -07:00
|
|
|
~PluginProcessParent();
|
|
|
|
|
|
|
|
/**
|
2014-12-29 15:13:28 -08:00
|
|
|
* Launch the plugin process. If the process fails to launch,
|
|
|
|
* this method will return false.
|
|
|
|
*
|
|
|
|
* @param aLaunchCompleteTask Task that is executed on the main
|
|
|
|
* thread once the asynchonous launch has completed.
|
2009-06-30 11:51:05 -07:00
|
|
|
*/
|
2014-12-29 15:13:28 -08:00
|
|
|
bool Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask = UniquePtr<LaunchCompleteTask>());
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2009-11-09 14:56:55 -08:00
|
|
|
void Delete();
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual bool CanShutdown() MOZ_OVERRIDE
|
2009-06-30 11:51:05 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-13 17:20:00 -08:00
|
|
|
const std::string& GetPluginFilePath() { return mPluginFilePath; }
|
|
|
|
|
2009-10-27 14:52:37 -07:00
|
|
|
using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
|
|
|
|
using mozilla::ipc::GeckoChildProcessHost::GetChannel;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
2014-12-29 15:13:28 -08:00
|
|
|
void SetCallRunnableImmediately(bool aCallImmediately);
|
|
|
|
virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void OnChannelConnected(int32_t peer_pid) MOZ_OVERRIDE;
|
|
|
|
virtual void OnChannelError() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
bool IsConnected();
|
|
|
|
|
2009-06-30 11:51:05 -07:00
|
|
|
private:
|
2015-01-07 17:01:51 -08:00
|
|
|
void RunLaunchCompleteTask();
|
|
|
|
|
2009-07-02 09:54:22 -07:00
|
|
|
std::string mPluginFilePath;
|
2014-12-29 15:13:28 -08:00
|
|
|
UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
|
|
|
|
MessageLoop* mMainMsgLoop;
|
|
|
|
bool mRunCompleteTaskImmediately;
|
2009-06-30 11:51:05 -07:00
|
|
|
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // ifndef dom_plugins_PluginProcessParent_h
|