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

Side by Side Diff: chrome/test/chromedriver/util.h

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 #ifndef CHROME_TEST_CHROMEDRIVER_UTIL_H_ 5 #ifndef CHROME_TEST_CHROMEDRIVER_UTIL_H_
6 #define CHROME_TEST_CHROMEDRIVER_UTIL_H_ 6 #define CHROME_TEST_CHROMEDRIVER_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/time/time.h"
11
10 namespace base { 12 namespace base {
11 class FilePath; 13 class FilePath;
12 class ListValue; 14 class ListValue;
13 } 15 }
14 16
15 struct Session; 17 struct Session;
16 class Status; 18 class Status;
17 class WebView; 19 class WebView;
18 20
21 // A helper for tracking the time spent executing a task. Creating a new
22 // instance marks the beginning of the task. Task duration limit may be set
23 // in the contructor or at any time later, but only once.
24 class Timeout {
25 public:
26 Timeout();
27 explicit Timeout(const base::TimeDelta& duration);
28
29 // To be used when executing a sub-task with its own timeout, keeping track
30 // of the parent task timeout at the same time. Creates a new Timeout whose
31 // deadline is either Now() + |duration| or deadline of |outer|, whichever is
32 // smaller. |outer| may be nullptr. Note: setting duration on |outer| won't
33 // affect sub-timeouts that were created earlier!
34 Timeout(const base::TimeDelta& duration, const Timeout* outer);
35
36 // Sets the deadline by adding |duration| to the start time recored at
37 // contruction. Should not be called if the deadline is already set.
38 void SetDuration(const base::TimeDelta& duration);
39
40 bool is_set() const { return !deadline_.is_null(); }
41
42 // Whether the remaining time delta is less than or equal to zero.
43 bool IsExpired() const;
44
45 // Returns the duration if set, otherwise returns TimeDelta::Max().
46 base::TimeDelta GetDuration() const;
47
48 // Returns the remaining time if duration is set, otherwise returns
49 // TimeDelta::Max().
50 base::TimeDelta GetRemainingTime() const;
51
52 private:
53 base::TimeTicks start_;
54 base::TimeTicks deadline_;
55 };
56
19 // Generates a random, 32-character hexidecimal ID. 57 // Generates a random, 32-character hexidecimal ID.
20 std::string GenerateId(); 58 std::string GenerateId();
21 59
22 // Send a sequence of key strokes to the active Element in window. 60 // Send a sequence of key strokes to the active Element in window.
23 Status SendKeysOnWindow( 61 Status SendKeysOnWindow(
24 WebView* web_view, 62 WebView* web_view,
25 const base::ListValue* key_list, 63 const base::ListValue* key_list,
26 bool release_modifiers, 64 bool release_modifiers,
27 int* sticky_modifiers); 65 int* sticky_modifiers);
28 66
(...skipping 10 matching lines...) Expand all
39 Status UnzipSoleFile(const base::FilePath& unzip_dir, 77 Status UnzipSoleFile(const base::FilePath& unzip_dir,
40 const std::string& bytes, 78 const std::string& bytes,
41 base::FilePath* file); 79 base::FilePath* file);
42 80
43 // Calls BeforeCommand for each of |session|'s |CommandListener|s. 81 // Calls BeforeCommand for each of |session|'s |CommandListener|s.
44 // If an error is encountered, will mark |session| for deletion and return. 82 // If an error is encountered, will mark |session| for deletion and return.
45 Status NotifyCommandListenersBeforeCommand(Session* session, 83 Status NotifyCommandListenersBeforeCommand(Session* session,
46 const std::string& command_name); 84 const std::string& command_name);
47 85
48 #endif // CHROME_TEST_CHROMEDRIVER_UTIL_H_ 86 #endif // CHROME_TEST_CHROMEDRIVER_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698