Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Unified Diff: content/browser/background_fetch/background_fetch_job_controller.cc

Issue 2860593003: Refactoring DownloadManager::DownloadURL to add proper annotation. (Closed)
Patch Set: Comment addressed. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/background_fetch/background_fetch_job_controller.cc
diff --git a/content/browser/background_fetch/background_fetch_job_controller.cc b/content/browser/background_fetch/background_fetch_job_controller.cc
index 3f9ae194c2585d881db8246d8efe31eac6b7cc55..950e431209a2e8532b8545584f4883250334b0fc 100644
--- a/content/browser/background_fetch/background_fetch_job_controller.cc
+++ b/content/browser/background_fetch/background_fetch_job_controller.cc
@@ -59,7 +59,9 @@ class BackgroundFetchJobController::Core : public DownloadItem::Observer {
base::WeakPtr<Core> GetWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); }
// Starts fetching the |request| with the download manager.
- void StartRequest(scoped_refptr<BackgroundFetchRequestInfo> request) {
+ void StartRequest(
+ scoped_refptr<BackgroundFetchRequestInfo> request,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(request_context_);
DCHECK(request);
@@ -108,7 +110,8 @@ class BackgroundFetchJobController::Core : public DownloadItem::Observer {
weak_ptr_factory_.GetWeakPtr(),
std::move(request)));
- download_manager->DownloadUrl(std::move(download_parameters));
+ download_manager->DownloadUrl(std::move(download_parameters),
+ traffic_annotation);
}
// DownloadItem::Observer overrides:
@@ -236,7 +239,8 @@ BackgroundFetchJobController::BackgroundFetchJobController(
BackgroundFetchJobController::~BackgroundFetchJobController() = default;
void BackgroundFetchJobController::Start(
- std::vector<scoped_refptr<BackgroundFetchRequestInfo>> initial_requests) {
+ std::vector<scoped_refptr<BackgroundFetchRequestInfo>> initial_requests,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_LE(initial_requests.size(), kMaximumBackgroundFetchParallelRequests);
DCHECK_EQ(state_, State::INITIALIZED);
@@ -244,16 +248,17 @@ void BackgroundFetchJobController::Start(
state_ = State::FETCHING;
for (const auto& request : initial_requests)
- StartRequest(request);
+ StartRequest(request, traffic_annotation);
}
void BackgroundFetchJobController::StartRequest(
- scoped_refptr<BackgroundFetchRequestInfo> request) {
+ scoped_refptr<BackgroundFetchRequestInfo> request,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK_EQ(state_, State::FETCHING);
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&Core::StartRequest, ui_core_ptr_, std::move(request)));
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&Core::StartRequest, ui_core_ptr_,
+ std::move(request), traffic_annotation));
}
void BackgroundFetchJobController::DidStartRequest(
@@ -285,7 +290,7 @@ void BackgroundFetchJobController::DidGetNextRequest(
// If a |request| has been given, start downloading the file and bail.
if (request) {
- StartRequest(std::move(request));
+ StartRequest(std::move(request), NO_TRAFFIC_ANNOTATION_YET);
return;
}

Powered by Google App Engine
This is Rietveld 408576698