#include "remoting/signaling/ftl_messaging_client.h"
#include <utility>
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/time/time.h"
#include "base/uuid.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/base/protobuf_http_stream_request.h"
#include "remoting/signaling/ftl_message_reception_channel.h"
#include "remoting/signaling/ftl_services_context.h"
#include "remoting/signaling/registration_manager.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace remoting {
namespace {
constexpr char kBatchAckMessagesPath[] = …;
constexpr char kReceiveMessagesPath[] = …;
constexpr char kSendMessagePath[] = …;
constexpr net::NetworkTrafficAnnotationTag kAckMessagesTrafficAnnotation = …;
constexpr net::NetworkTrafficAnnotationTag kReceiveMessagesTrafficAnnotation = …;
constexpr net::NetworkTrafficAnnotationTag kSendMessageTrafficAnnotation = …;
constexpr base::TimeDelta kInboxMessageTtl = …;
}
FtlMessagingClient::FtlMessagingClient(
OAuthTokenGetter* token_getter,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
RegistrationManager* registration_manager,
SignalingTracker* signaling_tracker)
: … { … }
FtlMessagingClient::FtlMessagingClient(
std::unique_ptr<ProtobufHttpClient> client,
RegistrationManager* registration_manager,
std::unique_ptr<MessageReceptionChannel> channel) { … }
FtlMessagingClient::~FtlMessagingClient() = default;
base::CallbackListSubscription FtlMessagingClient::RegisterMessageCallback(
const MessageCallback& callback) { … }
void FtlMessagingClient::SendMessage(
const std::string& destination,
const std::string& destination_registration_id,
const ftl::ChromotingMessage& message,
DoneCallback on_done) { … }
void FtlMessagingClient::StartReceivingMessages(base::OnceClosure on_ready,
DoneCallback on_closed) { … }
void FtlMessagingClient::StopReceivingMessages() { … }
bool FtlMessagingClient::IsReceivingMessages() const { … }
template <typename CallbackFunctor>
void FtlMessagingClient::ExecuteRequest(
const net::NetworkTrafficAnnotationTag& tag,
const std::string& path,
std::unique_ptr<google::protobuf::MessageLite> request,
CallbackFunctor callback_functor,
DoneCallback on_done) { … }
void FtlMessagingClient::OnSendMessageResponse(
DoneCallback on_done,
const ProtobufHttpStatus& status,
std::unique_ptr<ftl::InboxSendResponse> response) { … }
void FtlMessagingClient::BatchAckMessages(
const ftl::BatchAckMessagesRequest& request,
DoneCallback on_done) { … }
void FtlMessagingClient::OnBatchAckMessagesResponse(
DoneCallback on_done,
const ProtobufHttpStatus& status,
std::unique_ptr<ftl::BatchAckMessagesResponse> response) { … }
std::unique_ptr<ScopedProtobufHttpRequest>
FtlMessagingClient::OpenReceiveMessagesStream(
base::OnceClosure on_channel_ready,
const base::RepeatingCallback<
void(std::unique_ptr<ftl::ReceiveMessagesResponse>)>& on_incoming_msg,
base::OnceCallback<void(const ProtobufHttpStatus&)> on_channel_closed) { … }
void FtlMessagingClient::RunMessageCallbacks(const ftl::InboxMessage& message) { … }
void FtlMessagingClient::OnMessageReceived(const ftl::InboxMessage& message) { … }
}