diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 07:57:00 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-31 07:57:00 +0000 |
commit | 38fe1964640f28c273b2a68a564b7c47a68f8b01 (patch) | |
tree | 872c11ad9630842dc2a39b6bbe64877bcd41f0d0 /chrome/service/service_ipc_server.cc | |
parent | 6364aad5c4a477197165def0a06f118acd422744 (diff) | |
download | chromium_src-38fe1964640f28c273b2a68a564b7c47a68f8b01.zip chromium_src-38fe1964640f28c273b2a68a564b7c47a68f8b01.tar.gz chromium_src-38fe1964640f28c273b2a68a564b7c47a68f8b01.tar.bz2 |
Added an IPC server in the service process to listen to commands. This is not used yet.
BUG=None
TEST=None for now since this code is not enabled.
Review URL: http://codereview.chromium.org/3041036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/service_ipc_server.cc')
-rw-r--r-- | chrome/service/service_ipc_server.cc | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc new file mode 100644 index 0000000..2199d00 --- /dev/null +++ b/chrome/service/service_ipc_server.cc @@ -0,0 +1,85 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/service/service_ipc_server.h" + +#include "chrome/common/service_messages.h" +#include "chrome/service/cloud_print/cloud_print_proxy.h" +#include "chrome/service/service_process.h" +#include "ipc/ipc_logging.h" + +ServiceIPCServer::ServiceIPCServer(const std::string& channel_name) + : channel_name_(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()); + return true; +} + +ServiceIPCServer::~ServiceIPCServer() { +#ifdef IPC_MESSAGE_LOG_ENABLED + IPC::Logging::current()->SetIPCSender(NULL); +#endif + + channel_->RemoveFilter(sync_message_filter_.get()); + + // The ChannelProxy object caches a pointer to the IPC thread, so need to + // reset it as it's not guaranteed to outlive this object. + // NOTE: this also has the side-effect of not closing the main IPC channel to + // the browser process. This is needed because this is the signal that the + // browser uses to know that this process has died, so we need it to be alive + // until this process is shut down, and the OS closes the handle + // automatically. We used to watch the object handle on Windows to do this, + // but it wasn't possible to do so on POSIX. + channel_->ClearIPCMessageLoop(); +} + +void ServiceIPCServer::OnChannelError() { +} + +bool ServiceIPCServer::Send(IPC::Message* msg) { + if (!channel_.get()) { + delete msg; + return false; + } + + return channel_->Send(msg); +} + +void ServiceIPCServer::OnMessageReceived(const IPC::Message& msg) { + IPC_BEGIN_MESSAGE_MAP(ServiceIPCServer, msg) + IPC_MESSAGE_HANDLER(ServiceMsg_EnableCloudPrintProxy, + OnEnableCloudPrintProxy) + IPC_MESSAGE_HANDLER(ServiceMsg_EnableCloudPrintProxyWithTokens, + OnEnableCloudPrintProxyWithTokens) + IPC_MESSAGE_HANDLER(ServiceMsg_DisableCloudPrintProxy, + OnDisableCloudPrintProxy) + IPC_END_MESSAGE_MAP() +} + +void ServiceIPCServer::OnEnableCloudPrintProxy(const std::string& lsid) { + g_service_process->GetCloudPrintProxy()->EnableForUser(lsid); +} + +void ServiceIPCServer::OnEnableCloudPrintProxyWithTokens( + const std::string& cloud_print_token, const std::string& talk_token) { + // TODO(sanjeevr): Implement this. + NOTIMPLEMENTED(); +} + +void ServiceIPCServer::OnDisableCloudPrintProxy() { + g_service_process->GetCloudPrintProxy()->DisableForUser(); +} + |