#include "remoting/signaling/ftl_services_context.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "google_apis/google_api_keys.h"
#include "remoting/base/service_urls.h"
namespace remoting {
namespace {
constexpr char kChromotingAppIdentifier[] = "CRD";
}
constexpr base::TimeDelta FtlServicesContext::kBackoffInitialDelay;
constexpr base::TimeDelta FtlServicesContext::kBackoffMaxDelay;
const net::BackoffEntry::Policy& FtlServicesContext::GetBackoffPolicy() {
static const net::BackoffEntry::Policy kBackoffPolicy = {
0,
static_cast<int>(kBackoffInitialDelay.InMilliseconds()),
2,
0.5,
kBackoffMaxDelay.InMilliseconds(),
-1,
false,
};
return kBackoffPolicy;
}
std::string FtlServicesContext::GetServerEndpoint() {
return ServiceUrls::GetInstance()->ftl_server_endpoint();
}
std::string FtlServicesContext::GetChromotingAppIdentifier() {
return kChromotingAppIdentifier;
}
ftl::Id FtlServicesContext::CreateIdFromString(const std::string& ftl_id) {
ftl::Id id;
id.set_id(ftl_id);
id.set_app(GetChromotingAppIdentifier());
id.set_type(ftl::IdType_Type_EMAIL);
return id;
}
ftl::RequestHeader FtlServicesContext::CreateRequestHeader(
const std::string& ftl_auth_token) {
ftl::RequestHeader header;
header.set_request_id(base::Uuid::GenerateRandomV4().AsLowercaseString());
header.set_app(kChromotingAppIdentifier);
if (!ftl_auth_token.empty()) {
header.set_auth_token_payload(ftl_auth_token);
}
ftl::ClientInfo* client_info = header.mutable_client_info();
client_info->set_api_version(ftl::ApiVersion_Value_V4);
client_info->set_version_major(VERSION_MAJOR);
client_info->set_version_minor(VERSION_BUILD);
client_info->set_version_point(VERSION_PATCH);
ftl::Platform_Type platform_type;
#if BUILDFLAG(IS_ANDROID)
platform_type = ftl::Platform_Type_FTL_ANDROID;
#elif BUILDFLAG(IS_IOS)
platform_type = ftl::Platform_Type_FTL_IOS;
#else
platform_type = ftl::Platform_Type_FTL_DESKTOP;
#endif
client_info->set_platform_type(platform_type);
return header;
}
}