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

Side by Side Diff: chrome/test/automation/javascript_execution_controller.h

Issue 10787010: Switch to TimeDelta interfaces in chrome automation test infrastructure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_ 5 #ifndef CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
6 #define CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_ 6 #define CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/test/automation/javascript_message_utils.h" 15 #include "chrome/test/automation/javascript_message_utils.h"
15 16
16 class JavaScriptObjectProxy; 17 class JavaScriptObjectProxy;
17 18
18 // This class handles the execution of arbitrary JavaScript, preparing it for 19 // This class handles the execution of arbitrary JavaScript, preparing it for
19 // execution, and parsing its result (in JSON). It keeps track of all returned 20 // execution, and parsing its result (in JSON). It keeps track of all returned
20 // JavaScript objects. 21 // JavaScript objects.
21 class JavaScriptExecutionController 22 class JavaScriptExecutionController
22 : public base::SupportsWeakPtr<JavaScriptExecutionController> { 23 : public base::SupportsWeakPtr<JavaScriptExecutionController> {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 FirstObjectAdded(); 65 FirstObjectAdded();
65 handle_to_object_.insert(std::make_pair(handle, obj)); 66 handle_to_object_.insert(std::make_pair(handle, obj));
66 } else { 67 } else {
67 obj = static_cast<JavaScriptObject*>(iter->second); 68 obj = static_cast<JavaScriptObject*>(iter->second);
68 } 69 }
69 return obj; 70 return obj;
70 } 71 }
71 72
72 // Sets a timeout to be used for all JavaScript methods in which a response 73 // Sets a timeout to be used for all JavaScript methods in which a response
73 // is returned asynchronously. 74 // is returned asynchronously.
74 static void set_timeout(int timeout_ms) { timeout_ms_ = timeout_ms; } 75 static void set_timeout(base::TimeDelta timeout) {
76 timeout_ms_ = timeout.InMilliseconds();
77 }
75 78
76 protected: 79 protected:
77 virtual ~JavaScriptExecutionController(); 80 virtual ~JavaScriptExecutionController();
78 81
79 // Executes |script| and sets the JSON response |json|. Returns true 82 // Executes |script| and sets the JSON response |json|. Returns true
80 // on success. 83 // on success.
81 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script, 84 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script,
82 std::string* json) = 0; 85 std::string* json) = 0;
83 86
84 // Called when this controller is tracking its first object. Used by 87 // Called when this controller is tracking its first object. Used by
(...skipping 28 matching lines...) Expand all
113 // Timeout to use for all asynchronous methods. 116 // Timeout to use for all asynchronous methods.
114 static int timeout_ms_; 117 static int timeout_ms_;
115 118
116 // Weak pointer to all the object proxies that we create. 119 // Weak pointer to all the object proxies that we create.
117 HandleToObjectMap handle_to_object_; 120 HandleToObjectMap handle_to_object_;
118 121
119 DISALLOW_COPY_AND_ASSIGN(JavaScriptExecutionController); 122 DISALLOW_COPY_AND_ASSIGN(JavaScriptExecutionController);
120 }; 123 };
121 124
122 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_ 125 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/dom_automation_browsertest.cc ('k') | chrome/test/automation/proxy_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698