From 03f27a7db3f9b0ea13523c126e72d0561c235e9e Mon Sep 17 00:00:00 2001 From: "stoyan@chromium.org" Date: Mon, 11 May 2009 23:35:21 +0000 Subject: Remove AutomationRequest (deprecated by using SyncChannel). Some minor cleanup. Review URL: http://codereview.chromium.org/115210 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15813 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/automation/automation_proxy.cc | 65 ----------------------- chrome/test/automation/automation_proxy.h | 8 --- chrome/test/automation/automation_proxy_uitest.cc | 3 +- chrome/test/automation/tab_proxy.cc | 5 +- chrome/test/automation/tab_proxy.h | 3 +- 5 files changed, 4 insertions(+), 80 deletions(-) (limited to 'chrome/test/automation') diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index f005b92..0c50b4c 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -26,47 +26,6 @@ using base::TimeDelta; using base::TimeTicks; -// This class exists to group together the data and functionality used for -// synchronous automation requests. -class AutomationRequest - : public base::RefCountedThreadSafe { - public: - AutomationRequest() : received_response_(true, false) { - static int32 routing_id = 0; - routing_id_ = ++routing_id; - } - - // This is called on the background thread once the response has been - // received and the foreground thread can resume execution. - void SignalResponseReady(const IPC::Message& response) { - response_.reset(new IPC::Message(response)); - - received_response_.Signal(); - } - - // This can be used to take ownership of the response object that - // we've received, reducing the need to copy the message. - void GrabResponse(IPC::Message** response) { - DCHECK(response); - *response = response_.get(); - response_.release(); - } - - int32 routing_id() { return routing_id_; } - - const IPC::Message& response() { - DCHECK(response_.get()); - return *(response_.get()); - } - - private: - int32 routing_id_; - scoped_ptr response_; - base::WaitableEvent received_response_; - - DISALLOW_EVIL_CONSTRUCTORS(AutomationRequest); -}; - namespace { // This object allows messages received on the background thread to be @@ -78,28 +37,6 @@ class AutomationMessageFilter : public IPC::ChannelProxy::MessageFilter { // Return true to indicate that the message was handled, or false to let // the message be handled in the default way. virtual bool OnMessageReceived(const IPC::Message& message) { - { - // Here we're checking to see if it matches the (because there should - // be at most one) synchronous request. If the received message is - // the response to the synchronous request, we clear the server's - // "current_request" pointer and signal to the request object that - // the response is ready for processing. We're clearing current_request - // here rather than on the foreground thread so that we can assert - // that both threads perceive it as cleared at the time that the - // foreground thread wakes up. - scoped_refptr request = server_->current_request(); - if (request.get() && (message.routing_id() == request->routing_id())) { - server_->clear_current_request(); - request->SignalResponseReady(message); - return true; - } - if (message.routing_id() > 0) { - // The message is either the previous async response or arrived - // after timeout. - return true; - } - } - bool handled = true; IPC_BEGIN_MESSAGE_MAP(AutomationMessageFilter, message) @@ -146,7 +83,6 @@ AutomationProxy::AutomationProxy(int command_execution_timeout_ms) initial_loads_complete_(true, false), new_tab_ui_load_complete_(true, false), shutdown_event_(new base::WaitableEvent(true, false)), - current_request_(NULL), app_launch_signaled_(0), perform_version_check_(false), command_execution_timeout_( @@ -165,7 +101,6 @@ AutomationProxy::~AutomationProxy() { // AutomationMessageFilter::OnMessageReceived. channel_.reset(); thread_.reset(); - DCHECK(NULL == current_request_); tracker_.reset(); } diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index fca1078..abe4334 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -20,7 +20,6 @@ #include "chrome/test/automation/automation_handle_tracker.h" #include "chrome/test/automation/automation_messages.h" -class AutomationRequest; class BrowserProxy; class TabProxy; class WindowProxy; @@ -172,11 +171,6 @@ class AutomationProxy : public IPC::Channel::Listener, virtual bool SendWithTimeout(IPC::Message* message, int timeout, bool* is_timeout); - // Returns the current AutomationRequest object. - AutomationRequest* current_request() { return current_request_; } - // Clears the current AutomationRequest object. - void clear_current_request() { current_request_ = NULL; } - // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the // message from AutomationProxy, unpacks the messages and routes that call to // the tracker. @@ -230,8 +224,6 @@ class AutomationProxy : public IPC::Channel::Listener, // An event that notifies when we are shutting-down. scoped_ptr shutdown_event_; - AutomationRequest* current_request_; - // The version of the automation provider we are communicating with. std::string server_version_; diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index a2f8232..7d62a76 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -961,8 +961,7 @@ TEST_F(ExternalTabTestType, ExternalTabPostMessage) { tab->NavigateInExternalTab(GURL(content)); EXPECT_TRUE(proxy->WaitForNavigationComplete(10000)); - tab->HandleMessageFromExternalHost(tab->handle(), "Hello from gtest", - "null", "*"); + tab->HandleMessageFromExternalHost("Hello from gtest", "null", "*"); EXPECT_TRUE(ExternalTabHandler(external_tab_container, 10000)); EXPECT_NE(0, proxy->messages_received()); diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 811f926..2b27e0d 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -547,15 +547,14 @@ bool TabProxy::SavePage(const std::wstring& file_name, return succeeded; } -void TabProxy::HandleMessageFromExternalHost(AutomationHandle handle, - const std::string& message, +void TabProxy::HandleMessageFromExternalHost(const std::string& message, const std::string& origin, const std::string& target) { if (!is_valid()) return; bool succeeded = - sender_->Send(new AutomationMsg_HandleMessageFromExternalHost(0, handle, + sender_->Send(new AutomationMsg_HandleMessageFromExternalHost(0, handle_, message, origin, target)); DCHECK(succeeded); } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 86f8149..8f071bb 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -255,8 +255,7 @@ class TabProxy : public AutomationResourceProxy { SavePackage::SavePackageType type); // Posts a message to the external tab. - void HandleMessageFromExternalHost(AutomationHandle handle, - const std::string& message, + void HandleMessageFromExternalHost(const std::string& message, const std::string& origin, const std::string& target); -- cgit v1.1