#include "components/invalidation/impl/per_user_topic_subscription_request.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
HttpRequestHeaders;
namespace invalidation {
namespace {
const char kPublicTopicNameKey[] = …;
const char kPrivateTopicNameKey[] = …;
const std::string* GetTopicName(const base::Value& value) { … }
bool IsNetworkError(int net_error) { … }
enum class SubscriptionStatus { … };
void RecordRequestStatus(SubscriptionStatus status,
PerUserTopicSubscriptionRequest::RequestType type,
const std::string& topic,
int net_error = net::OK,
int response_code = 200) { … }
}
PerUserTopicSubscriptionRequest::PerUserTopicSubscriptionRequest() = default;
PerUserTopicSubscriptionRequest::~PerUserTopicSubscriptionRequest() = default;
void PerUserTopicSubscriptionRequest::Start(
CompletedCallback callback,
network::mojom::URLLoaderFactory* loader_factory) { … }
void PerUserTopicSubscriptionRequest::OnURLFetchComplete(
std::unique_ptr<std::string> response_body) { … }
void PerUserTopicSubscriptionRequest::OnURLFetchCompleteInternal(
int net_error,
int response_code,
std::unique_ptr<std::string> response_body) { … }
void PerUserTopicSubscriptionRequest::OnJsonParse(
data_decoder::DataDecoder::ValueOrError result) { … }
void PerUserTopicSubscriptionRequest::RunCompletedCallbackAndMaybeDie(
Status status,
std::string topic_name) { … }
PerUserTopicSubscriptionRequest::Builder::Builder() = default;
PerUserTopicSubscriptionRequest::Builder::~Builder() = default;
std::unique_ptr<PerUserTopicSubscriptionRequest>
PerUserTopicSubscriptionRequest::Builder::Build() const { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetInstanceIdToken(
const std::string& token) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetScope(const std::string& scope) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetAuthenticationHeader(
const std::string& auth_header) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetPublicTopicName(
const Topic& topic) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetProjectId(
const std::string& project_id) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetType(RequestType type) { … }
PerUserTopicSubscriptionRequest::Builder&
PerUserTopicSubscriptionRequest::Builder::SetTopicIsPublic(
bool topic_is_public) { … }
HttpRequestHeaders PerUserTopicSubscriptionRequest::Builder::BuildHeaders()
const { … }
std::string PerUserTopicSubscriptionRequest::Builder::BuildBody() const { … }
std::unique_ptr<network::SimpleURLLoader>
PerUserTopicSubscriptionRequest::Builder::BuildURLFetcher(
const HttpRequestHeaders& headers,
const std::string& body,
const GURL& url) const { … }
}