summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-22 23:22:40 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-22 23:22:40 +0000
commit5f0a94bd38f533cdd04e938a31f43d880eed71bd (patch)
tree95381a4a95b39ee5e3e1c5066c3da8195f1d317c /chrome/service
parent285f5ad8f3fbe85c69e3e747e1ba9b0dfd4c5e42 (diff)
downloadchromium_src-5f0a94bd38f533cdd04e938a31f43d880eed71bd.zip
chromium_src-5f0a94bd38f533cdd04e938a31f43d880eed71bd.tar.gz
chromium_src-5f0a94bd38f533cdd04e938a31f43d880eed71bd.tar.bz2
Recreate the channel when an IPC client to the service process (typically a browser process) disconnects so we can keep servicing
client requests. BUG=None TEST=Test connecting to a service process over IPC repeatedly. Review URL: http://codereview.chromium.org/3451013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/service_ipc_server.cc20
-rw-r--r--chrome/service/service_ipc_server.h3
2 files changed, 17 insertions, 6 deletions
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc
index c532414..5663f49 100644
--- a/chrome/service/service_ipc_server.cc
+++ b/chrome/service/service_ipc_server.cc
@@ -14,20 +14,24 @@ ServiceIPCServer::ServiceIPCServer(const std::string& channel_name)
}
bool ServiceIPCServer::Init() {
- channel_.reset(new IPC::SyncChannel(channel_name_,
- IPC::Channel::MODE_SERVER, this, NULL,
- g_service_process->io_thread()->message_loop(), true,
- g_service_process->shutdown_event()));
#ifdef IPC_MESSAGE_LOG_ENABLED
IPC::Logging::current()->SetIPCSender(this);
#endif
-
sync_message_filter_ =
new IPC::SyncMessageFilter(g_service_process->shutdown_event());
- channel_->AddFilter(sync_message_filter_.get());
+ CreateChannel();
return true;
}
+void ServiceIPCServer::CreateChannel() {
+ channel_.reset(new IPC::SyncChannel(channel_name_,
+ IPC::Channel::MODE_SERVER, this, NULL,
+ g_service_process->io_thread()->message_loop(), true,
+ g_service_process->shutdown_event()));
+ DCHECK(sync_message_filter_.get());
+ channel_->AddFilter(sync_message_filter_.get());
+}
+
ServiceIPCServer::~ServiceIPCServer() {
#ifdef IPC_MESSAGE_LOG_ENABLED
IPC::Logging::current()->SetIPCSender(NULL);
@@ -47,6 +51,10 @@ ServiceIPCServer::~ServiceIPCServer() {
}
void ServiceIPCServer::OnChannelError() {
+ // When a client (typically a browser process) disconnects, the pipe is
+ // closed and we get an OnChannelError. Since we want to keep servicing
+ // client requests, we will recreate the channel.
+ CreateChannel();
}
bool ServiceIPCServer::Send(IPC::Message* msg) {
diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h
index 6ead58e..5cd8624 100644
--- a/chrome/service/service_ipc_server.h
+++ b/chrome/service/service_ipc_server.h
@@ -49,6 +49,9 @@ class ServiceIPCServer : public IPC::Channel::Listener,
void OnHello();
void OnShutdown();
+ // Helper method to create the sync channel.
+ void CreateChannel();
+
std::string channel_name_;
scoped_ptr<IPC::SyncChannel> channel_;