Commit e5996795 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting][FTL] Allow overriding FTL server endpoint for testing

This CL allows developers to override FTL server endpoint for debug
build so that they can test with non-prod FTL server.

Bug: 947337
Change-Id: Ifbd340a21f9b25fb26439c36b7a4d9ad9b1d9da4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1566624
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650556}
parent fd7c4f20
...@@ -10,26 +10,28 @@ ...@@ -10,26 +10,28 @@
#include "remoting/base/remoting_bot.h" #include "remoting/base/remoting_bot.h"
// Configurable service data. // Configurable service data.
const char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1"; constexpr char kDirectoryBaseUrl[] = "https://www.googleapis.com/chromoting/v1";
const char kGcdBaseUrl[] = "https://www.googleapis.com/clouddevices/v1"; constexpr char kGcdBaseUrl[] = "https://www.googleapis.com/clouddevices/v1";
const char kXmppServerAddress[] = "talk.google.com:443"; constexpr char kXmppServerAddress[] = "talk.google.com:443";
const char kXmppServerAddressForMe2MeHost[] = "talk.google.com:5222"; constexpr char kXmppServerAddressForMe2MeHost[] = "talk.google.com:5222";
const bool kXmppServerUseTls = true; constexpr bool kXmppServerUseTls = true;
const char kGcdJid[] = "clouddevices.gserviceaccount.com"; constexpr char kGcdJid[] = "clouddevices.gserviceaccount.com";
constexpr char kFtlServerEndpoint[] = "instantmessaging-pa.googleapis.com";
// Command line switches. // Command line switches.
#if !defined(NDEBUG) #if !defined(NDEBUG)
const char kDirectoryBaseUrlSwitch[] = "directory-base-url"; constexpr char kDirectoryBaseUrlSwitch[] = "directory-base-url";
const char kGcdBaseUrlSwitch[] = "gcd-base-url"; constexpr char kGcdBaseUrlSwitch[] = "gcd-base-url";
const char kXmppServerAddressSwitch[] = "xmpp-server-address"; constexpr char kXmppServerAddressSwitch[] = "xmpp-server-address";
const char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls"; constexpr char kXmppServerDisableTlsSwitch[] = "disable-xmpp-server-tls";
const char kDirectoryBotJidSwitch[] = "directory-bot-jid"; constexpr char kDirectoryBotJidSwitch[] = "directory-bot-jid";
const char kGcdJidSwitch[] = "gcd-jid"; constexpr char kGcdJidSwitch[] = "gcd-jid";
constexpr char kFtlServerEndpointSwitch[] = "ftl-server-endpoint";
#endif // !defined(NDEBUG) #endif // !defined(NDEBUG)
// Non-configurable service paths. // Non-configurable service paths.
const char kDirectoryHostsSuffix[] = "/@me/hosts/"; constexpr char kDirectoryHostsSuffix[] = "/@me/hosts/";
const char kDirectoryIceConfigSuffix[] = "/@me/iceconfig"; constexpr char kDirectoryIceConfigSuffix[] = "/@me/iceconfig";
namespace remoting { namespace remoting {
...@@ -40,7 +42,8 @@ ServiceUrls::ServiceUrls() ...@@ -40,7 +42,8 @@ ServiceUrls::ServiceUrls()
xmpp_server_address_for_me2me_host_(kXmppServerAddressForMe2MeHost), xmpp_server_address_for_me2me_host_(kXmppServerAddressForMe2MeHost),
xmpp_server_use_tls_(kXmppServerUseTls), xmpp_server_use_tls_(kXmppServerUseTls),
directory_bot_jid_(kRemotingBotJid), directory_bot_jid_(kRemotingBotJid),
gcd_jid_(kGcdJid) { gcd_jid_(kGcdJid),
ftl_server_endpoint_(kFtlServerEndpoint) {
#if !defined(NDEBUG) #if !defined(NDEBUG)
// The command line may not be initialized when running as a PNaCl plugin. // The command line may not be initialized when running as a PNaCl plugin.
if (base::CommandLine::InitializedForCurrentProcess()) { if (base::CommandLine::InitializedForCurrentProcess()) {
...@@ -69,6 +72,10 @@ ServiceUrls::ServiceUrls() ...@@ -69,6 +72,10 @@ ServiceUrls::ServiceUrls()
if (command_line->HasSwitch(kGcdJidSwitch)) { if (command_line->HasSwitch(kGcdJidSwitch)) {
gcd_jid_ = command_line->GetSwitchValueASCII(kGcdJidSwitch); gcd_jid_ = command_line->GetSwitchValueASCII(kGcdJidSwitch);
} }
if (command_line->HasSwitch(kFtlServerEndpointSwitch)) {
ftl_server_endpoint_ =
command_line->GetSwitchValueASCII(kFtlServerEndpointSwitch);
}
} }
#endif // !defined(NDEBUG) #endif // !defined(NDEBUG)
......
...@@ -45,6 +45,10 @@ class ServiceUrls { ...@@ -45,6 +45,10 @@ class ServiceUrls {
// ICE config URL. // ICE config URL.
const std::string& ice_config_url() const { return ice_config_url_; } const std::string& ice_config_url() const { return ice_config_url_; }
const std::string& ftl_server_endpoint() const {
return ftl_server_endpoint_;
}
#if !defined(NDEBUG) #if !defined(NDEBUG)
// Override the directory bot JID for testing. // Override the directory bot JID for testing.
void set_directory_bot_jid(const std::string& bot_jid) { void set_directory_bot_jid(const std::string& bot_jid) {
...@@ -67,6 +71,7 @@ class ServiceUrls { ...@@ -67,6 +71,7 @@ class ServiceUrls {
std::string directory_bot_jid_; std::string directory_bot_jid_;
std::string gcd_jid_; std::string gcd_jid_;
std::string ice_config_url_; std::string ice_config_url_;
std::string ftl_server_endpoint_;
DISALLOW_COPY_AND_ASSIGN(ServiceUrls); DISALLOW_COPY_AND_ASSIGN(ServiceUrls);
}; };
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "google_apis/google_api_keys.h" #include "google_apis/google_api_keys.h"
#include "remoting/base/service_urls.h"
#include "third_party/grpc/src/include/grpcpp/channel.h" #include "third_party/grpc/src/include/grpcpp/channel.h"
#include "third_party/grpc/src/include/grpcpp/client_context.h" #include "third_party/grpc/src/include/grpcpp/client_context.h"
#include "third_party/grpc/src/include/grpcpp/grpcpp.h" #include "third_party/grpc/src/include/grpcpp/grpcpp.h"
...@@ -20,9 +21,6 @@ namespace { ...@@ -20,9 +21,6 @@ namespace {
constexpr char kChromotingAppIdentifier[] = "CRD"; constexpr char kChromotingAppIdentifier[] = "CRD";
// TODO(yuweih): We should target different service environments.
constexpr char kFtlServerEndpoint[] = "instantmessaging-pa.googleapis.com";
static base::NoDestructor<GrpcChannelSharedPtr> g_channel_for_testing; static base::NoDestructor<GrpcChannelSharedPtr> g_channel_for_testing;
const net::BackoffEntry::Policy kBackoffPolicy = { const net::BackoffEntry::Policy kBackoffPolicy = {
...@@ -81,7 +79,8 @@ GrpcChannelSharedPtr FtlGrpcContext::CreateChannel() { ...@@ -81,7 +79,8 @@ GrpcChannelSharedPtr FtlGrpcContext::CreateChannel() {
if (*g_channel_for_testing) { if (*g_channel_for_testing) {
return *g_channel_for_testing; return *g_channel_for_testing;
} }
return CreateSslChannelForEndpoint(kFtlServerEndpoint); return CreateSslChannelForEndpoint(
ServiceUrls::GetInstance()->ftl_server_endpoint());
} }
// static // static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment