summaryrefslogtreecommitdiffstats
path: root/chrome/service/service_process.cc
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 23:20:57 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 23:20:57 +0000
commite96bf0c56566457022d20682ee278cd135d7c681 (patch)
tree16aae1f02aa4ca3948343ffb75f6010f9d1da125 /chrome/service/service_process.cc
parent4232100ca0d42e558e75a728b69abca4b28499bf (diff)
downloadchromium_src-e96bf0c56566457022d20682ee278cd135d7c681.zip
chromium_src-e96bf0c56566457022d20682ee278cd135d7c681.tar.gz
chromium_src-e96bf0c56566457022d20682ee278cd135d7c681.tar.bz2
Resubmit r56600 - Start/stop service process when browser starts and stop
Save the information that the setup of remoting has completed. After setup has been completed we start and stop service process when --enable-remoting presents when browser starts. Also save the information in the service process that host is registered and ready to be used. Again start chromoting host automatically once the host registration is done. BUG=50244, 50242, 50243, 50249 Review URL: http://codereview.chromium.org/3153029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/service_process.cc')
-rw-r--r--chrome/service/service_process.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index f6d38e6..3dc4601 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -8,9 +8,11 @@
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
+#include "base/values.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/json_pref_store.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/service_process_type.h"
#include "chrome/common/service_process_util.h"
#include "chrome/service/cloud_print/cloud_print_proxy.h"
@@ -65,6 +67,16 @@ bool ServiceProcess::Initialize(MessageLoop* message_loop) {
file_thread_->message_loop_proxy()));
service_prefs_->ReadPrefs();
+ DictionaryValue* values = service_prefs_->prefs();
+ bool remoting_host_enabled = false;
+
+ // Check if remoting host is already enabled.
+ if (values->GetBoolean(prefs::kRemotingHostEnabled, &remoting_host_enabled) &&
+ remoting_host_enabled) {
+ // If true then we start the host.
+ StartChromotingHost();
+ }
+
// TODO(hclam): Each type of service process should has it own instance of
// process and thus channel, but now we have only one process for all types
// so the type parameter doesn't matter now.
@@ -81,7 +93,6 @@ bool ServiceProcess::Initialize(MessageLoop* message_loop) {
}
bool ServiceProcess::Teardown() {
- // TODO(hclam): Remove this as this looks like dead code.
if (service_prefs_.get()) {
service_prefs_->WritePrefs();
service_prefs_.reset();
@@ -132,6 +143,8 @@ bool ServiceProcess::EnableChromotingHostWithTokens(
talk_token_ = talk_token;
// Use the remoting directory to register the host.
+ if (remoting_directory_.get())
+ remoting_directory_->CancelRequest();
remoting_directory_.reset(new RemotingDirectoryService(this));
remoting_directory_->AddHost(remoting_token);
return true;
@@ -207,6 +220,12 @@ void ServiceProcess::OnRemotingHostAdded() {
remoting_token_ = "";
talk_token_ = "";
+ // Save the preference that we have enabled the remoting host.
+ service_prefs_->prefs()->SetBoolean(prefs::kRemotingHostEnabled, true);
+
+ // Force writing prefs to the disk.
+ service_prefs_->WritePrefs();
+
// TODO(hclam): If we have a problem we need to send an IPC message back
// to the client that started this.
bool ret = StartChromotingHost();