#include "google_apis/gcm/engine/registration_request.h"
#include <stddef.h>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/values.h"
#include "google_apis/credentials_mode.h"
#include "google_apis/gcm/base/gcm_util.h"
#include "google_apis/gcm/monitoring/gcm_stats_recorder.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
namespace gcm {
namespace {
const char kRegistrationRequestContentType[] = …;
const char kCategoryKey[] = …;
const char kSubtypeKey[] = …;
const char kDeviceIdKey[] = …;
const char kLoginHeader[] = …;
const char kErrorPrefix[] = …;
const char kTokenPrefix[] = …;
const char kDeviceRegistrationError[] = …;
const char kAuthenticationFailed[] = …;
const char kInvalidSender[] = …;
const char kInvalidParameters[] = …;
const char kInternalServerError[] = …;
const char kQuotaExceeded[] = …;
const char kTooManyRegistrations[] = …;
const char kTooManySubscribers[] = …;
const char kInvalidTargetVersion[] = …;
const char kFisAuthError[] = …;
RegistrationRequest::Status GetStatusFromError(const std::string& error) { … }
bool ShouldRetryWithStatus(RegistrationRequest::Status status) { … }
}
RegistrationRequest::RequestInfo::RequestInfo(uint64_t android_id,
uint64_t security_token,
const std::string& category,
const std::string& subtype)
: … { … }
RegistrationRequest::RequestInfo::~RequestInfo() { … }
RegistrationRequest::CustomRequestHandler::CustomRequestHandler() { … }
RegistrationRequest::CustomRequestHandler::~CustomRequestHandler() { … }
RegistrationRequest::RegistrationRequest(
const GURL& registration_url,
const RequestInfo& request_info,
std::unique_ptr<CustomRequestHandler> custom_request_handler,
const net::BackoffEntry::Policy& backoff_policy,
RegistrationCallback callback,
int max_retry_count,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
scoped_refptr<base::SequencedTaskRunner> io_task_runner,
GCMStatsRecorder* recorder,
const std::string& source_to_record)
: … { … }
RegistrationRequest::~RegistrationRequest() { … }
void RegistrationRequest::Start() { … }
void RegistrationRequest::BuildRequestHeaders(
net::HttpRequestHeaders* headers) { … }
void RegistrationRequest::BuildRequestBody(std::string* body) { … }
void RegistrationRequest::RetryWithBackoff() { … }
RegistrationRequest::Status RegistrationRequest::ParseResponse(
const network::SimpleURLLoader* source,
std::unique_ptr<std::string> body,
std::string* token) { … }
void RegistrationRequest::OnURLLoadComplete(
const network::SimpleURLLoader* source,
std::unique_ptr<std::string> body) { … }
}