From 6d1db74e78ec273a01ea98c80f0b5cd7a1ca84e9 Mon Sep 17 00:00:00 2001
From: "vitalybuka@chromium.org"
 <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Sun, 23 Sep 2012 03:51:41 +0000
Subject: Removed unnecessary returning by reference to simplify code.

BUG=137129

Review URL: https://chromiumcodereview.appspot.com/10958052

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158200 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/service/cloud_print/cloud_print_proxy.cc  | 24 ++++++++++--------------
 chrome/service/cloud_print/connector_settings.cc | 23 +++++++++++------------
 2 files changed, 21 insertions(+), 26 deletions(-)

(limited to 'chrome/service/cloud_print')

diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc
index 416eddb1..b6eff89 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy.cc
@@ -90,13 +90,11 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) {
   DCHECK(backend_.get());
   // Read persisted robot credentials because we may decide to reuse it if the
   // passed in LSID belongs the same user.
-  std::string robot_refresh_token;
-  service_prefs_->GetString(prefs::kCloudPrintRobotRefreshToken,
-                            &robot_refresh_token);
-  std::string robot_email;
-  service_prefs_->GetString(prefs::kCloudPrintRobotEmail,
-                            &robot_email);
-  service_prefs_->GetString(prefs::kCloudPrintEmail, &user_email_);
+  std::string robot_refresh_token =
+      service_prefs_->GetString(prefs::kCloudPrintRobotRefreshToken, "");
+  std::string robot_email =
+      service_prefs_->GetString(prefs::kCloudPrintRobotEmail, "");
+  user_email_ = service_prefs_->GetString(prefs::kCloudPrintEmail, user_email_);
 
   // If we have been passed in an LSID, we want to use this to authenticate.
   // Else we will try and retrieve the last used auth tokens from prefs.
@@ -110,9 +108,8 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) {
       backend_->InitializeWithRobotToken(robot_refresh_token, robot_email);
     } else {
       // Finally see if we have persisted user credentials (legacy case).
-      std::string cloud_print_token;
-      service_prefs_->GetString(prefs::kCloudPrintAuthToken,
-                                &cloud_print_token);
+      std::string cloud_print_token =
+          service_prefs_->GetString(prefs::kCloudPrintAuthToken, "");
       DCHECK(!cloud_print_token.empty());
       backend_->InitializeWithToken(cloud_print_token);
     }
@@ -146,8 +143,8 @@ bool CloudPrintProxy::CreateBackend() {
 
   // By default we don't poll for jobs when we lose XMPP connection. But this
   // behavior can be overridden by a preference.
-  bool enable_job_poll = false;
-  service_prefs_->GetBoolean(prefs::kCloudPrintEnableJobPoll, &enable_job_poll);
+  bool enable_job_poll =
+    service_prefs_->GetBoolean(prefs::kCloudPrintEnableJobPoll, false);
 
   gaia::OAuthClientInfo oauth_client_info;
   oauth_client_info.client_id =
@@ -156,7 +153,6 @@ bool CloudPrintProxy::CreateBackend() {
     google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_CLOUD_PRINT);
   backend_.reset(new CloudPrintProxyBackend(this, settings_, oauth_client_info,
                                             enable_job_poll));
-
   return true;
 }
 
@@ -191,7 +187,7 @@ void CloudPrintProxy::GetProxyInfo(cloud_print::CloudPrintProxyInfo* info) {
   // If the Cloud Print service is not enabled, we may need to read the old
   // value of proxy_id from prefs.
   if (info->proxy_id.empty())
-    service_prefs_->GetString(prefs::kCloudPrintProxyId, &info->proxy_id);
+    info->proxy_id = service_prefs_->GetString(prefs::kCloudPrintProxyId, "");
 }
 
 void CloudPrintProxy::CheckCloudPrintProxyPolicy() {
diff --git a/chrome/service/cloud_print/connector_settings.cc b/chrome/service/cloud_print/connector_settings.cc
index 667dd5b..f400914 100644
--- a/chrome/service/cloud_print/connector_settings.cc
+++ b/chrome/service/cloud_print/connector_settings.cc
@@ -17,7 +17,8 @@ const char kDeleteOnEnumFail[] = "delete_on_enum_fail";
 
 }  // namespace
 
-ConnectorSettings::ConnectorSettings() : delete_on_enum_fail_(false) {
+ConnectorSettings::ConnectorSettings()
+  : delete_on_enum_fail_(false) {
 }
 
 ConnectorSettings::~ConnectorSettings() {
@@ -26,7 +27,7 @@ ConnectorSettings::~ConnectorSettings() {
 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
   CopyFrom(ConnectorSettings());
 
-  prefs->GetString(prefs::kCloudPrintProxyId, &proxy_id_);
+  proxy_id_ = prefs->GetString(prefs::kCloudPrintProxyId, "");
   if (proxy_id_.empty()) {
     proxy_id_ = cloud_print::PrintSystem::GenerateProxyId();
     prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_);
@@ -34,24 +35,22 @@ void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
   }
 
   // Getting print system specific settings from the preferences.
-  const base::DictionaryValue* print_system_settings = NULL;
-  prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings,
-                       &print_system_settings);
+  const base::DictionaryValue* print_system_settings =
+      prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings);
   if (print_system_settings) {
     print_system_settings_.reset(print_system_settings->DeepCopy());
-    // TODO(vitalybuka) : Consider to move option from print_system_settings.
+    // TODO(vitalybuka) : Consider to rename and move out option from
+    // print_system_settings.
     print_system_settings_->GetBoolean(kDeleteOnEnumFail,
                                        &delete_on_enum_fail_);
   }
 
   // Check if there is an override for the cloud print server URL.
-  std::string cloud_print_server_url_str;
-  prefs->GetString(prefs::kCloudPrintServiceURL,
-                   &cloud_print_server_url_str);
-  if (cloud_print_server_url_str.empty()) {
-    cloud_print_server_url_str = kDefaultCloudPrintServerUrl;
+  server_url_ = GURL(prefs->GetString(prefs::kCloudPrintServiceURL, ""));
+  DCHECK(server_url_.is_empty() || server_url_.is_valid());
+  if (server_url_.is_empty() || !server_url_.is_valid()) {
+    server_url_ = GURL(kDefaultCloudPrintServerUrl);
   }
-  server_url_ = GURL(cloud_print_server_url_str.c_str());
   DCHECK(server_url_.is_valid());
 }
 
-- 
cgit v1.1