OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 base::file_handle_mapping_vector AutomationProxy::fds_to_map() const { | 441 base::file_handle_mapping_vector AutomationProxy::fds_to_map() const { |
442 base::file_handle_mapping_vector map; | 442 base::file_handle_mapping_vector map; |
443 const int ipcfd = channel_->GetClientFileDescriptor(); | 443 const int ipcfd = channel_->GetClientFileDescriptor(); |
444 if (ipcfd > -1) | 444 if (ipcfd > -1) |
445 map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); | 445 map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); |
446 return map; | 446 return map; |
447 } | 447 } |
448 #endif // defined(OS_POSIX) | 448 #endif // defined(OS_POSIX) |
449 | 449 |
450 bool AutomationProxy::Send(IPC::Message* message) { | 450 bool AutomationProxy::Send(IPC::Message* message) { |
451 return Send(message, | |
452 AutomationProxy::command_execution_timeout_.InMilliseconds()); | |
Paweł Hajdan Jr.
2011/03/19 10:21:34
nit: We're in AutomationProxy, there is no need fo
| |
453 } | |
454 | |
455 bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) { | |
451 if (!channel_.get()) { | 456 if (!channel_.get()) { |
452 LOG(ERROR) << "Automation channel has been closed; dropping message!"; | 457 LOG(ERROR) << "Automation channel has been closed; dropping message!"; |
453 delete message; | 458 delete message; |
454 return false; | 459 return false; |
455 } | 460 } |
456 | 461 |
457 bool success = channel_->SendWithTimeout(message, | 462 bool success = channel_->SendWithTimeout(message, timeout_ms); |
458 command_execution_timeout_ms()); | |
459 | 463 |
460 if (!success && disconnect_on_failure_) { | 464 if (!success && disconnect_on_failure_) { |
461 // Send failed (possibly due to a timeout). Browser is likely in a weird | 465 // Send failed (possibly due to a timeout). Browser is likely in a weird |
462 // state, and further IPC requests are extremely likely to fail (possibly | 466 // state, and further IPC requests are extremely likely to fail (possibly |
463 // timeout, which would make tests slower). Disconnect the channel now | 467 // timeout, which would make tests slower). Disconnect the channel now |
464 // to avoid the slowness. | 468 // to avoid the slowness. |
465 LOG(ERROR) << "Disconnecting channel after error!"; | 469 LOG(ERROR) << "Disconnecting channel after error!"; |
466 Disconnect(); | 470 Disconnect(); |
467 } | 471 } |
468 | 472 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 return Send(new AutomationMsg_ResetToDefaultTheme()); | 557 return Send(new AutomationMsg_ResetToDefaultTheme()); |
554 } | 558 } |
555 | 559 |
556 bool AutomationProxy::SendJSONRequest(const std::string& request, | 560 bool AutomationProxy::SendJSONRequest(const std::string& request, |
557 std::string* response) { | 561 std::string* response) { |
558 bool result = false; | 562 bool result = false; |
559 if (!SendAutomationJSONRequest(this, request, response, &result)) | 563 if (!SendAutomationJSONRequest(this, request, response, &result)) |
560 return false; | 564 return false; |
561 return result; | 565 return result; |
562 } | 566 } |
OLD | NEW |