Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: chrome/browser/automation/automation_provider.cc

Issue 6515016: Restart named testing channel on disconnect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes per nirnimesh's comments. Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e5091f34cc1c13f1198a1c48bf043d98262f6018 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),
+ reinitialize_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;
+
+ reinitialize_on_channel_error_ = true;
}
if (!automation_resource_message_filter_.get()) {
@@ -432,7 +436,21 @@ 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() {
+ if (reinitialize_on_channel_error_) {
+ VLOG(1) << "AutomationProxy disconnected, resetting AutomationProvider.";
+ if (ReinitializeChannel())
+ return;
+ VLOG(1) << "Error reinitializing AutomationProvider channel.";
+ }
VLOG(1) << "AutomationProxy went away, shutting down app.";
AutomationProviderList::GetInstance()->RemoveProvider(this);
}
« no previous file with comments | « chrome/browser/automation/automation_provider.h ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698