Bug 1632750 - profiler_get_controlled_chunk_manager - r=canaltinova

The Gecko Profiler can provide its current controlled chunk manager.
It is the responsibility of the caller to keep track of the state of the profiler, to avoid using the chunk manager after it's discarded.

Differential Revision: https://phabricator.services.mozilla.com/D72364
This commit is contained in:
Gerald Squelart 2020-05-08 03:34:30 +00:00
Родитель 3292ac76d9
Коммит f1439fbad0
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -961,6 +961,14 @@ class ActivePS {
PS_GET(const Vector<std::string>&, Filters)
// Not using PS_GET, because only the "Controlled" interface of
// `mProfileBufferChunkManager` should be exposed here.
static ProfileBufferControlledChunkManager& ControlledChunkManager(
PSLockRef) {
MOZ_ASSERT(sInstance);
return sInstance->mProfileBufferChunkManager;
}
static void FulfillChunkRequests(PSLockRef) {
MOZ_ASSERT(sInstance);
sInstance->mProfileBufferChunkManager.FulfillChunkRequests();
@ -3919,6 +3927,15 @@ void profiler_get_start_params(int* aCapacity, Maybe<double>* aDuration,
}
}
ProfileBufferControlledChunkManager* profiler_get_controlled_chunk_manager() {
MOZ_RELEASE_ASSERT(CorePS::Exists());
PSAutoLock lock(gPSMutex);
if (NS_WARN_IF(!ActivePS::Exists(lock))) {
return nullptr;
}
return &ActivePS::ControlledChunkManager(lock);
}
namespace mozilla {
void GetProfilerEnvVarsForChildProcess(

Просмотреть файл

@ -114,6 +114,7 @@ class ProfilerCodeAddressService;
class ProfilerMarkerPayload;
class SpliceableJSONWriter;
namespace mozilla {
class ProfileBufferControlledChunkManager;
namespace net {
struct TimingStruct;
enum CacheDisposition : uint8_t;
@ -546,6 +547,10 @@ void profiler_get_start_params(
mozilla::Vector<const char*, 0, mozilla::MallocAllocPolicy>* aFilters,
uint64_t* aActiveBrowsingContextID);
// Get the chunk manager used in the current profiling session, or null.
mozilla::ProfileBufferControlledChunkManager*
profiler_get_controlled_chunk_manager();
// The number of milliseconds since the process started. Operates the same
// whether the profiler is active or inactive.
double profiler_time();