2014-05-17 20:05:46 -07: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-10 20:35:56 -07:00
|
|
|
#include "nsString.h"
|
2014-05-17 20:05:46 -07:00
|
|
|
#include "mozIGeckoMediaPluginService.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIThread.h"
|
2014-07-10 11:48:11 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2014-05-17 20:05:46 -07:00
|
|
|
|
2014-06-17 07:57:23 -07:00
|
|
|
template <class> struct already_AddRefed;
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPParent;
|
|
|
|
|
|
|
|
class GeckoMediaPluginService MOZ_FINAL : public mozIGeckoMediaPluginService
|
|
|
|
, public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static already_AddRefed<GeckoMediaPluginService> GetGeckoMediaPluginService();
|
|
|
|
|
|
|
|
GeckoMediaPluginService();
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_MOZIGECKOMEDIAPLUGINSERVICE
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
private:
|
|
|
|
~GeckoMediaPluginService();
|
|
|
|
|
2014-06-29 16:02:39 -07:00
|
|
|
GMPParent* SelectPluginForAPI(const nsAString& aOrigin,
|
|
|
|
const nsCString& aAPI,
|
|
|
|
const nsTArray<nsCString>& aTags);
|
2014-07-10 11:48:11 -07:00
|
|
|
|
2014-05-17 20:05:46 -07:00
|
|
|
void UnloadPlugins();
|
|
|
|
|
2014-07-10 11:48:11 -07:00
|
|
|
void LoadFromEnvironment();
|
2014-05-17 20:05:46 -07:00
|
|
|
void ProcessPossiblePlugin(nsIFile* aDir);
|
2014-07-10 11:48:11 -07:00
|
|
|
|
|
|
|
void AddOnGMPThread(const nsAString& aSearchDir);
|
|
|
|
void RemoveOnGMPThread(const nsAString& aSearchDir);
|
|
|
|
|
|
|
|
class PathRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PathRunnable(GeckoMediaPluginService* service, const nsAString& path,
|
|
|
|
bool add)
|
|
|
|
: mService(service)
|
|
|
|
, mPath(path)
|
|
|
|
, mAdd(add)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<GeckoMediaPluginService> mService;
|
|
|
|
nsString mPath;
|
|
|
|
bool mAdd;
|
|
|
|
};
|
2014-05-17 20:05:46 -07:00
|
|
|
|
|
|
|
nsTArray<nsRefPtr<GMPParent>> mPlugins;
|
|
|
|
Mutex mMutex; // Protects mGMPThread and mShuttingDown
|
|
|
|
nsCOMPtr<nsIThread> mGMPThread;
|
|
|
|
bool mShuttingDown;
|
|
|
|
bool mShuttingDownOnGMPThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPService_h_
|