summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/service_ipc_server.cc11
-rw-r--r--chrome/service/service_ipc_server.h1
-rw-r--r--chrome/service/service_process.cc16
-rw-r--r--chrome/service/service_process.h15
4 files changed, 40 insertions, 3 deletions
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc
index f912701..ae80d42 100644
--- a/chrome/service/service_ipc_server.cc
+++ b/chrome/service/service_ipc_server.cc
@@ -61,8 +61,11 @@ void ServiceIPCServer::OnChannelError() {
// client requests, we will recreate the channel.
bool client_was_connected = client_connected_;
client_connected_ = false;
- if (client_was_connected)
+ // TODO(sanjeevr): Instead of invoking the service process for such handlers,
+ // define a Client interface that the ServiceProcess can implement.
+ if (client_was_connected && g_service_process->HandleClientDisconnect()) {
CreateChannel();
+ }
}
bool ServiceIPCServer::Send(IPC::Message* msg) {
@@ -88,6 +91,7 @@ void ServiceIPCServer::OnMessageReceived(const IPC::Message& msg) {
OnIsCloudPrintProxyEnabled)
IPC_MESSAGE_HANDLER(ServiceMsg_Hello, OnHello);
IPC_MESSAGE_HANDLER(ServiceMsg_Shutdown, OnShutdown);
+ IPC_MESSAGE_HANDLER(ServiceMsg_UpdateAvailable, OnUpdateAvailable);
IPC_END_MESSAGE_MAP()
}
@@ -129,3 +133,8 @@ void ServiceIPCServer::OnHello() {
void ServiceIPCServer::OnShutdown() {
g_service_process->Shutdown();
}
+
+void ServiceIPCServer::OnUpdateAvailable() {
+ g_service_process->SetUpdateAvailable();
+}
+
diff --git a/chrome/service/service_ipc_server.h b/chrome/service/service_ipc_server.h
index 1c8c19b..79416a5 100644
--- a/chrome/service/service_ipc_server.h
+++ b/chrome/service/service_ipc_server.h
@@ -51,6 +51,7 @@ class ServiceIPCServer : public IPC::Channel::Listener,
void OnDisableCloudPrintProxy();
void OnHello();
void OnShutdown();
+ void OnUpdateAvailable();
// Helper method to create the sync channel.
void CreateChannel();
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 86d787b..db562c3 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -52,7 +52,8 @@ static const int64 kShutdownDelay = 60000;
ServiceProcess::ServiceProcess()
: shutdown_event_(true, false),
main_message_loop_(NULL),
- enabled_services_(0) {
+ enabled_services_(0),
+ update_available_(false) {
DCHECK(!g_service_process);
g_service_process = this;
}
@@ -150,6 +151,17 @@ void ServiceProcess::Shutdown() {
main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
+bool ServiceProcess::HandleClientDisconnect() {
+ // If there are no enabled services or if there is an update available
+ // we want to shutdown right away. Else we want to keep listening for
+ // new connections.
+ if (!enabled_services_ || update_available()) {
+ Shutdown();
+ return false;
+ }
+ return true;
+}
+
CloudPrintProxy* ServiceProcess::GetCloudPrintProxy() {
if (!cloud_print_proxy_.get()) {
cloud_print_proxy_.reset(new CloudPrintProxy());
@@ -180,7 +192,7 @@ void ServiceProcess::OnServiceEnabled() {
}
void ServiceProcess::OnServiceDisabled() {
- DCHECK(0 != enabled_services_);
+ DCHECK_NE(enabled_services_, 0);
enabled_services_--;
if (0 == enabled_services_) {
RemoveServiceProcessFromAutoStart();
diff --git a/chrome/service/service_process.h b/chrome/service/service_process.h
index 3e99d21..a8a5e5a 100644
--- a/chrome/service/service_process.h
+++ b/chrome/service/service_process.h
@@ -6,6 +6,8 @@
#define CHROME_SERVICE_SERVICE_PROCESS_H_
#pragma once
+#include <string>
+
#include "base/gtest_prod_util.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
@@ -74,6 +76,16 @@ class ServiceProcess : public RemotingDirectoryService::Client,
// Shutdown the service process. This is likely triggered by a IPC message.
void Shutdown();
+ void SetUpdateAvailable() {
+ update_available_ = true;
+ }
+ bool update_available() const { return update_available_; }
+
+ // Called by the IPC server when a client disconnects. A return value of
+ // true indicates that the IPC server should continue listening for new
+ // connections.
+ bool HandleClientDisconnect();
+
CloudPrintProxy* GetCloudPrintProxy();
// CloudPrintProxy::Client implementation.
@@ -168,6 +180,9 @@ class ServiceProcess : public RemotingDirectoryService::Client,
// Count of currently enabled services in this process.
int enabled_services_;
+ // Speficies whether a product update is available.
+ bool update_available_;
+
DISALLOW_COPY_AND_ASSIGN(ServiceProcess);
};