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.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "net/base/load_flags.h" | 9 #include "net/base/load_flags.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 !queued_logs_.empty() && | 101 !queued_logs_.empty() && |
102 !IsUploadScheduled() && | 102 !IsUploadScheduled() && |
103 !has_callback_pending_; | 103 !has_callback_pending_; |
104 } | 104 } |
105 | 105 |
106 void LogUploader::StartScheduledUpload() { | 106 void LogUploader::StartScheduledUpload() { |
107 if (!CanStartUpload()) | 107 if (!CanStartUpload()) |
108 return; | 108 return; |
109 DVLOG(2) << "Upload to " << server_url_.spec() << " starting."; | 109 DVLOG(2) << "Upload to " << server_url_.spec() << " starting."; |
110 has_callback_pending_ = true; | 110 has_callback_pending_ = true; |
111 current_fetch_.reset( | 111 current_fetch_ = |
112 net::URLFetcher::Create(server_url_, net::URLFetcher::POST, this)); | 112 net::URLFetcher::Create(server_url_, net::URLFetcher::POST, this); |
113 current_fetch_->SetRequestContext(request_context_.get()); | 113 current_fetch_->SetRequestContext(request_context_.get()); |
114 current_fetch_->SetUploadData(mime_type_, queued_logs_.front()); | 114 current_fetch_->SetUploadData(mime_type_, queued_logs_.front()); |
115 | 115 |
116 // 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 |
117 // client-side as well. | 117 // client-side as well. |
118 current_fetch_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 118 current_fetch_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
119 net::LOAD_DO_NOT_SEND_COOKIES); | 119 net::LOAD_DO_NOT_SEND_COOKIES); |
120 current_fetch_->Start(); | 120 current_fetch_->Start(); |
121 } | 121 } |
122 | 122 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (!server_is_healthy) | 186 if (!server_is_healthy) |
187 upload_interval_ = BackOffUploadInterval(upload_interval_); | 187 upload_interval_ = BackOffUploadInterval(upload_interval_); |
188 else | 188 else |
189 upload_interval_ = base::TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds); | 189 upload_interval_ = base::TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds); |
190 | 190 |
191 if (CanStartUpload()) | 191 if (CanStartUpload()) |
192 ScheduleNextUpload(upload_interval_); | 192 ScheduleNextUpload(upload_interval_); |
193 } | 193 } |
194 | 194 |
195 } // namespace rappor | 195 } // namespace rappor |
OLD | NEW |