1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ChildProfilerController_h
7 #define ChildProfilerController_h
9 #include "base/process.h"
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ipc/ProtocolUtils.h"
12 #include "mozilla/DataMutex.h"
13 #include "mozilla/RefPtr.h"
14 #include "nsISupportsImpl.h"
15 #include "nsStringFwd.h"
16 #include "ProfileAdditionalInformation.h"
22 class PProfilerParent
;
24 // ChildProfilerController manages the setup and teardown of ProfilerChild.
25 // It's used on the main thread.
26 // It manages a background thread that ProfilerChild runs on.
27 class ChildProfilerController final
{
29 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChildProfilerController
)
31 #ifdef MOZ_GECKO_PROFILER
32 static already_AddRefed
<ChildProfilerController
> Create(
33 mozilla::ipc::Endpoint
<PProfilerChild
>&& aEndpoint
);
35 [[nodiscard
]] ProfileAndAdditionalInformation
36 GrabShutdownProfileAndShutdown();
40 ChildProfilerController();
41 ~ChildProfilerController();
42 void Init(mozilla::ipc::Endpoint
<PProfilerChild
>&& aEndpoint
);
43 void ShutdownAndMaybeGrabShutdownProfileFirst(
44 ProfileAndAdditionalInformation
* aOutShutdownProfileInformation
);
47 void SetupProfilerChild(mozilla::ipc::Endpoint
<PProfilerChild
>&& aEndpoint
);
48 void ShutdownProfilerChild(
49 ProfileAndAdditionalInformation
* aOutShutdownProfileInformation
);
51 RefPtr
<ProfilerChild
> mProfilerChild
; // only accessed on mThread
52 DataMutex
<RefPtr
<nsIThread
>> mThread
;
54 static already_AddRefed
<ChildProfilerController
> Create(
55 mozilla::ipc::Endpoint
<PProfilerChild
>&& aEndpoint
) {
58 [[nodiscard
]] ProfileAndAdditionalInformation
59 GrabShutdownProfileAndShutdown() {
60 return ProfileAndAdditionalInformation(std::move(EmptyCString()));
65 ~ChildProfilerController() {}
66 #endif // MOZ_GECKO_PROFILER
69 } // namespace mozilla
71 #endif // ChildProfilerController_h