/
raw_process.go
74 lines (67 loc) · 3.31 KB
/
raw_process.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package electron
import "github.com/oskca/gopherjs-nodejs/events"
import "github.com/gopherjs/gopherjs/js"
const (
// Emitted when Electron has loaded its internal initialization script and is beginning to load the web page or the main script. It can be used by the preload script to add removed Node global symbols back to the global scope when node integration is turned off:
EvtProcessLoaded = "loaded"
)
// ProcessModule version@1.4.15
//
// Extensions to process object.
type ProcessModule struct {
*events.Emitter
// Setting this to true can disable the support for asar archives in Node's built-in modules.
NoAsar string `js:"noAsar"`
// Current process's type, can be "browser" (i.e. main process) or "renderer".
Type string `js:"type"`
// Electron's version string.
Electron string `js:"electron"`
// Chrome's version string.
Chrome string `js:"chrome"`
// Path to the resources directory.
ResourcesPath string `js:"resourcesPath"`
// For Mac App Store build, this property is true, for other builds it is undefined.
Mas string `js:"mas"`
// If the app is running as a Windows Store app (appx), this property is true, for otherwise it is undefined.
WindowsStore string `js:"windowsStore"`
// When app is started by being passed as parameter to the default app, this property is true in the main process, otherwise it is undefined.
DefaultApp string `js:"defaultApp"`
// Causes the main thread of the current process crash.
Crash func() `js:"crash"`
// Causes the main thread of the current process hang.
Hang func() `js:"hang"`
// Sets the file descriptor soft limit to maxDescriptors or the OS hard limit, whichever is lower for the current process.
SetFdLimit func(MaxDescriptors int64) `js:"setFdLimit"`
// Returns an object giving memory usage statistics about the current process. Note that all statistics are reported in Kilobytes.
GetProcessMemoryInfo func() (Obj *ProcessModuleGetProcessMemoryInfoObj) `js:"getProcessMemoryInfo"`
// Returns an object giving memory usage statistics about the entire system. Note that all statistics are reported in Kilobytes.
GetSystemMemoryInfo func() (Obj *ProcessModuleGetSystemMemoryInfoObj) `js:"getSystemMemoryInfo"`
}
func GetProcessModule() *ProcessModule {
o := Get("process")
return &ProcessModule{
Emitter: events.New(o),
}
}
type ProcessModuleGetProcessMemoryInfoObj struct {
*js.Object
// The amount of memory currently pinned to actual physical RAM.
WorkingSetSize int64 `js:"workingSetSize"`
// The maximum amount of memory that has ever been pinned to actual physical RAM.
PeakWorkingSetSize int64 `js:"peakWorkingSetSize"`
// The amount of memory not shared by other processes, such as JS heap or HTML content.
PrivateBytes int64 `js:"privateBytes"`
// The amount of memory shared between processes, typically memory consumed by the Electron code itself
SharedBytes int64 `js:"sharedBytes"`
}
type ProcessModuleGetSystemMemoryInfoObj struct {
*js.Object
// The total amount of physical memory in Kilobytes available to the system.
Total int64 `js:"total"`
// The total amount of memory not being used by applications or disk cache.
Free int64 `js:"free"`
// The total amount of swap memory in Kilobytes available to the system.
SwapTotal int64 `js:"swapTotal"`
// The free amount of swap memory in Kilobytes available to the system.
SwapFree int64 `js:"swapFree"`
}