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

Side by Side Diff: chrome/test/automation/automation_proxy.cc

Issue 6685099: Removing command_execution_timeout_ms in favor of action_max_timeout_ms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/automation/automation_proxy.h ('k') | chrome/test/automation/browser_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/automation/automation_proxy.h" 5 #include "chrome/test/automation/automation_proxy.h"
6 6
7 #include <gtest/gtest.h> 7 #include <gtest/gtest.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 server_->SignalAppLaunch(server_version); 83 server_->SignalAppLaunch(server_version);
84 } 84 }
85 85
86 private: 86 private:
87 AutomationProxy* server_; 87 AutomationProxy* server_;
88 }; 88 };
89 89
90 } // anonymous namespace 90 } // anonymous namespace
91 91
92 92
93 AutomationProxy::AutomationProxy(int command_execution_timeout_ms, 93 AutomationProxy::AutomationProxy(int action_timeout_ms,
94 bool disconnect_on_failure) 94 bool disconnect_on_failure)
95 : app_launched_(true, false), 95 : app_launched_(true, false),
96 initial_loads_complete_(true, false), 96 initial_loads_complete_(true, false),
97 new_tab_ui_load_complete_(true, false), 97 new_tab_ui_load_complete_(true, false),
98 shutdown_event_(new base::WaitableEvent(true, false)), 98 shutdown_event_(new base::WaitableEvent(true, false)),
99 app_launch_signaled_(0), 99 app_launch_signaled_(0),
100 perform_version_check_(false), 100 perform_version_check_(false),
101 disconnect_on_failure_(disconnect_on_failure), 101 disconnect_on_failure_(disconnect_on_failure),
102 command_execution_timeout_( 102 action_timeout_(
103 TimeDelta::FromMilliseconds(command_execution_timeout_ms)), 103 TimeDelta::FromMilliseconds(action_timeout_ms)),
104 listener_thread_id_(0) { 104 listener_thread_id_(0) {
105 // base::WaitableEvent::TimedWait() will choke if we give it a negative value. 105 // base::WaitableEvent::TimedWait() will choke if we give it a negative value.
106 // Zero also seems unreasonable, since we need to wait for IPC, but at 106 // Zero also seems unreasonable, since we need to wait for IPC, but at
107 // least it is legal... ;-) 107 // least it is legal... ;-)
108 DCHECK_GE(command_execution_timeout_ms, 0); 108 DCHECK_GE(action_timeout_ms, 0);
109 listener_thread_id_ = base::PlatformThread::CurrentId(); 109 listener_thread_id_ = base::PlatformThread::CurrentId();
110 InitializeHandleTracker(); 110 InitializeHandleTracker();
111 InitializeThread(); 111 InitializeThread();
112 } 112 }
113 113
114 AutomationProxy::~AutomationProxy() { 114 AutomationProxy::~AutomationProxy() {
115 // Destruction order is important. Thread has to outlive the channel and 115 // Destruction order is important. Thread has to outlive the channel and
116 // tracker has to outlive the thread since we access the tracker inside 116 // tracker has to outlive the thread since we access the tracker inside
117 // AutomationMessageFilter::OnMessageReceived. 117 // AutomationMessageFilter::OnMessageReceived.
118 Disconnect(); 118 Disconnect();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 shutdown_event_.get())); 162 shutdown_event_.get()));
163 channel_->AddFilter(new AutomationMessageFilter(this)); 163 channel_->AddFilter(new AutomationMessageFilter(this));
164 } 164 }
165 165
166 void AutomationProxy::InitializeHandleTracker() { 166 void AutomationProxy::InitializeHandleTracker() {
167 tracker_.reset(new AutomationHandleTracker()); 167 tracker_.reset(new AutomationHandleTracker());
168 } 168 }
169 169
170 AutomationLaunchResult AutomationProxy::WaitForAppLaunch() { 170 AutomationLaunchResult AutomationProxy::WaitForAppLaunch() {
171 AutomationLaunchResult result = AUTOMATION_SUCCESS; 171 AutomationLaunchResult result = AUTOMATION_SUCCESS;
172 if (app_launched_.TimedWait(command_execution_timeout_)) { 172 if (app_launched_.TimedWait(action_timeout_)) {
173 if (perform_version_check_) { 173 if (perform_version_check_) {
174 // Obtain our own version number and compare it to what the automation 174 // Obtain our own version number and compare it to what the automation
175 // provider sent. 175 // provider sent.
176 chrome::VersionInfo version_info; 176 chrome::VersionInfo version_info;
177 DCHECK(version_info.is_valid()); 177 DCHECK(version_info.is_valid());
178 178
179 // Note that we use a simple string comparison since we expect the version 179 // Note that we use a simple string comparison since we expect the version
180 // to be a punctuated numeric string. Consider using base/Version if we 180 // to be a punctuated numeric string. Consider using base/Version if we
181 // ever need something more complicated here. 181 // ever need something more complicated here.
182 if (server_version_ != version_info.Version()) { 182 if (server_version_ != version_info.Version()) {
(...skipping 19 matching lines...) Expand all
202 } 202 }
203 server_version_ = version_string; 203 server_version_ = version_string;
204 app_launched_.Signal(); 204 app_launched_.Signal();
205 } 205 }
206 206
207 bool AutomationProxy::WaitForProcessLauncherThreadToGoIdle() { 207 bool AutomationProxy::WaitForProcessLauncherThreadToGoIdle() {
208 return Send(new AutomationMsg_WaitForProcessLauncherThreadToGoIdle()); 208 return Send(new AutomationMsg_WaitForProcessLauncherThreadToGoIdle());
209 } 209 }
210 210
211 bool AutomationProxy::WaitForInitialLoads() { 211 bool AutomationProxy::WaitForInitialLoads() {
212 return initial_loads_complete_.TimedWait(command_execution_timeout_); 212 return initial_loads_complete_.TimedWait(action_timeout_);
213 } 213 }
214 214
215 bool AutomationProxy::WaitForInitialNewTabUILoad(int* load_time) { 215 bool AutomationProxy::WaitForInitialNewTabUILoad(int* load_time) {
216 if (new_tab_ui_load_complete_.TimedWait(command_execution_timeout_)) { 216 if (new_tab_ui_load_complete_.TimedWait(action_timeout_)) {
217 *load_time = new_tab_ui_load_time_; 217 *load_time = new_tab_ui_load_time_;
218 new_tab_ui_load_complete_.Reset(); 218 new_tab_ui_load_complete_.Reset();
219 return true; 219 return true;
220 } 220 }
221 return false; 221 return false;
222 } 222 }
223 223
224 void AutomationProxy::SignalInitialLoads() { 224 void AutomationProxy::SignalInitialLoads() {
225 initial_loads_complete_.Signal(); 225 initial_loads_complete_.Signal();
226 } 226 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 base::file_handle_mapping_vector AutomationProxy::fds_to_map() const { 436 base::file_handle_mapping_vector AutomationProxy::fds_to_map() const {
437 base::file_handle_mapping_vector map; 437 base::file_handle_mapping_vector map;
438 const int ipcfd = channel_->GetClientFileDescriptor(); 438 const int ipcfd = channel_->GetClientFileDescriptor();
439 if (ipcfd > -1) 439 if (ipcfd > -1)
440 map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); 440 map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3));
441 return map; 441 return map;
442 } 442 }
443 #endif // defined(OS_POSIX) 443 #endif // defined(OS_POSIX)
444 444
445 bool AutomationProxy::Send(IPC::Message* message) { 445 bool AutomationProxy::Send(IPC::Message* message) {
446 return Send(message,
447 static_cast<int>(action_timeout_.InMilliseconds()));
448 }
449
450 bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) {
446 if (!channel_.get()) { 451 if (!channel_.get()) {
447 LOG(ERROR) << "Automation channel has been closed; dropping message!"; 452 LOG(ERROR) << "Automation channel has been closed; dropping message!";
448 delete message; 453 delete message;
449 return false; 454 return false;
450 } 455 }
451 456
452 bool success = channel_->SendWithTimeout(message, 457 bool success = channel_->SendWithTimeout(message, timeout_ms);
453 command_execution_timeout_ms());
454 458
455 if (!success && disconnect_on_failure_) { 459 if (!success && disconnect_on_failure_) {
456 // Send failed (possibly due to a timeout). Browser is likely in a weird 460 // Send failed (possibly due to a timeout). Browser is likely in a weird
457 // state, and further IPC requests are extremely likely to fail (possibly 461 // state, and further IPC requests are extremely likely to fail (possibly
458 // timeout, which would make tests slower). Disconnect the channel now 462 // timeout, which would make tests slower). Disconnect the channel now
459 // to avoid the slowness. 463 // to avoid the slowness.
460 LOG(ERROR) << "Disconnecting channel after error!"; 464 LOG(ERROR) << "Disconnecting channel after error!";
461 Disconnect(); 465 Disconnect();
462 } 466 }
463 467
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // If message sending unsuccessful or test failed, return false. 546 // If message sending unsuccessful or test failed, return false.
543 return sent && success; 547 return sent && success;
544 } 548 }
545 #endif 549 #endif
546 550
547 bool AutomationProxy::ResetToDefaultTheme() { 551 bool AutomationProxy::ResetToDefaultTheme() {
548 return Send(new AutomationMsg_ResetToDefaultTheme()); 552 return Send(new AutomationMsg_ResetToDefaultTheme());
549 } 553 }
550 554
551 bool AutomationProxy::SendJSONRequest(const std::string& request, 555 bool AutomationProxy::SendJSONRequest(const std::string& request,
556 int timeout_ms,
552 std::string* response) { 557 std::string* response) {
553 bool result = false; 558 bool result = false;
554 if (!SendAutomationJSONRequest(this, request, response, &result)) 559 if (!SendAutomationJSONRequest(this, request, timeout_ms, response, &result))
555 return false; 560 return false;
556 return result; 561 return result;
557 } 562 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy.h ('k') | chrome/test/automation/browser_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698