2014-05-18 07:05:46 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef GMPService_h_
|
|
|
|
#define GMPService_h_
|
|
|
|
|
2014-07-11 07:35:56 +04:00
|
|
|
#include "nsString.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "mozIGeckoMediaPluginService.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsTArray.h"
|
2014-09-01 07:50:23 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-08-18 01:41:56 +04:00
|
|
|
#include "mozilla/Monitor.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIThread.h"
|
|
|
|
|
2014-06-17 18:57:23 +04:00
|
|
|
template <class> struct already_AddRefed;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2015-02-09 23:54:12 +03:00
|
|
|
|
|
|
|
extern PRLogModuleInfo* GetGMPLog();
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
namespace gmp {
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
class GetGMPContentParentCallback;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2014-10-22 00:45:18 +04:00
|
|
|
#define GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT 3000
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
class GeckoMediaPluginService : public mozIGeckoMediaPluginService
|
|
|
|
, public nsIObserver
|
2014-05-18 07:05:46 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static already_AddRefed<GeckoMediaPluginService> GetGeckoMediaPluginService();
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
virtual nsresult Init();
|
2014-05-18 07:05:46 +04:00
|
|
|
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
// mozIGeckoMediaPluginService
|
|
|
|
NS_IMETHOD GetThread(nsIThread** aThread) override;
|
|
|
|
NS_IMETHOD HasPluginForAPI(const nsACString& aAPI, nsTArray<nsCString>* aTags,
|
|
|
|
bool *aRetVal) override;
|
|
|
|
NS_IMETHOD GetGMPVideoDecoder(nsTArray<nsCString>* aTags,
|
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPVideoDecoderCallback>&& aCallback)
|
|
|
|
override;
|
2015-02-09 23:54:12 +03:00
|
|
|
NS_IMETHOD GetGMPVideoEncoder(nsTArray<nsCString>* aTags,
|
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPVideoEncoderCallback>&& aCallback)
|
|
|
|
override;
|
2015-02-09 23:54:12 +03:00
|
|
|
NS_IMETHOD GetGMPAudioDecoder(nsTArray<nsCString>* aTags,
|
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPAudioDecoderCallback>&& aCallback)
|
|
|
|
override;
|
2015-02-09 23:54:12 +03:00
|
|
|
NS_IMETHOD GetGMPDecryptor(nsTArray<nsCString>* aTags,
|
|
|
|
const nsACString& aNodeId,
|
2015-02-10 13:48:29 +03:00
|
|
|
UniquePtr<GetGMPDecryptorCallback>&& aCallback)
|
|
|
|
override;
|
2014-08-18 01:41:56 +04:00
|
|
|
|
2014-10-22 00:45:18 +04:00
|
|
|
int32_t AsyncShutdownTimeoutMs();
|
|
|
|
|
2015-03-26 09:55:30 +03:00
|
|
|
class PluginCrashCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(PluginCrashCallback)
|
|
|
|
|
|
|
|
PluginCrashCallback(const nsACString& aPluginId)
|
|
|
|
: mPluginId(aPluginId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
const nsACString& PluginId() const { return mPluginId; }
|
|
|
|
virtual void Run(const nsACString& aPluginName, const nsAString& aPluginDumpId) = 0;
|
|
|
|
virtual bool IsStillValid() = 0; // False if callback has become useless.
|
|
|
|
protected:
|
|
|
|
virtual ~PluginCrashCallback()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const nsCString mPluginId;
|
|
|
|
};
|
|
|
|
void RemoveObsoletePluginCrashCallbacks(); // Called from add/remove/run.
|
|
|
|
void AddPluginCrashCallback(nsRefPtr<PluginCrashCallback> aPluginCrashCallback);
|
|
|
|
void RemovePluginCrashCallbacks(const nsACString& aPluginId);
|
|
|
|
void RunPluginCrashCallbacks(const nsACString& aPluginId,
|
|
|
|
const nsACString& aPluginName,
|
|
|
|
const nsAString& aPluginDumpId);
|
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
protected:
|
|
|
|
GeckoMediaPluginService();
|
|
|
|
virtual ~GeckoMediaPluginService();
|
2014-10-21 05:53:30 +04:00
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
virtual void InitializePlugins() = 0;
|
2015-02-10 13:48:42 +03:00
|
|
|
virtual bool GetContentParentFrom(const nsACString& aNodeId,
|
|
|
|
const nsCString& aAPI,
|
|
|
|
const nsTArray<nsCString>& aTags,
|
|
|
|
UniquePtr<GetGMPContentParentCallback>&& aCallback) = 0;
|
2014-07-10 22:48:11 +04:00
|
|
|
|
2015-02-09 23:54:12 +03:00
|
|
|
nsresult GMPDispatch(nsIRunnable* event, uint32_t flags = NS_DISPATCH_NORMAL);
|
|
|
|
void ShutdownGMPThread();
|
2015-01-06 03:00:00 +03:00
|
|
|
|
2014-07-28 19:42:55 +04:00
|
|
|
protected:
|
2015-02-09 23:54:12 +03:00
|
|
|
Mutex mMutex; // Protects mGMPThread and mGMPThreadShutdown and some members
|
|
|
|
// in derived classes.
|
2014-05-18 07:05:46 +04:00
|
|
|
nsCOMPtr<nsIThread> mGMPThread;
|
2015-02-09 23:54:12 +03:00
|
|
|
bool mGMPThreadShutdown;
|
2014-05-18 07:05:46 +04:00
|
|
|
bool mShuttingDownOnGMPThread;
|
2014-08-18 01:41:56 +04:00
|
|
|
|
2015-03-26 09:55:30 +03:00
|
|
|
nsTArray<nsRefPtr<PluginCrashCallback>> mPluginCrashCallbacks;
|
2014-05-18 07:05:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPService_h_
|