v0.23.2 bfd5eb4

webkit_context.go RawHistoryFolder

1// Package port defines interfaces for external dependencies.
2package port
3
4import "context"
5
6// MemoryPressureConfig holds memory pressure settings for a WebKit process.
7// Zero values mean "use WebKit defaults".
8type MemoryPressureConfig struct {
9	// MemoryLimitMB sets the memory limit in megabytes.
10	// 0 means unset (uses WebKit default: system RAM capped at 3GB).
11	MemoryLimitMB int
12
13	// PollIntervalSec sets the interval for memory usage checks.
14	// 0 means unset (uses WebKit default: 30 seconds).
15	PollIntervalSec float64
16
17	// ConservativeThreshold sets threshold for conservative memory release.
18	// Must be in (0, 1). 0 means unset (uses WebKit default: 0.33).
19	ConservativeThreshold float64
20
21	// StrictThreshold sets threshold for strict memory release.
22	// Must be in (0, 1). 0 means unset (uses WebKit default: 0.5).
23	StrictThreshold float64
24}
25
26// IsConfigured returns true if any memory pressure setting is configured.
27func (c *MemoryPressureConfig) IsConfigured() bool {
28	if c == nil {
29		return false
30	}
31	return c.MemoryLimitMB > 0 ||
32		c.PollIntervalSec > 0 ||
33		c.ConservativeThreshold > 0 ||
34		c.StrictThreshold > 0
35}
36
37// WebKitContextOptions configures WebKitContext creation.
38type WebKitContextOptions struct {
39	// DataDir is the directory for persistent data (cookies, storage, etc.).
40	DataDir string
41
42	// CacheDir is the directory for cache data.
43	CacheDir string
44
45	// WebProcessMemory configures memory pressure for web processes.
46	// nil means use WebKit defaults.
47	WebProcessMemory *MemoryPressureConfig
48
49	// NetworkProcessMemory configures memory pressure for the network process.
50	// nil means use WebKit defaults.
51	NetworkProcessMemory *MemoryPressureConfig
52}
53
54// IsWebProcessMemoryConfigured returns true if web process memory settings are configured.
55func (o *WebKitContextOptions) IsWebProcessMemoryConfigured() bool {
56	if o == nil {
57		return false
58	}
59	return o.WebProcessMemory.IsConfigured()
60}
61
62// IsNetworkProcessMemoryConfigured returns true if network process memory settings are configured.
63func (o *WebKitContextOptions) IsNetworkProcessMemoryConfigured() bool {
64	if o == nil {
65		return false
66	}
67	return o.NetworkProcessMemory.IsConfigured()
68}
69
70// MemoryPressureApplier applies memory pressure settings to WebKit processes.
71// This interface abstracts the WebKit-specific memory pressure configuration
72// to allow testing without WebKit dependencies.
73type MemoryPressureApplier interface {
74	// ApplyNetworkProcessSettings applies memory pressure settings to the network process.
75	// Must be called BEFORE creating any NetworkSession.
76	ApplyNetworkProcessSettings(ctx context.Context, cfg *MemoryPressureConfig) error
77
78	// ApplyWebProcessSettings applies memory pressure settings to web processes.
79	// Returns an opaque settings object that should be passed to WebContext creation.
80	// Returns nil if no settings are configured.
81	ApplyWebProcessSettings(ctx context.Context, cfg *MemoryPressureConfig) (any, error)
82}
83
84// WebKitContextProvider creates and manages WebKit contexts.
85// This interface abstracts WebKit context creation for testability.
86type WebKitContextProvider interface {
87	// Initialize sets up the WebKit context with the given options.
88	// Must be called before any other methods.
89	Initialize(ctx context.Context, opts WebKitContextOptions) error
90
91	// DataDir returns the data directory path.
92	DataDir() string
93
94	// CacheDir returns the cache directory path.
95	CacheDir() string
96
97	// PrefetchDNS prefetches DNS for the given hostname.
98	PrefetchDNS(hostname string)
99
100	// Close releases resources held by the context.
101	Close() error
102}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close