Skip to content

Instantly share code, notes, and snippets.

@t4kemyh4nd
Last active October 15, 2023 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t4kemyh4nd/a52f7f31023f31440640814f3322b6b2 to your computer and use it in GitHub Desktop.
Save t4kemyh4nd/a52f7f31023f31440640814f3322b6b2 to your computer and use it in GitHub Desktop.
webapk_installer.cc
void WebApkInstaller::SendRequest(
const net::NetworkTrafficAnnotationTag& traffic_annotation,
const std::string& serialized_proto) {
DCHECK(server_url_.is_valid());
timer_.Start(
FROM_HERE, base::Milliseconds(webapk_server_timeout_ms_),
base::BindOnce(&WebApkInstaller::OnResult, weak_ptr_factory_.GetWeakPtr(),
webapps::WebApkInstallResult::REQUEST_TIMEOUT));
auto request = std::make_unique<network::ResourceRequest>();
request->url = server_url_;
request->method = "POST";
request->load_flags = net::LOAD_DISABLE_CACHE;
request->credentials_mode = network::mojom::CredentialsMode::kOmit;
loader_ =
network::SimpleURLLoader::Create(std::move(request), traffic_annotation);
loader_->AttachStringForUpload(serialized_proto, kProtoMimeType);
loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
GetURLLoaderFactory(browser_context_),
base::BindOnce(&WebApkInstaller::OnURLLoaderComplete,
weak_ptr_factory_.GetWeakPtr()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment