#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "remoting/signaling/ftl_registration_manager.h"
#include <utility>
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/time/time.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "remoting/base/protobuf_http_client.h"
#include "remoting/base/protobuf_http_request.h"
#include "remoting/base/protobuf_http_request_config.h"
#include "remoting/base/protobuf_http_status.h"
#include "remoting/proto/ftl/v1/ftl_messages.pb.h"
#include "remoting/signaling/ftl_device_id_provider.h"
#include "remoting/signaling/ftl_services_context.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace remoting {
namespace {
constexpr remoting::ftl::ChromotingCapability::Feature
kChromotingCapabilities[] = {
remoting::ftl::ChromotingCapability_Feature_SERIALIZED_XMPP_SIGNALING};
constexpr size_t kChromotingCapabilityCount =
sizeof(kChromotingCapabilities) /
sizeof(ftl::ChromotingCapability::Feature);
constexpr remoting::ftl::FtlCapability::Feature kFtlCapabilities[] = {
remoting::ftl::FtlCapability_Feature_RECEIVE_CALLS_FROM_GAIA,
remoting::ftl::FtlCapability_Feature_GAIA_REACHABLE};
constexpr size_t kFtlCapabilityCount =
sizeof(kFtlCapabilities) / sizeof(ftl::FtlCapability::Feature);
constexpr base::TimeDelta kRefreshBufferTime = …;
constexpr char kSignInGaiaPath[] = …;
constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation = …;
}
class FtlRegistrationManager::RegistrationClientImpl final
: public FtlRegistrationManager::RegistrationClient { … };
FtlRegistrationManager::RegistrationClientImpl::RegistrationClientImpl(
OAuthTokenGetter* token_getter,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: … { … }
FtlRegistrationManager::RegistrationClientImpl::~RegistrationClientImpl() =
default;
void FtlRegistrationManager::RegistrationClientImpl::SignInGaia(
const ftl::SignInGaiaRequest& request,
SignInGaiaResponseCallback on_done) { … }
void FtlRegistrationManager::RegistrationClientImpl::CancelPendingRequests() { … }
FtlRegistrationManager::FtlRegistrationManager(
OAuthTokenGetter* token_getter,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<FtlDeviceIdProvider> device_id_provider)
: … { … }
FtlRegistrationManager::FtlRegistrationManager(
std::unique_ptr<RegistrationClient> registration_client,
std::unique_ptr<FtlDeviceIdProvider> device_id_provider)
: … { … }
FtlRegistrationManager::~FtlRegistrationManager() = default;
void FtlRegistrationManager::SignInGaia(DoneCallback on_done) { … }
void FtlRegistrationManager::SignOut() { … }
bool FtlRegistrationManager::IsSignedIn() const { … }
std::string FtlRegistrationManager::GetRegistrationId() const { … }
std::string FtlRegistrationManager::GetFtlAuthToken() const { … }
void FtlRegistrationManager::DoSignInGaia(DoneCallback on_done) { … }
void FtlRegistrationManager::OnSignInGaiaResponse(
DoneCallback on_done,
const ProtobufHttpStatus& status,
std::unique_ptr<ftl::SignInGaiaResponse> response) { … }
}