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

Side by Side Diff: components/domain_reliability/context.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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/domain_reliability/context.h" 5 #include "components/domain_reliability/context.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 min_delay, 216 min_delay,
217 max_delay); 217 max_delay);
218 } 218 }
219 219
220 void DomainReliabilityContext::StartUpload() { 220 void DomainReliabilityContext::StartUpload() {
221 MarkUpload(); 221 MarkUpload();
222 222
223 DCHECK(upload_time_.is_null()); 223 DCHECK(upload_time_.is_null());
224 upload_time_ = time_->NowTicks(); 224 upload_time_ = time_->NowTicks();
225 std::string report_json; 225 std::string report_json;
226 scoped_ptr<const Value> report_value(CreateReport(upload_time_)); 226 base::JSONWriter::Write(*CreateReport(upload_time_), &report_json);
227 base::JSONWriter::Write(report_value.get(), &report_json);
228 report_value.reset();
229 227
230 size_t collector_index = scheduler_.OnUploadStart(); 228 size_t collector_index = scheduler_.OnUploadStart();
231 229
232 uploader_->UploadReport( 230 uploader_->UploadReport(
233 report_json, 231 report_json,
234 config_->collectors[collector_index]->upload_url, 232 config_->collectors[collector_index]->upload_url,
235 base::Bind( 233 base::Bind(
236 &DomainReliabilityContext::OnUploadComplete, 234 &DomainReliabilityContext::OnUploadComplete,
237 weak_factory_.GetWeakPtr())); 235 weak_factory_.GetWeakPtr()));
238 236
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 beacon.ToValue(upload_time, *last_network_change_time_)); 272 beacon.ToValue(upload_time, *last_network_change_time_));
275 } 273 }
276 274
277 scoped_ptr<ListValue> resources_value(new ListValue()); 275 scoped_ptr<ListValue> resources_value(new ListValue());
278 for (const auto& state : states_) { 276 for (const auto& state : states_) {
279 scoped_ptr<Value> resource_report = state->ToValue(upload_time); 277 scoped_ptr<Value> resource_report = state->ToValue(upload_time);
280 if (resource_report) 278 if (resource_report)
281 resources_value->Append(resource_report.release()); 279 resources_value->Append(resource_report.release());
282 } 280 }
283 281
284 DictionaryValue* report_value = new DictionaryValue(); 282 scoped_ptr<DictionaryValue> report_value(new DictionaryValue());
285 if (!config().version.empty()) 283 if (!config().version.empty())
286 report_value->SetString("config_version", config().version); 284 report_value->SetString("config_version", config().version);
287 report_value->SetString("reporter", upload_reporter_string_); 285 report_value->SetString("reporter", upload_reporter_string_);
288 report_value->Set("entries", beacons_value.release()); 286 report_value->Set("entries", beacons_value.release());
289 if (!resources_value->empty()) 287 if (!resources_value->empty())
290 report_value->Set("resources", resources_value.release()); 288 report_value->Set("resources", resources_value.release());
291 289
292 return scoped_ptr<const Value>(report_value); 290 return report_value.Pass();
293 } 291 }
294 292
295 void DomainReliabilityContext::MarkUpload() { 293 void DomainReliabilityContext::MarkUpload() {
296 for (auto& state : states_) 294 for (auto& state : states_)
297 state->MarkUpload(); 295 state->MarkUpload();
298 DCHECK_EQ(0u, uploading_beacons_size_); 296 DCHECK_EQ(0u, uploading_beacons_size_);
299 uploading_beacons_size_ = beacons_.size(); 297 uploading_beacons_size_ = beacons_.size();
300 DCHECK_NE(0u, uploading_beacons_size_); 298 DCHECK_NE(0u, uploading_beacons_size_);
301 } 299 }
302 300
(...skipping 22 matching lines...) Expand all
325 323
326 beacons_.pop_front(); 324 beacons_.pop_front();
327 325
328 // If that just removed a beacon counted in uploading_beacons_size_, decrement 326 // If that just removed a beacon counted in uploading_beacons_size_, decrement
329 // that. 327 // that.
330 if (uploading_beacons_size_ > 0) 328 if (uploading_beacons_size_ > 0)
331 --uploading_beacons_size_; 329 --uploading_beacons_size_;
332 } 330 }
333 331
334 } // namespace domain_reliability 332 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/dom_distiller/core/viewer.cc ('k') | components/error_page/renderer/net_error_helper_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698