1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_UPDATE_CLIENT_NET_NETWORK_IMPL_H_
#define COMPONENTS_UPDATE_CLIENT_NET_NETWORK_IMPL_H_
#include <stdint.h>
#include <memory>
#include <string>
#include "base/functional/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/update_client/net/network_chromium.h"
#include "components/update_client/network.h"
#include "services/network/public/mojom/url_response_head.mojom-forward.h"
namespace network {
class SharedURLLoaderFactory;
} // namespace network
namespace update_client {
class NetworkFetcherImpl : public NetworkFetcher {
public:
explicit NetworkFetcherImpl(
scoped_refptr<network::SharedURLLoaderFactory> shared_url_network_factory,
SendCookiesPredicate cookie_predicate);
NetworkFetcherImpl(const NetworkFetcherImpl&) = delete;
NetworkFetcherImpl& operator=(const NetworkFetcherImpl&) = delete;
~NetworkFetcherImpl() override;
// NetworkFetcher overrides.
void PostRequest(
const GURL& url,
const std::string& post_data,
const std::string& content_type,
const base::flat_map<std::string, std::string>& post_additional_headers,
ResponseStartedCallback response_started_callback,
ProgressCallback progress_callback,
PostRequestCompleteCallback post_request_complete_callback) override;
base::OnceClosure DownloadToFile(
const GURL& url,
const base::FilePath& file_path,
ResponseStartedCallback response_started_callback,
ProgressCallback progress_callback,
DownloadToFileCompleteCallback download_to_file_complete_callback)
override;
private:
void OnResponseStartedCallback(
ResponseStartedCallback response_started_callback,
const GURL& final_url,
const network::mojom::URLResponseHead& response_head);
void OnProgressCallback(ProgressCallback response_started_callback,
uint64_t current);
static constexpr int kMaxRetriesOnNetworkChange = 3;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_network_factory_;
SendCookiesPredicate cookie_predicate_;
base::WeakPtrFactory<NetworkFetcherImpl> weak_ptr_factory_{this};
};
} // namespace update_client
#endif // COMPONENTS_UPDATE_CLIENT_NET_NETWORK_IMPL_H_
|