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

Side by Side Diff: chrome/test/chromedriver/net/timeout.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: pure virtual Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/test/chromedriver/net/timeout.h"
6
7 #include <algorithm>
8
9 #include "base/logging.h"
10
11 Timeout::Timeout() : start_(base::TimeTicks::Now()) {
12 }
13
14 Timeout::Timeout(const base::TimeDelta& duration) : Timeout() {
15 SetDuration(duration);
16 }
17
18 Timeout::Timeout(const base::TimeDelta& duration, const Timeout* outer)
19 : Timeout(duration) {
20 if (outer && !outer->deadline_.is_null())
21 deadline_ = std::min(outer->deadline_, deadline_);
22 }
23
24 void Timeout::SetDuration(const base::TimeDelta& duration) {
25 DCHECK(!start_.is_null());
26 if (deadline_.is_null()) {
27 deadline_ = start_ + duration;
28 } else if (deadline_ - start_ != duration) {
29 LOG(ERROR) << "Timeout::SetDuration was called with a duration different"
30 " from what was already set: " << duration << " vs. "
31 << deadline_ - start_ << " (original).";
32 NOTREACHED();
33 }
34 }
35
36 bool Timeout::IsExpired() const {
37 return GetRemainingTime() <= base::TimeDelta();
38 }
39
40 base::TimeDelta Timeout::GetDuration() const {
41 return !deadline_.is_null() ? deadline_ - start_
42 : base::TimeDelta::Max();
43 }
44
45 base::TimeDelta Timeout::GetRemainingTime() const {
46 return !deadline_.is_null() ? deadline_ - base::TimeTicks::Now()
47 : base::TimeDelta::Max();
48 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/timeout.h ('k') | chrome/test/chromedriver/net/timeout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698