| OLD | NEW |
| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 | 426 |
| 427 scoped_refptr<BrowserProxy> AutomationProxy::GetLastActiveBrowserWindow() { | 427 scoped_refptr<BrowserProxy> AutomationProxy::GetLastActiveBrowserWindow() { |
| 428 int handle = 0; | 428 int handle = 0; |
| 429 if (!Send(new AutomationMsg_LastActiveBrowserWindow(&handle))) | 429 if (!Send(new AutomationMsg_LastActiveBrowserWindow(&handle))) |
| 430 return NULL; | 430 return NULL; |
| 431 | 431 |
| 432 return ProxyObjectFromHandle<BrowserProxy>(handle); | 432 return ProxyObjectFromHandle<BrowserProxy>(handle); |
| 433 } | 433 } |
| 434 | 434 |
| 435 #if defined(OS_POSIX) | 435 IPC::SyncChannel* AutomationProxy::channel() { |
| 436 base::file_handle_mapping_vector AutomationProxy::fds_to_map() const { | 436 return channel_.get(); |
| 437 base::file_handle_mapping_vector map; | |
| 438 const int ipcfd = channel_->GetClientFileDescriptor(); | |
| 439 if (ipcfd > -1) | |
| 440 map.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); | |
| 441 return map; | |
| 442 } | 437 } |
| 443 #endif // defined(OS_POSIX) | |
| 444 | 438 |
| 445 bool AutomationProxy::Send(IPC::Message* message) { | 439 bool AutomationProxy::Send(IPC::Message* message) { |
| 446 return Send(message, | 440 return Send(message, |
| 447 static_cast<int>(action_timeout_.InMilliseconds())); | 441 static_cast<int>(action_timeout_.InMilliseconds())); |
| 448 } | 442 } |
| 449 | 443 |
| 450 bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) { | 444 bool AutomationProxy::Send(IPC::Message* message, int timeout_ms) { |
| 451 if (!channel_.get()) { | 445 if (!channel_.get()) { |
| 452 LOG(ERROR) << "Automation channel has been closed; dropping message!"; | 446 LOG(ERROR) << "Automation channel has been closed; dropping message!"; |
| 453 delete message; | 447 delete message; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 547 } |
| 554 | 548 |
| 555 bool AutomationProxy::SendJSONRequest(const std::string& request, | 549 bool AutomationProxy::SendJSONRequest(const std::string& request, |
| 556 int timeout_ms, | 550 int timeout_ms, |
| 557 std::string* response) { | 551 std::string* response) { |
| 558 bool result = false; | 552 bool result = false; |
| 559 if (!SendAutomationJSONRequest(this, request, timeout_ms, response, &result)) | 553 if (!SendAutomationJSONRequest(this, request, timeout_ms, response, &result)) |
| 560 return false; | 554 return false; |
| 561 return result; | 555 return result; |
| 562 } | 556 } |
| OLD | NEW |