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

Unified Diff: chrome/browser/safe_browsing/two_phase_uploader.cc

Issue 2697193003: Network traffic annotation added to safe_browsing (Closed)
Patch Set: Comments addressed. Created 3 years, 9 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: chrome/browser/safe_browsing/two_phase_uploader.cc
diff --git a/chrome/browser/safe_browsing/two_phase_uploader.cc b/chrome/browser/safe_browsing/two_phase_uploader.cc
index 07e71bbe7c40080e28a909684c5ab7289749a1d7..07fd70a4ee80cf56aaa1087634a8b4b146c7b195 100644
--- a/chrome/browser/safe_browsing/two_phase_uploader.cc
+++ b/chrome/browser/safe_browsing/two_phase_uploader.cc
@@ -33,13 +33,15 @@ const char kUploadContentType[] = "application/octet-stream";
class TwoPhaseUploaderImpl : public net::URLFetcherDelegate,
public TwoPhaseUploader {
public:
- TwoPhaseUploaderImpl(net::URLRequestContextGetter* url_request_context_getter,
- base::TaskRunner* file_task_runner,
- const GURL& base_url,
- const std::string& metadata,
- const base::FilePath& file_path,
- const ProgressCallback& progress_callback,
- const FinishCallback& finish_callback);
+ TwoPhaseUploaderImpl(
+ net::URLRequestContextGetter* url_request_context_getter,
+ base::TaskRunner* file_task_runner,
+ const GURL& base_url,
+ const std::string& metadata,
+ const base::FilePath& file_path,
+ const ProgressCallback& progress_callback,
+ const FinishCallback& finish_callback,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation);
~TwoPhaseUploaderImpl() override;
// Begins the upload process.
@@ -65,6 +67,7 @@ class TwoPhaseUploaderImpl : public net::URLFetcherDelegate,
const base::FilePath file_path_;
ProgressCallback progress_callback_;
FinishCallback finish_callback_;
+ net::NetworkTrafficAnnotationTag traffic_annotation_;
std::unique_ptr<net::URLFetcher> url_fetcher_;
@@ -78,7 +81,8 @@ TwoPhaseUploaderImpl::TwoPhaseUploaderImpl(
const std::string& metadata,
const base::FilePath& file_path,
const ProgressCallback& progress_callback,
- const FinishCallback& finish_callback)
+ const FinishCallback& finish_callback,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation)
: state_(STATE_NONE),
url_request_context_getter_(url_request_context_getter),
file_task_runner_(file_task_runner),
@@ -86,7 +90,8 @@ TwoPhaseUploaderImpl::TwoPhaseUploaderImpl(
metadata_(metadata),
file_path_(file_path),
progress_callback_(progress_callback),
- finish_callback_(finish_callback) {
+ finish_callback_(finish_callback),
+ traffic_annotation_(traffic_annotation) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
}
@@ -168,8 +173,9 @@ void TwoPhaseUploaderImpl::OnURLFetchUploadProgress(
void TwoPhaseUploaderImpl::UploadMetadata() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
state_ = UPLOAD_METADATA;
- url_fetcher_ =
- net::URLFetcher::Create(base_url_, net::URLFetcher::POST, this);
+ url_fetcher_ = net::URLFetcher::Create(base_url_, net::URLFetcher::POST, this,
+ traffic_annotation_);
+
data_use_measurement::DataUseUserData::AttachToFetcher(
url_fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING);
url_fetcher_->SetRequestContext(url_request_context_getter_.get());
@@ -182,8 +188,8 @@ void TwoPhaseUploaderImpl::UploadFile() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
state_ = UPLOAD_FILE;
- url_fetcher_ =
- net::URLFetcher::Create(upload_url_, net::URLFetcher::PUT, this);
+ url_fetcher_ = net::URLFetcher::Create(upload_url_, net::URLFetcher::PUT,
+ this, traffic_annotation_);
data_use_measurement::DataUseUserData::AttachToFetcher(
url_fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING);
url_fetcher_->SetRequestContext(url_request_context_getter_.get());
@@ -213,13 +219,14 @@ std::unique_ptr<TwoPhaseUploader> TwoPhaseUploader::Create(
const std::string& metadata,
const base::FilePath& file_path,
const ProgressCallback& progress_callback,
- const FinishCallback& finish_callback) {
+ const FinishCallback& finish_callback,
+ const net::NetworkTrafficAnnotationTag& traffic_annotation) {
if (!factory_) {
return base::WrapUnique(new TwoPhaseUploaderImpl(
url_request_context_getter, file_task_runner, base_url, metadata,
- file_path, progress_callback, finish_callback));
+ file_path, progress_callback, finish_callback, traffic_annotation));
}
return TwoPhaseUploader::factory_->CreateTwoPhaseUploader(
url_request_context_getter, file_task_runner, base_url, metadata,
- file_path, progress_callback, finish_callback);
+ file_path, progress_callback, finish_callback, traffic_annotation);
}
« no previous file with comments | « chrome/browser/safe_browsing/two_phase_uploader.h ('k') | chrome/browser/safe_browsing/two_phase_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698