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