Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: headless/app/headless_shell.cc

Issue 2525903003: Add Page.stopLoading to devtools and --timeout switch to headless_shell (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
« no previous file with comments | « no previous file | headless/app/headless_shell_switches.h » ('j') | headless/lib/browser/headless_web_contents_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698