Index: google_apis/gcm/engine/gservices_settings.cc |
diff --git a/google_apis/gcm/engine/gservices_settings.cc b/google_apis/gcm/engine/gservices_settings.cc |
index 8e228acf63af1e1e990d4f96ac37f0b4b03a3df4..e40529a72a06b5e86fc2c30f05bf60f5783f1483 100644 |
--- a/google_apis/gcm/engine/gservices_settings.cc |
+++ b/google_apis/gcm/engine/gservices_settings.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/strings/stringprintf.h" |
namespace { |
// The expected time in seconds between periodic checkins. |
@@ -22,10 +23,16 @@ const char kRegistrationURLKey[] = "gcm_registration_url"; |
const int64 kDefaultCheckinInterval = 2 * 24 * 60 * 60; // seconds = 2 days. |
const int64 kMinimumCheckinInterval = 12 * 60 * 60; // seconds = 12 hours. |
const char kDefaultCheckinURL[] = "https://android.clients.google.com/checkin"; |
-const char kDefaultMCSHostname[] = "https://mtalk.google.com"; |
+const char kDefaultMCSHostname[] = "mtalk.google.com"; |
const int kDefaultMCSSecurePort = 5228; |
jianli
2014/05/08 18:59:37
nit: kDefaultMCSMainSecurePort
fgorski
2014/05/08 19:21:03
Done.
|
+const int kDefaultMCSFallbackPort = 443; |
jianli
2014/05/08 18:59:37
nit: better to add "Secure" into the name, like kD
fgorski
2014/05/08 19:21:03
Done.
|
const char kDefaultRegistrationURL[] = |
"https://android.clients.google.com/c2dm/register3"; |
+const char kMCSEnpointTemplate[] = "https://%s:%d"; |
+ |
+std::string MakeMCSEndpoint(const std::string& mcs_hostname, int port) { |
+ return base::StringPrintf(kMCSEnpointTemplate, mcs_hostname.c_str(), port); |
+} |
} // namespace |
@@ -44,8 +51,10 @@ const GURL GServicesSettings::DefaultCheckinURL() { |
GServicesSettings::GServicesSettings() |
: checkin_interval_(base::TimeDelta::FromSeconds(kDefaultCheckinInterval)), |
checkin_url_(kDefaultCheckinURL), |
- mcs_hostname_(kDefaultMCSHostname), |
- mcs_secure_port_(kDefaultMCSSecurePort), |
+ mcs_main_endpoint_(MakeMCSEndpoint(kDefaultMCSHostname, |
+ kDefaultMCSSecurePort)), |
+ mcs_fallback_endpoint_(MakeMCSEndpoint(kDefaultMCSHostname, |
+ kDefaultMCSFallbackPort)), |
registration_url_(kDefaultRegistrationURL), |
weak_ptr_factory_(this) { |
} |
@@ -88,8 +97,8 @@ std::map<std::string, std::string> GServicesSettings::GetSettingsMap() const { |
settings[kCheckinIntervalKey] = |
base::Int64ToString(checkin_interval_.InSeconds()); |
settings[kCheckinURLKey] = checkin_url_.spec(); |
- settings[kMCSHostnameKey] = mcs_hostname_; |
- settings[kMCSSecurePortKey] = base::IntToString(mcs_secure_port_); |
+ settings[kMCSHostnameKey] = mcs_main_endpoint_.host(); |
+ settings[kMCSSecurePortKey] = mcs_main_endpoint_.port(); |
settings[kRegistrationURLKey] = registration_url_.spec(); |
return settings; |
} |
@@ -172,8 +181,10 @@ bool GServicesSettings::UpdateSettings( |
// We only update the settings once all of them are correct. |
checkin_interval_ = base::TimeDelta::FromSeconds(new_checkin_interval); |
- mcs_hostname_ = new_mcs_hostname; |
- mcs_secure_port_ = new_mcs_secure_port; |
+ mcs_main_endpoint_ = GURL(MakeMCSEndpoint(new_mcs_hostname, |
jianli
2014/05/08 18:59:37
Can you validate the URL?
fgorski
2014/05/08 19:21:03
Done.
|
+ new_mcs_secure_port)); |
+ mcs_fallback_endpoint_ = GURL(MakeMCSEndpoint(new_mcs_hostname, |
+ kDefaultMCSFallbackPort)); |
checkin_url_ = new_checkin_url; |
registration_url_ = new_registration_url; |
return true; |