backgroundservice.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // Package backgroundservice provides the Chrome DevTools Protocol
  2. // commands, types, and events for the BackgroundService domain.
  3. //
  4. // Defines events for background web platform features.
  5. //
  6. // Generated by the cdproto-gen command.
  7. package backgroundservice
  8. // Code generated by cdproto-gen. DO NOT EDIT.
  9. import (
  10. "context"
  11. "github.com/chromedp/cdproto/cdp"
  12. )
  13. // StartObservingParams enables event updates for the service.
  14. type StartObservingParams struct {
  15. Service ServiceName `json:"service"`
  16. }
  17. // StartObserving enables event updates for the service.
  18. //
  19. // See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#method-startObserving
  20. //
  21. // parameters:
  22. //
  23. // service
  24. func StartObserving(service ServiceName) *StartObservingParams {
  25. return &StartObservingParams{
  26. Service: service,
  27. }
  28. }
  29. // Do executes BackgroundService.startObserving against the provided context.
  30. func (p *StartObservingParams) Do(ctx context.Context) (err error) {
  31. return cdp.Execute(ctx, CommandStartObserving, p, nil)
  32. }
  33. // StopObservingParams disables event updates for the service.
  34. type StopObservingParams struct {
  35. Service ServiceName `json:"service"`
  36. }
  37. // StopObserving disables event updates for the service.
  38. //
  39. // See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#method-stopObserving
  40. //
  41. // parameters:
  42. //
  43. // service
  44. func StopObserving(service ServiceName) *StopObservingParams {
  45. return &StopObservingParams{
  46. Service: service,
  47. }
  48. }
  49. // Do executes BackgroundService.stopObserving against the provided context.
  50. func (p *StopObservingParams) Do(ctx context.Context) (err error) {
  51. return cdp.Execute(ctx, CommandStopObserving, p, nil)
  52. }
  53. // SetRecordingParams set the recording state for the service.
  54. type SetRecordingParams struct {
  55. ShouldRecord bool `json:"shouldRecord"`
  56. Service ServiceName `json:"service"`
  57. }
  58. // SetRecording set the recording state for the service.
  59. //
  60. // See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#method-setRecording
  61. //
  62. // parameters:
  63. //
  64. // shouldRecord
  65. // service
  66. func SetRecording(shouldRecord bool, service ServiceName) *SetRecordingParams {
  67. return &SetRecordingParams{
  68. ShouldRecord: shouldRecord,
  69. Service: service,
  70. }
  71. }
  72. // Do executes BackgroundService.setRecording against the provided context.
  73. func (p *SetRecordingParams) Do(ctx context.Context) (err error) {
  74. return cdp.Execute(ctx, CommandSetRecording, p, nil)
  75. }
  76. // ClearEventsParams clears all stored data for the service.
  77. type ClearEventsParams struct {
  78. Service ServiceName `json:"service"`
  79. }
  80. // ClearEvents clears all stored data for the service.
  81. //
  82. // See: https://chromedevtools.github.io/devtools-protocol/tot/BackgroundService#method-clearEvents
  83. //
  84. // parameters:
  85. //
  86. // service
  87. func ClearEvents(service ServiceName) *ClearEventsParams {
  88. return &ClearEventsParams{
  89. Service: service,
  90. }
  91. }
  92. // Do executes BackgroundService.clearEvents against the provided context.
  93. func (p *ClearEventsParams) Do(ctx context.Context) (err error) {
  94. return cdp.Execute(ctx, CommandClearEvents, p, nil)
  95. }
  96. // Command names.
  97. const (
  98. CommandStartObserving = "BackgroundService.startObserving"
  99. CommandStopObserving = "BackgroundService.stopObserving"
  100. CommandSetRecording = "BackgroundService.setRecording"
  101. CommandClearEvents = "BackgroundService.clearEvents"
  102. )