feat: define browser domain and application contracts

This commit is contained in:
QiuSW
2026-07-22 14:53:39 +08:00
parent f8aaaeda21
commit a5260496f3
7 changed files with 255 additions and 30 deletions
+55
View File
@@ -0,0 +1,55 @@
package application
import (
"context"
"time"
"chub/internal/domain"
)
type BrowserManager interface {
Start(context.Context, domain.LaunchSpec) (domain.InstanceView, error)
List(context.Context) ([]domain.InstanceView, error)
Get(context.Context, string) (domain.InstanceView, error)
Stop(context.Context, string, bool) error
Restart(context.Context, string) (domain.InstanceView, error)
}
type EventSink func(domain.BrowserEvent)
type ProcessHandle interface {
PID() int
Wait(context.Context) (int, error)
}
type ProcessLauncher interface {
Start(context.Context, domain.LaunchSpec) (ProcessHandle, error)
}
type ExecutableResolver interface {
Resolve(context.Context, domain.BrowserKind, string) (string, error)
}
type ProcessIdentity struct {
PID int
Executable string
CommandLine string
UserDataDir string
}
type ProcessInspector interface {
Inspect(context.Context, int) (ProcessIdentity, error)
Alive(context.Context, int) (bool, error)
}
type ProfileUse struct {
Occupied bool
PID int
Source string
}
type ProfileInspector interface {
Inspect(context.Context, string) (ProfileUse, error)
}
type Clock func() time.Time