Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
msoap authored and ZekeLu committed Apr 30, 2021
1 parent b2bbc05 commit 4a55e10
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ func NewBrowser(ctx context.Context, urlstr string, opts ...BrowserOption) (*Bro
return b, nil
}

// Process returns the process object of the browser.
// It could be nil when the browser is allocated with RemoteAllocator.
// It can be used to control the memory consumed by the browser process.
//
// Example:
// if process := chromedp.FromContext(ctx).Browser.Process(); process != nil {
// fmt.Printf("Browser PID: %v", process.Pid)
// }
func (b *Browser) Process() *os.Process {
return b.process
}

func (b *Browser) newExecutorForTarget(ctx context.Context, targetID target.ID, sessionID target.SessionID) (*Target, error) {
if targetID == "" {
return nil, errors.New("empty target ID")
Expand Down Expand Up @@ -310,15 +322,6 @@ func (b *Browser) run(ctx context.Context) {
}
}

// Process returns the Chrome process object
// Example:
// if process := chromedp.FromContext(ctx).Browser.Process(); process != nil {
// fmt.Printf("Chrome PID: %v", process.Pid)
// }
func (b *Browser) Process() *os.Process {
return b.process
}

// BrowserOption is a browser option.
type BrowserOption = func(*Browser)

Expand Down

0 comments on commit 4a55e10

Please sign in to comment.