|
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 PROFILER_SAVETASK_H_ |
|
7 #define PROFILER_SAVETASK_H_ |
|
8 |
|
9 #include "platform.h" |
|
10 #include "nsThreadUtils.h" |
|
11 #include "nsIXULRuntime.h" |
|
12 #include "nsDirectoryServiceUtils.h" |
|
13 #include "nsDirectoryServiceDefs.h" |
|
14 #include "nsXULAppAPI.h" |
|
15 #include "nsIJSRuntimeService.h" |
|
16 #include "nsIProfileSaveEvent.h" |
|
17 |
|
18 #ifdef XP_WIN |
|
19 #include <windows.h> |
|
20 #define getpid GetCurrentProcessId |
|
21 #else |
|
22 #include <unistd.h> |
|
23 #endif |
|
24 |
|
25 /** |
|
26 * This is an event used to save the profile on the main thread |
|
27 * to be sure that it is not being modified while saving. |
|
28 */ |
|
29 class SaveProfileTask : public nsRunnable { |
|
30 public: |
|
31 SaveProfileTask() {} |
|
32 |
|
33 NS_IMETHOD Run(); |
|
34 }; |
|
35 |
|
36 class ProfileSaveEvent MOZ_FINAL : public nsIProfileSaveEvent { |
|
37 public: |
|
38 typedef void (*AddSubProfileFunc)(const char* aProfile, void* aClosure); |
|
39 NS_DECL_ISUPPORTS |
|
40 |
|
41 ProfileSaveEvent(AddSubProfileFunc aFunc, void* aClosure) |
|
42 : mFunc(aFunc) |
|
43 , mClosure(aClosure) |
|
44 {} |
|
45 |
|
46 ~ProfileSaveEvent() {} |
|
47 |
|
48 NS_IMETHOD AddSubProfile(const char* aProfile); |
|
49 private: |
|
50 AddSubProfileFunc mFunc; |
|
51 void* mClosure; |
|
52 }; |
|
53 |
|
54 #endif |
|
55 |