summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 09:55:58 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-31 09:55:58 +0000
commit1e927691dcc9f65d82aafc0f89af086048b945f3 (patch)
tree0469878b25e6aac0716f18f6f6e9857dac71cfd4
parentd4a952f4cfa17e705d601761b7c4e10217915554 (diff)
downloadchromium_src-1e927691dcc9f65d82aafc0f89af086048b945f3.zip
chromium_src-1e927691dcc9f65d82aafc0f89af086048b945f3.tar.gz
chromium_src-1e927691dcc9f65d82aafc0f89af086048b945f3.tar.bz2
GTTF: Make automation provider recognize more IPC error conditions
1) Report IPC message deserialization errors in "delay reply" handlers. 2) Handle those errors in automation provider. BUG=77875 Review URL: http://codereview.chromium.org/6675047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79980 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc15
-rw-r--r--chrome/browser/automation/automation_provider.h4
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc9
-rw-r--r--ipc/ipc_message_macros.h2
4 files changed, 24 insertions, 6 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index c8de882..a65a960 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -339,7 +339,8 @@ void AutomationProvider::OnChannelConnected(int pid) {
bool AutomationProvider::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(AutomationProvider, message)
+ bool deserialize_success = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(AutomationProvider, message, deserialize_success)
#if !defined(OS_MACOSX)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag,
WindowSimulateDrag)
@@ -407,8 +408,10 @@ bool AutomationProvider::OnMessageReceived(const IPC::Message& message) {
OnRunUnloadHandlers)
IPC_MESSAGE_HANDLER(AutomationMsg_SetZoomLevel, OnSetZoomLevel)
#endif // defined(OS_WIN)
- IPC_MESSAGE_UNHANDLED(handled = false;OnUnhandledMessage())
- IPC_END_MESSAGE_MAP()
+ IPC_MESSAGE_UNHANDLED(handled = false; OnUnhandledMessage())
+ IPC_END_MESSAGE_MAP_EX()
+ if (!deserialize_success)
+ OnMessageDeserializationFailure();
return handled;
}
@@ -425,6 +428,12 @@ void AutomationProvider::OnUnhandledMessage() {
channel_->Close();
}
+void AutomationProvider::OnMessageDeserializationFailure() {
+ LOG(ERROR) << "Failed to deserialize IPC message. "
+ << "Closing the automation channel.";
+ channel_->Close();
+}
+
// This task just adds another task to the event queue. This is useful if
// you want to ensure that any tasks added to the event queue after this one
// have already been processed by the time |task| is run.
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index 3ba4812..0bd06c7 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -179,6 +179,10 @@ class AutomationProvider
// Returns NULL on failure.
RenderViewHost* GetViewForTab(int tab_handle);
+ // Called on IPC message deserialization failure. Prints an error message
+ // and closes the IPC channel.
+ void OnMessageDeserializationFailure();
+
scoped_ptr<AutomationAutocompleteEditTracker> autocomplete_edit_tracker_;
scoped_ptr<AutomationBrowserTracker> browser_tracker_;
scoped_ptr<InitialLoadObserver> initial_load_observer_;
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 2a14cb9..4e3eb13 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -193,7 +193,10 @@ void TestingAutomationProvider::Observe(NotificationType type,
bool TestingAutomationProvider::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(TestingAutomationProvider, message)
+ bool deserialize_success = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(TestingAutomationProvider,
+ message,
+ deserialize_success)
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser)
IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync,
CloseBrowserAsync)
@@ -382,7 +385,9 @@ bool TestingAutomationProvider::OnMessageReceived(
IPC_MESSAGE_UNHANDLED(
handled = AutomationProvider::OnMessageReceived(message))
- IPC_END_MESSAGE_MAP()
+ IPC_END_MESSAGE_MAP_EX()
+ if (!deserialize_success)
+ OnMessageDeserializationFailure();
return handled;
}
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index 0320aaa..87e9c20 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -730,7 +730,7 @@ LogFunctionMap g_log_function_mapping;
#define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \
case msg_class::ID: \
- msg_class::DispatchDelayReply(&ipc_message__, obj, &member_func); \
+ msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, &member_func); \
break;
#define IPC_MESSAGE_HANDLER_DELAY_REPLY(msg_class, member_func) \