forked from asticode/go-astilectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession.go
34 lines (29 loc) · 957 Bytes
/
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
package astilectron
import (
"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(ctx context.Context, d *dispatcher, i *identifier, w *writer) *Session {
return &Session{object: newObject(ctx, d, i, w, i.new())}
}
// ClearCache clears the Session's HTTP cache
func (s *Session) ClearCache() (err error) {
if err = s.ctx.Err(); err != nil {
return
}
_, err = synchronousEvent(s.ctx, s, s.w, Event{Name: EventNameSessionCmdClearCache, TargetID: s.id}, EventNameSessionEventClearedCache)
return
}