Line data Source code
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/. */
5 :
6 : #ifndef ChildProfilerController_h
7 : #define ChildProfilerController_h
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "mozilla/RefPtr.h"
11 : #include "base/process.h"
12 :
13 : class nsCString;
14 :
15 : namespace mozilla {
16 :
17 : class ProfilerChild;
18 : class PProfilerChild;
19 : class PProfilerParent;
20 :
21 : // ChildProfilerController manages the setup and teardown of ProfilerChild.
22 : // It's used on the main thread.
23 : // It manages a background thread that ProfilerChild runs on.
24 : class ChildProfilerController final
25 : {
26 : public:
27 6 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChildProfilerController)
28 :
29 : static already_AddRefed<ChildProfilerController>
30 : Create(mozilla::ipc::Endpoint<PProfilerChild>&& aEndpoint);
31 :
32 : MOZ_MUST_USE nsCString GrabShutdownProfileAndShutdown();
33 : void Shutdown();
34 :
35 : private:
36 : ChildProfilerController();
37 : ~ChildProfilerController();
38 : void Init(mozilla::ipc::Endpoint<PProfilerChild>&& aEndpoint);
39 : void ShutdownAndMaybeGrabShutdownProfileFirst(nsCString* aOutShutdownProfile);
40 :
41 : // Called on mThread:
42 : void SetupProfilerChild(mozilla::ipc::Endpoint<PProfilerChild>&& aEndpoint);
43 : void ShutdownProfilerChild(nsCString* aOutShutdownProfile);
44 :
45 : RefPtr<ProfilerChild> mProfilerChild; // only accessed on mThread
46 : RefPtr<nsIThread> mThread;
47 : };
48 :
49 : } // namespace mozilla
50 :
51 : #endif // ChildProfilerController_h
|