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

Unified Diff: chrome/test/chromedriver/util.cc

Issue 1669453002: [chromedriver] Apply page load timeout to slow cross-process navigations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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: chrome/test/chromedriver/util.cc
diff --git a/chrome/test/chromedriver/util.cc b/chrome/test/chromedriver/util.cc
index 8c59bfea8ff0104a46ef777b928b54b2534cd1b5..ca176c2df2f7fa3663f506f4f2f94a565458397d 100644
--- a/chrome/test/chromedriver/util.cc
+++ b/chrome/test/chromedriver/util.cc
@@ -29,6 +29,39 @@
#include "chrome/test/chromedriver/session.h"
#include "third_party/zlib/google/zip.h"
+Timeout::Timeout() : start_(base::TimeTicks::Now()) {
+}
+
+Timeout::Timeout(const base::TimeDelta& duration) : Timeout() {
+ SetDuration(duration);
+}
+
+Timeout::Timeout(const base::TimeDelta& duration, const Timeout* outer)
+ : Timeout(duration) {
+ if (outer && !outer->deadline_.is_null())
+ deadline_ = std::min(outer->deadline_, deadline_);
+}
+
+void Timeout::SetDuration(const base::TimeDelta& duration) {
+ DCHECK(!start_.is_null());
+ DCHECK(deadline_.is_null());
samuong 2016/02/19 20:18:57 ChromeDriver is a bit different from Chrome in tha
Alexander Semashko 2016/02/19 23:38:58 Yeah, I put DCHECKs here hoping they'll be hit in
samuong 2016/02/20 00:11:44 For the C++ unit tests, they'll get built differen
Alexander Semashko 2016/02/24 12:51:20 Done.
+ deadline_ = start_ + duration;
+}
+
+bool Timeout::IsExpired() const {
+ return GetRemainingTime() <= base::TimeDelta();
+}
+
+base::TimeDelta Timeout::GetDuration() const {
+ return !deadline_.is_null() ? deadline_ - start_
+ : base::TimeDelta::Max();
+}
+
+base::TimeDelta Timeout::GetRemainingTime() const {
+ return !deadline_.is_null() ? deadline_ - base::TimeTicks::Now()
+ : base::TimeDelta::Max();
+}
+
std::string GenerateId() {
uint64_t msb = base::RandUint64();
uint64_t lsb = base::RandUint64();

Powered by Google App Engine
This is Rietveld 408576698