mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
255bc818dc
Adds the IPDL layer to asynchronously retrieve in the parent process the performance counters. MozReview-Commit-ID: RbKstNx8pi --HG-- extra : rebase_source : d7c00f2ef16623dbbd88ede0f6636ca56501e151
131 lines
2.9 KiB
C++
131 lines
2.9 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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 mozilla_dom_workers_workerdebuggermanager_h
|
|
#define mozilla_dom_workers_workerdebuggermanager_h
|
|
|
|
#include "mozilla/dom/WorkerCommon.h"
|
|
|
|
#include "nsIObserver.h"
|
|
#include "nsIWorkerDebuggerManager.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "nsTArray.h"
|
|
#include "nsThreadUtils.h"
|
|
|
|
#define WORKERDEBUGGERMANAGER_CID \
|
|
{ 0x62ec8731, 0x55ad, 0x4246, \
|
|
{ 0xb2, 0xea, 0xf2, 0x6c, 0x1f, 0xe1, 0x9d, 0x2d } }
|
|
#define WORKERDEBUGGERMANAGER_CONTRACTID \
|
|
"@mozilla.org/dom/workers/workerdebuggermanager;1"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
class WorkerDebugger;
|
|
class WorkerPrivate;
|
|
|
|
class WorkerDebuggerManager final : public nsIObserver,
|
|
public nsIWorkerDebuggerManager
|
|
{
|
|
Mutex mMutex;
|
|
|
|
// Protected by mMutex.
|
|
nsTArray<nsCOMPtr<nsIWorkerDebuggerManagerListener>> mListeners;
|
|
|
|
// Only touched on the main thread.
|
|
nsTArray<RefPtr<WorkerDebugger>> mDebuggers;
|
|
|
|
public:
|
|
static already_AddRefed<WorkerDebuggerManager>
|
|
GetInstance();
|
|
|
|
static WorkerDebuggerManager*
|
|
GetOrCreate();
|
|
|
|
static WorkerDebuggerManager*
|
|
Get();
|
|
|
|
WorkerDebuggerManager();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIOBSERVER
|
|
NS_DECL_NSIWORKERDEBUGGERMANAGER
|
|
|
|
nsresult
|
|
Init();
|
|
|
|
void
|
|
Shutdown();
|
|
|
|
void
|
|
RegisterDebugger(WorkerPrivate* aWorkerPrivate);
|
|
|
|
void
|
|
RegisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate,
|
|
bool aNotifyListeners);
|
|
|
|
void
|
|
UnregisterDebugger(WorkerPrivate* aWorkerPrivate);
|
|
|
|
void
|
|
UnregisterDebuggerMainThread(WorkerPrivate* aWorkerPrivate);
|
|
|
|
uint32_t
|
|
GetDebuggersLength() const;
|
|
|
|
WorkerDebugger*
|
|
GetDebuggerAt(uint32_t aIndex) const;
|
|
|
|
private:
|
|
virtual ~WorkerDebuggerManager();
|
|
};
|
|
|
|
inline nsresult
|
|
RegisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
|
|
{
|
|
WorkerDebuggerManager* manager;
|
|
|
|
if (NS_IsMainThread()) {
|
|
manager = WorkerDebuggerManager::GetOrCreate();
|
|
if (!manager) {
|
|
NS_WARNING("Failed to create worker debugger manager!");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
else {
|
|
manager = WorkerDebuggerManager::Get();
|
|
}
|
|
|
|
manager->RegisterDebugger(aWorkerPrivate);
|
|
return NS_OK;
|
|
}
|
|
|
|
inline nsresult
|
|
UnregisterWorkerDebugger(WorkerPrivate* aWorkerPrivate)
|
|
{
|
|
WorkerDebuggerManager* manager;
|
|
|
|
if (NS_IsMainThread()) {
|
|
manager = WorkerDebuggerManager::GetOrCreate();
|
|
if (!manager) {
|
|
NS_WARNING("Failed to create worker debugger manager!");
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
else {
|
|
manager = WorkerDebuggerManager::Get();
|
|
}
|
|
|
|
manager->UnregisterDebugger(aWorkerPrivate);
|
|
return NS_OK;
|
|
}
|
|
|
|
} // dom namespace
|
|
} // mozilla namespace
|
|
|
|
#endif // mozilla_dom_workers_workerdebuggermanager_h
|