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

Side by Side 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, 10 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/chromedriver/util.h" 5 #include "chrome/test/chromedriver/util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/test/chromedriver/chrome/browser_info.h" 22 #include "chrome/test/chromedriver/chrome/browser_info.h"
23 #include "chrome/test/chromedriver/chrome/chrome.h" 23 #include "chrome/test/chromedriver/chrome/chrome.h"
24 #include "chrome/test/chromedriver/chrome/status.h" 24 #include "chrome/test/chromedriver/chrome/status.h"
25 #include "chrome/test/chromedriver/chrome/ui_events.h" 25 #include "chrome/test/chromedriver/chrome/ui_events.h"
26 #include "chrome/test/chromedriver/chrome/web_view.h" 26 #include "chrome/test/chromedriver/chrome/web_view.h"
27 #include "chrome/test/chromedriver/command_listener.h" 27 #include "chrome/test/chromedriver/command_listener.h"
28 #include "chrome/test/chromedriver/key_converter.h" 28 #include "chrome/test/chromedriver/key_converter.h"
29 #include "chrome/test/chromedriver/session.h" 29 #include "chrome/test/chromedriver/session.h"
30 #include "third_party/zlib/google/zip.h" 30 #include "third_party/zlib/google/zip.h"
31 31
32 Timeout::Timeout() : start_(base::TimeTicks::Now()) {
33 }
34
35 Timeout::Timeout(const base::TimeDelta& duration) : Timeout() {
36 SetDuration(duration);
37 }
38
39 Timeout::Timeout(const base::TimeDelta& duration, const Timeout* outer)
40 : Timeout(duration) {
41 if (outer && !outer->deadline_.is_null())
42 deadline_ = std::min(outer->deadline_, deadline_);
43 }
44
45 void Timeout::SetDuration(const base::TimeDelta& duration) {
46 DCHECK(!start_.is_null());
47 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.
48 deadline_ = start_ + duration;
49 }
50
51 bool Timeout::IsExpired() const {
52 return GetRemainingTime() <= base::TimeDelta();
53 }
54
55 base::TimeDelta Timeout::GetDuration() const {
56 return !deadline_.is_null() ? deadline_ - start_
57 : base::TimeDelta::Max();
58 }
59
60 base::TimeDelta Timeout::GetRemainingTime() const {
61 return !deadline_.is_null() ? deadline_ - base::TimeTicks::Now()
62 : base::TimeDelta::Max();
63 }
64
32 std::string GenerateId() { 65 std::string GenerateId() {
33 uint64_t msb = base::RandUint64(); 66 uint64_t msb = base::RandUint64();
34 uint64_t lsb = base::RandUint64(); 67 uint64_t lsb = base::RandUint64();
35 return base::StringPrintf("%016" PRIx64 "%016" PRIx64, msb, lsb); 68 return base::StringPrintf("%016" PRIx64 "%016" PRIx64, msb, lsb);
36 } 69 }
37 70
38 namespace { 71 namespace {
39 72
40 Status FlattenStringArray(const base::ListValue* src, base::string16* dest) { 73 Status FlattenStringArray(const base::ListValue* src, base::string16* dest) {
41 base::string16 keys; 74 base::string16 keys;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (session->chrome) { 460 if (session->chrome) {
428 const BrowserInfo* browser_info = session->chrome->GetBrowserInfo(); 461 const BrowserInfo* browser_info = session->chrome->GetBrowserInfo();
429 status.AddDetails("Session info: " + browser_info->browser_name + "=" + 462 status.AddDetails("Session info: " + browser_info->browser_name + "=" +
430 browser_info->browser_version); 463 browser_info->browser_version);
431 } 464 }
432 return status; 465 return status;
433 } 466 }
434 } 467 }
435 return Status(kOk); 468 return Status(kOk);
436 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698