forked from asticode/go-astilectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.go
36 lines (30 loc) · 1.02 KB
/
session.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
package astilectron
import (
"context"
"github.com/asticode/go-astitools/context"
)
// Session event names
const (
EventNameSessionCmdClearCache = "session.cmd.clear.cache"
EventNameSessionEventClearedCache = "session.event.cleared.cache"
EventNameSessionEventWillDownload = "session.event.will.download"
)
// Session represents a session
// TODO Add missing session methods
// TODO Add missing session events
// https://github.com/electron/electron/blob/v1.8.1/docs/api/session.md
type Session struct {
*object
}
// newSession creates a new session
func newSession(parentCtx context.Context, c *asticontext.Canceller, d *dispatcher, i *identifier, w *writer) *Session {
return &Session{object: newObject(parentCtx, c, d, i, w, i.new())}
}
// ClearCache clears the Session's HTTP cache
func (s *Session) ClearCache() (err error) {
if err = s.isActionable(); err != nil {
return
}
_, err = synchronousEvent(s.c, s, s.w, Event{Name: EventNameSessionCmdClearCache, TargetID: s.id}, EventNameSessionEventClearedCache)
return
}