summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 04:32:57 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 04:32:57 +0000
commit295039bdf97f08bf5c1c1c136dd977b7e97ddd31 (patch)
treeae3b47308e7d2f2db903f6a61c193e7a8c9ec882 /chrome/test/automation
parent1c33790ef99bf8301260b9144110e71e7723d0f4 (diff)
downloadchromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.zip
chromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.tar.gz
chromium_src-295039bdf97f08bf5c1c1c136dd977b7e97ddd31.tar.bz2
Introduce MessagePump to represent the native message pump used to drive a
MessageLoop. A MessageLoop now has a MessagePump. This will make it possible to port the MessagePump interface to other platforms as well as to use an IO completion port for our worker threads on Windows. Currently, there is only MessagePumpWin, which attempts to preserve the pre-existing behavior of the MessageLoop. API changes to MessageLoop: 1. MessageLoop::Quit means return from Run when the MessageLoop would otherwise wait for more work. 2. MessageLoop::Quit can no longer be called outside the context of an active Run call. So, things like this: MessageLoop::current()->Quit(); MessageLoop::current()->Run(); are now: MessageLoop::current()->RunAllPending(); 3. MessageLoop::Quit can no longer be called from other threads. This means that PostTask(..., new MessageLoop::QuitTask()) must be used explicitly to Quit across thread boundaries. 4. No protection is made to deal with nested MessageLoops involving watched objects or APCs. In fact, an assertion is added to flag such cases. This is a temporary measure until object watching and APC facilities are removed in favor of a MessagePump designed around an IO completion port. As part of this CL, I also changed the automation system to use an IPC::ChannelProxy instead of an IPC::Channel. This moves the automation IPC onto Chrome's IO thread where it belongs. I also fixed some abuses of RefCounted in the AutomationProvider class. It was deleting itself in some cases! This led to having to fix the ownership model for AutomationProvider, which explains the changes to AutomationProviderList and so on. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_proxy.cc13
-rw-r--r--chrome/test/automation/automation_proxy.h8
2 files changed, 19 insertions, 2 deletions
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc
index 07e5387..6d98f0d 100644
--- a/chrome/test/automation/automation_proxy.cc
+++ b/chrome/test/automation/automation_proxy.cc
@@ -325,6 +325,10 @@ bool AutomationProxy::SetFilteredInet(bool enabled) {
return Send(new AutomationMsg_SetFilteredInet(0, enabled));
}
+void AutomationProxy::Disconnect() {
+ channel_.reset();
+}
+
void AutomationProxy::OnMessageReceived(const IPC::Message& msg) {
// This won't get called unless AutomationProxy is run from
// inside a message loop.
@@ -491,6 +495,15 @@ AutocompleteEditProxy* AutomationProxy::GetAutocompleteEditForBrowser(
autocomplete_edit_handle);
}
+bool AutomationProxy::Send(IPC::Message* message) {
+ if (channel_.get())
+ return channel_->Send(message);
+
+ DLOG(WARNING) << "Channel has been closed; dropping message!";
+ delete message;
+ return false;
+}
+
bool AutomationProxy::SendAndWaitForResponse(IPC::Message* request,
IPC::Message** response,
int response_type) {
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index e8d63b5..58ffbac 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -91,6 +91,9 @@ class AutomationProxy : public IPC::Channel::Listener,
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
+ // Close the automation IPC channel.
+ void Disconnect();
+
// Waits for the app to launch and the automation provider to say hello
// (the app isn't fully done loading by this point).
// Returns true if the launch is successful
@@ -188,7 +191,7 @@ class AutomationProxy : public IPC::Channel::Listener,
const std::wstring& channel_id() const { return channel_id_; }
// AutomationMessageSender implementations.
- virtual bool Send(IPC::Message* message) { return channel_->Send(message); }
+ virtual bool Send(IPC::Message* message);
virtual bool SendAndWaitForResponse(IPC::Message* request,
IPC::Message** response,
int response_type);
@@ -211,7 +214,8 @@ class AutomationProxy : public IPC::Channel::Listener,
// Creates a tab that can hosted in an external process. The function
// returns a TabProxy representing the tab as well as a window handle
// that can be reparented in another process.
- TabProxy* AutomationProxy::CreateExternalTab(HWND* external_tab_container);
+ TabProxy* CreateExternalTab(HWND* external_tab_container);
+
private:
DISALLOW_EVIL_CONSTRUCTORS(AutomationProxy);