| OLD | NEW |
| 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 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 FirstObjectAdded(); | 64 FirstObjectAdded(); |
| 65 handle_to_object_.insert(std::make_pair(handle, obj)); | 65 handle_to_object_.insert(std::make_pair(handle, obj)); |
| 66 } else { | 66 } else { |
| 67 obj = static_cast<JavaScriptObject*>(iter->second); | 67 obj = static_cast<JavaScriptObject*>(iter->second); |
| 68 } | 68 } |
| 69 return obj; | 69 return obj; |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Sets a timeout to be used for all JavaScript methods in which a response | 72 // Sets a timeout to be used for all JavaScript methods in which a response |
| 73 // is returned asynchronously. | 73 // is returned asynchronously. |
| 74 static void set_timeout(int timeout_ms) { timeout_ms_ = timeout_ms; } | 74 static void set_timeout(base::TimeDelta timeout) { |
| 75 timeout_ms_ = timeout.InMilliseconds(); |
| 76 } |
| 75 | 77 |
| 76 protected: | 78 protected: |
| 77 virtual ~JavaScriptExecutionController(); | 79 virtual ~JavaScriptExecutionController(); |
| 78 | 80 |
| 79 // Executes |script| and sets the JSON response |json|. Returns true | 81 // Executes |script| and sets the JSON response |json|. Returns true |
| 80 // on success. | 82 // on success. |
| 81 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script, | 83 virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script, |
| 82 std::string* json) = 0; | 84 std::string* json) = 0; |
| 83 | 85 |
| 84 // Called when this controller is tracking its first object. Used by | 86 // Called when this controller is tracking its first object. Used by |
| (...skipping 28 matching lines...) Expand all Loading... |
| 113 // Timeout to use for all asynchronous methods. | 115 // Timeout to use for all asynchronous methods. |
| 114 static int timeout_ms_; | 116 static int timeout_ms_; |
| 115 | 117 |
| 116 // Weak pointer to all the object proxies that we create. | 118 // Weak pointer to all the object proxies that we create. |
| 117 HandleToObjectMap handle_to_object_; | 119 HandleToObjectMap handle_to_object_; |
| 118 | 120 |
| 119 DISALLOW_COPY_AND_ASSIGN(JavaScriptExecutionController); | 121 DISALLOW_COPY_AND_ASSIGN(JavaScriptExecutionController); |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_ | 124 #endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_ |
| OLD | NEW |