Chromium Code Reviews| Index: headless/app/headless_shell.cc |
| diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc |
| index 8fc623abf91cd12c407398d651476430973552a6..16dbb448e61d6fb411b0786411ace275c69b18c9 100644 |
| --- a/headless/app/headless_shell.cc |
| +++ b/headless/app/headless_shell.cc |
| @@ -163,9 +163,28 @@ class HeadlessShell : public HeadlessWebContents::Observer, |
| } else { |
| PollReadyState(); |
| } |
| + |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTimeout)) { |
| + std::string timeout_ms_ascii = |
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kTimeout); |
| + int timeout_ms; |
| + CHECK(base::StringToInt(timeout_ms_ascii, &timeout_ms)) |
| + << "Expected an integer value for --timeout="; |
| + browser_->BrowserMainThread()->PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&HeadlessShell::FetchTimeout, base::Unretained(this)), |
|
Sami
2016/11/23 18:11:32
Should we use a weak pointer here? Nothing seems t
alex clarke (OOO till 29th)
2016/11/24 12:05:04
Done.
|
| + base::TimeDelta::FromMilliseconds(timeout_ms)); |
| + } |
| + |
| // TODO(skyostil): Implement more features to demonstrate the devtools API. |
| } |
| + void FetchTimeout() { |
| + LOG(INFO) << "Timeout."; |
| + web_contents_->Stop(); |
| + } |
| + |
| void OnTargetCrashed(const inspector::TargetCrashedParams& params) override { |
| LOG(ERROR) << "Abnormal renderer termination."; |
| // NB this never gets called if remote debugging is enabled. |