summaryrefslogtreecommitdiffstats
path: root/chrome/service/service_main.cc
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-21 19:09:55 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-21 19:09:55 +0000
commit1e6c016987770754320842057097e2be9266011d (patch)
treee34f1122652e8d5fbe44df8108f2e873a0494d47 /chrome/service/service_main.cc
parentbbd8993d6edff252033397a88da1b47c770d0c11 (diff)
downloadchromium_src-1e6c016987770754320842057097e2be9266011d.zip
chromium_src-1e6c016987770754320842057097e2be9266011d.tar.gz
chromium_src-1e6c016987770754320842057097e2be9266011d.tar.bz2
Added the ability in the service process to save and read state from a prefs file. Used this to save and read the cloud print proxy auth token and proxy id.
BUG=None. TEST=Test Cloud Print Proxy (run it second time without LSID and ProxyId command-line args) Review URL: http://codereview.chromium.org/2066018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service/service_main.cc')
-rw-r--r--chrome/service/service_main.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc
index 44ca8eb..8fea68d 100644
--- a/chrome/service/service_main.cc
+++ b/chrome/service/service_main.cc
@@ -3,8 +3,11 @@
// found in the LICENSE file.
#include "base/message_loop.h"
+#include "base/path_service.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/json_pref_store.h"
#include "chrome/common/main_function_params.h"
#include "chrome/service/cloud_print/cloud_print_proxy.h"
#include "chrome/service/service_process.h"
@@ -17,16 +20,32 @@ int ServiceProcessMain(const MainFunctionParams& parameters) {
ServiceProcess service_process;
service_process.Initialize();
+
+ // TODO(sanjeevr): The interface to start individual services such as the
+ // cloud print proxy needs to change from a command-line interface to an
+ // IPC interface. There will be eventually only one service process to handle
+ // requests from multiple Chrome browser profiles. The path of the user data
+ // directory will be passed in to the command and there will be one instance
+ // of services such as the cloud print proxy per requesting profile.
+ FilePath user_data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ FilePath pref_path = user_data_dir.Append(chrome::kServiceStateFileName);
+ scoped_ptr<JsonPrefStore> service_prefs(
+ new JsonPrefStore(
+ pref_path,
+ service_process.file_thread()->message_loop_proxy()));
+ service_prefs->ReadPrefs();
+
if (parameters.command_line_.HasSwitch(switches::kEnableCloudPrintProxy)) {
std::string lsid =
parameters.command_line_.GetSwitchValueASCII(
switches::kServiceAccountLsid);
- std::string proxy_id =
- parameters.command_line_.GetSwitchValueASCII(
- switches::kCloudPrintProxyId);
- service_process.cloud_print_proxy()->EnableForUser(lsid, proxy_id);
+ CloudPrintProxy* cloud_print_proxy =
+ service_process.CreateCloudPrintProxy(service_prefs.get());
+ cloud_print_proxy->EnableForUser(lsid);
}
MessageLoop::current()->Run();
+ service_prefs->WritePrefs();
service_process.Teardown();
return 0;