Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: google_apis/gcm/engine/gservices_settings.cc

Issue 270403006: Adding handling of MCS Endpoints to GServicesSettings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing CR feedback Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/engine/gservices_settings.h ('k') | google_apis/gcm/engine/gservices_settings_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..55cfa391392373f3326e0a8d34842a4095f1e3c7 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 int kDefaultMCSSecurePort = 5228;
+const char kDefaultMCSHostname[] = "mtalk.google.com";
+const int kDefaultMCSMainSecurePort = 5228;
+const int kDefaultMCSFallbackSecurePort = 443;
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);
Nicolas Zea 2014/05/08 22:00:52 Should we be doing any kind of verification that t
fgorski 2014/05/09 17:54:41 Based on our conversation, we don't want to make a
+}
} // 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,
+ kDefaultMCSMainSecurePort)),
+ mcs_fallback_endpoint_(MakeMCSEndpoint(kDefaultMCSHostname,
+ kDefaultMCSFallbackSecurePort)),
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;
}
@@ -144,6 +153,14 @@ bool GServicesSettings::UpdateSettings(
return false;
}
+ GURL new_mcs_main_endpoint =
+ GURL(MakeMCSEndpoint(new_mcs_hostname, new_mcs_secure_port));
+ GURL new_mcs_fallback_endpoint =
+ GURL(MakeMCSEndpoint(new_mcs_hostname, kDefaultMCSFallbackSecurePort));
+ if (!new_mcs_main_endpoint.is_valid() ||
+ !new_mcs_fallback_endpoint.is_valid())
+ return false;
+
GURL new_checkin_url;
iter = settings.find(kCheckinURLKey);
if (iter == settings.end()) {
@@ -172,8 +189,8 @@ 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_ = new_mcs_main_endpoint;
+ mcs_fallback_endpoint_ = new_mcs_fallback_endpoint;
checkin_url_ = new_checkin_url;
registration_url_ = new_registration_url;
return true;
« no previous file with comments | « google_apis/gcm/engine/gservices_settings.h ('k') | google_apis/gcm/engine/gservices_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698