OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/rappor/log_uploader.h" | 5 #include "components/rappor/log_uploader.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "components/data_use_measurement/core/data_use_user_data.h" |
9 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
11 #include "net/url_request/url_fetcher.h" | 12 #include "net/url_request/url_fetcher.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // The delay, in seconds, between uploading when there are queued logs to send. | 16 // The delay, in seconds, between uploading when there are queued logs to send. |
16 const int kUnsentLogsIntervalSeconds = 3; | 17 const int kUnsentLogsIntervalSeconds = 3; |
17 | 18 |
18 // When uploading metrics to the server fails, we progressively wait longer and | 19 // When uploading metrics to the server fails, we progressively wait longer and |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 !has_callback_pending_; | 104 !has_callback_pending_; |
104 } | 105 } |
105 | 106 |
106 void LogUploader::StartScheduledUpload() { | 107 void LogUploader::StartScheduledUpload() { |
107 if (!CanStartUpload()) | 108 if (!CanStartUpload()) |
108 return; | 109 return; |
109 DVLOG(2) << "Upload to " << server_url_.spec() << " starting."; | 110 DVLOG(2) << "Upload to " << server_url_.spec() << " starting."; |
110 has_callback_pending_ = true; | 111 has_callback_pending_ = true; |
111 current_fetch_ = | 112 current_fetch_ = |
112 net::URLFetcher::Create(server_url_, net::URLFetcher::POST, this); | 113 net::URLFetcher::Create(server_url_, net::URLFetcher::POST, this); |
| 114 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 115 current_fetch_.get(), data_use_measurement::DataUseUserData::RAPPOR); |
113 current_fetch_->SetRequestContext(request_context_.get()); | 116 current_fetch_->SetRequestContext(request_context_.get()); |
114 current_fetch_->SetUploadData(mime_type_, queued_logs_.front()); | 117 current_fetch_->SetUploadData(mime_type_, queued_logs_.front()); |
115 | 118 |
116 // We already drop cookies server-side, but we might as well strip them out | 119 // We already drop cookies server-side, but we might as well strip them out |
117 // client-side as well. | 120 // client-side as well. |
118 current_fetch_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 121 current_fetch_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
119 net::LOAD_DO_NOT_SEND_COOKIES); | 122 net::LOAD_DO_NOT_SEND_COOKIES); |
120 current_fetch_->Start(); | 123 current_fetch_->Start(); |
121 } | 124 } |
122 | 125 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (!server_is_healthy) | 189 if (!server_is_healthy) |
187 upload_interval_ = BackOffUploadInterval(upload_interval_); | 190 upload_interval_ = BackOffUploadInterval(upload_interval_); |
188 else | 191 else |
189 upload_interval_ = base::TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds); | 192 upload_interval_ = base::TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds); |
190 | 193 |
191 if (CanStartUpload()) | 194 if (CanStartUpload()) |
192 ScheduleNextUpload(upload_interval_); | 195 ScheduleNextUpload(upload_interval_); |
193 } | 196 } |
194 | 197 |
195 } // namespace rappor | 198 } // namespace rappor |
OLD | NEW |