 Chromium Code Reviews
 Chromium Code Reviews Issue 2860593003:
  Refactoring DownloadManager::DownloadURL to add proper annotation.  (Closed)
    
  
    Issue 2860593003:
  Refactoring DownloadManager::DownloadURL to add proper annotation.  (Closed) 
  | 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..cb5e8f1fe2b58eaff02112b73a753c365b6faf72 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,18 @@ 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))); | 
| + base::Bind(&Core::StartRequest, ui_core_ptr_, std::move(request), | 
| + NO_TRAFFIC_ANNOTATION_YET)); | 
| 
Peter Beverloo
2017/06/01 14:17:06
should this be |traffic_annotation|? In the longer
 
Ramin Halavati
2017/06/01 14:35:53
Done, I will start adding CLs to remove NO_TRAFFIC
 | 
| } | 
| void BackgroundFetchJobController::DidStartRequest( | 
| @@ -285,7 +291,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; | 
| } |