diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 01:07:24 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-12 01:07:24 +0000 |
commit | 50307586363272bb8b133004889772b4919ad8fd (patch) | |
tree | a7e73d040cbd3d846e60570abd68c731f85b3e48 /chrome/browser/service/service_process_control_manager.cc | |
parent | 7e8a83c5f13b6ed0c5be202f5697efc07cee06ce (diff) | |
download | chromium_src-50307586363272bb8b133004889772b4919ad8fd.zip chromium_src-50307586363272bb8b133004889772b4919ad8fd.tar.gz chromium_src-50307586363272bb8b133004889772b4919ad8fd.tar.bz2 |
ServiceProcessControl to launch a service process and communicate through IPC.
Added two class for use with service process:
ServiceProcessControl
Used by the browser to launch and connect to the service process, also used
to receive messages from the service process.
ServiceProcessControlManager
A singleton to manage multiple ServicProcessControl.
BUG=50244
TEST=browser_tests --gtest_filter=ServiceProcess*
Review URL: http://codereview.chromium.org/3032061
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service/service_process_control_manager.cc')
-rw-r--r-- | chrome/browser/service/service_process_control_manager.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/chrome/browser/service/service_process_control_manager.cc b/chrome/browser/service/service_process_control_manager.cc new file mode 100644 index 0000000..821de9a --- /dev/null +++ b/chrome/browser/service/service_process_control_manager.cc @@ -0,0 +1,45 @@ +// Copyright (c) 2010 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/browser/service/service_process_control_manager.h" + +#include "base/singleton.h" +#include "base/stl_util-inl.h" +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/service/service_process_control.h" + +ServiceProcessControlManager::ServiceProcessControlManager() { +} + +ServiceProcessControlManager::~ServiceProcessControlManager() { + DCHECK(process_control_list_.empty()); +} + +ServiceProcessControl* ServiceProcessControlManager::GetProcessControl( + Profile* profile, ServiceProcessType type) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + + // TODO(hclam): We will have different service process for different types of + // service, but now we only create a new process for a different profile. + for (ServiceProcessControlList::iterator i = process_control_list_.begin(); + i != process_control_list_.end(); ++i) { + if ((*i)->profile() == profile) + return *i; + } + + // Couldn't find a ServiceProcess so construct a new one. + ServiceProcessControl* process = new ServiceProcessControl(profile, type); + process_control_list_.push_back(process); + return process; +} + +void ServiceProcessControlManager::Shutdown() { + STLDeleteElements(&process_control_list_); +} + +// static +ServiceProcessControlManager* ServiceProcessControlManager::instance() { + return Singleton<ServiceProcessControlManager>::get(); +} |