Index: chrome/browser/automation/automation_provider.cc |
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc |
index adc563b70e1411d23c19c0d0f8d743c57b558b67..051f472d115cf222ce973a2e1db215126b7e0cb1 100644 |
--- a/chrome/browser/automation/automation_provider.cc |
+++ b/chrome/browser/automation/automation_provider.cc |
@@ -110,6 +110,7 @@ using base::Time; |
AutomationProvider::AutomationProvider(Profile* profile) |
: profile_(profile), |
reply_message_(NULL), |
+ reconnect_on_channel_error_(false), |
is_connected_(false), |
initial_loads_complete_(false) { |
TRACE_EVENT_BEGIN("AutomationProvider::AutomationProvider", 0, ""); |
@@ -146,6 +147,7 @@ AutomationProvider::~AutomationProvider() { |
bool AutomationProvider::InitializeChannel(const std::string& channel_id) { |
TRACE_EVENT_BEGIN("AutomationProvider::InitializeChannel", 0, ""); |
+ channel_id_ = channel_id; |
std::string effective_channel_id = channel_id; |
// If the channel_id starts with kNamedInterfacePrefix, create a named IPC |
@@ -157,6 +159,8 @@ bool AutomationProvider::InitializeChannel(const std::string& channel_id) { |
strlen(automation::kNamedInterfacePrefix)); |
if (effective_channel_id.length() <= 0) |
return false; |
+ |
+ reconnect_on_channel_error_ = true; |
} |
if (!automation_resource_message_filter_.get()) { |
@@ -432,9 +436,25 @@ void AutomationProvider::HandleUnused(const IPC::Message& message, int handle) { |
} |
} |
+bool AutomationProvider::ReinitializeChannel() { |
+ base::ThreadRestrictions::ScopedAllowIO allow_io; |
+ |
+ // Make sure any old channels are cleaned up before starting up a new one. |
+ channel_.reset(); |
+ return InitializeChannel(channel_id_); |
+} |
+ |
void AutomationProvider::OnChannelError() { |
- VLOG(1) << "AutomationProxy went away, shutting down app."; |
- AutomationProviderList::GetInstance()->RemoveProvider(this); |
+ if (reconnect_on_channel_error_) { |
+ VLOG(1) << "AutomationProxy disconnected, resetting AutomationProvider."; |
+ if (!ReinitializeChannel()) { |
+ VLOG(1) << "Error reinitializing AutomationProvider channel."; |
+ AutomationProviderList::GetInstance()->RemoveProvider(this); |
+ } |
+ } else { |
+ VLOG(1) << "AutomationProxy went away, shutting down app."; |
+ AutomationProviderList::GetInstance()->RemoveProvider(this); |
Nirnimesh
2011/02/17 00:55:12
You won't need to repeat this RemoveProvider() cal
dtu
2011/02/17 02:14:25
Done.
|
+ } |
} |
bool AutomationProvider::Send(IPC::Message* msg) { |