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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser vice.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9
10 #include <algorithm> 9 #include <algorithm>
10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/process/process_info.h" 17 #include "base/process/process_info.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/stl_util.h" 19 #include "base/stl_util.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 IncidentReportingService::Receiver::~Receiver() { 203 IncidentReportingService::Receiver::~Receiver() {
204 } 204 }
205 205
206 void IncidentReportingService::Receiver::AddIncidentForProfile( 206 void IncidentReportingService::Receiver::AddIncidentForProfile(
207 Profile* profile, 207 Profile* profile,
208 scoped_ptr<Incident> incident) { 208 scoped_ptr<Incident> incident) {
209 DCHECK(thread_runner_->BelongsToCurrentThread()); 209 DCHECK(thread_runner_->BelongsToCurrentThread());
210 DCHECK(profile); 210 DCHECK(profile);
211 AddIncidentOnMainThread(service_, profile, incident.Pass()); 211 AddIncidentOnMainThread(service_, profile, std::move(incident));
212 } 212 }
213 213
214 void IncidentReportingService::Receiver::AddIncidentForProcess( 214 void IncidentReportingService::Receiver::AddIncidentForProcess(
215 scoped_ptr<Incident> incident) { 215 scoped_ptr<Incident> incident) {
216 if (thread_runner_->BelongsToCurrentThread()) { 216 if (thread_runner_->BelongsToCurrentThread()) {
217 AddIncidentOnMainThread(service_, nullptr, incident.Pass()); 217 AddIncidentOnMainThread(service_, nullptr, std::move(incident));
218 } else if (!thread_runner_->PostTask( 218 } else if (!thread_runner_->PostTask(
219 FROM_HERE, 219 FROM_HERE,
220 base::Bind(&IncidentReportingService::Receiver::AddIncidentOnMainThread, 220 base::Bind(&IncidentReportingService::Receiver::AddIncidentOnMainThread,
221 service_, nullptr, base::Passed(&incident)))) { 221 service_, nullptr, base::Passed(&incident)))) {
222 LogIncidentDataType(DISCARDED, *incident); 222 LogIncidentDataType(DISCARDED, *incident);
223 } 223 }
224 } 224 }
225 225
226 void IncidentReportingService::Receiver::ClearIncidentForProcess( 226 void IncidentReportingService::Receiver::ClearIncidentForProcess(
227 scoped_ptr<Incident> incident) { 227 scoped_ptr<Incident> incident) {
228 if (thread_runner_->BelongsToCurrentThread()) { 228 if (thread_runner_->BelongsToCurrentThread()) {
229 ClearIncidentOnMainThread(service_, nullptr, incident.Pass()); 229 ClearIncidentOnMainThread(service_, nullptr, std::move(incident));
230 } else { 230 } else {
231 thread_runner_->PostTask( 231 thread_runner_->PostTask(
232 FROM_HERE, 232 FROM_HERE,
233 base::Bind( 233 base::Bind(
234 &IncidentReportingService::Receiver::ClearIncidentOnMainThread, 234 &IncidentReportingService::Receiver::ClearIncidentOnMainThread,
235 service_, nullptr, base::Passed(&incident))); 235 service_, nullptr, base::Passed(&incident)));
236 } 236 }
237 } 237 }
238 238
239 bool IncidentReportingService::HasIncidentsToUpload() const { 239 bool IncidentReportingService::HasIncidentsToUpload() const {
240 for (const auto& profile_and_context : profiles_) { 240 for (const auto& profile_and_context : profiles_) {
241 if (!profile_and_context.second->incidents.empty()) 241 if (!profile_and_context.second->incidents.empty())
242 return true; 242 return true;
243 } 243 }
244 return false; 244 return false;
245 } 245 }
246 246
247 // static 247 // static
248 void IncidentReportingService::Receiver::AddIncidentOnMainThread( 248 void IncidentReportingService::Receiver::AddIncidentOnMainThread(
249 const base::WeakPtr<IncidentReportingService>& service, 249 const base::WeakPtr<IncidentReportingService>& service,
250 Profile* profile, 250 Profile* profile,
251 scoped_ptr<Incident> incident) { 251 scoped_ptr<Incident> incident) {
252 if (service) 252 if (service)
253 service->AddIncident(profile, incident.Pass()); 253 service->AddIncident(profile, std::move(incident));
254 else 254 else
255 LogIncidentDataType(DISCARDED, *incident); 255 LogIncidentDataType(DISCARDED, *incident);
256 } 256 }
257 257
258 // static 258 // static
259 void IncidentReportingService::Receiver::ClearIncidentOnMainThread( 259 void IncidentReportingService::Receiver::ClearIncidentOnMainThread(
260 const base::WeakPtr<IncidentReportingService>& service, 260 const base::WeakPtr<IncidentReportingService>& service,
261 Profile* profile, 261 Profile* profile,
262 scoped_ptr<Incident> incident) { 262 scoped_ptr<Incident> incident) {
263 if (service) 263 if (service)
264 service->ClearIncident(profile, incident.Pass()); 264 service->ClearIncident(profile, std::move(incident));
265 } 265 }
266 266
267 IncidentReportingService::ProfileContext::ProfileContext() : added(false) { 267 IncidentReportingService::ProfileContext::ProfileContext() : added(false) {
268 } 268 }
269 269
270 IncidentReportingService::ProfileContext::~ProfileContext() { 270 IncidentReportingService::ProfileContext::~ProfileContext() {
271 for (const auto& incident : incidents) { 271 for (const auto& incident : incidents) {
272 if (incident) 272 if (incident)
273 LogIncidentDataType(DISCARDED, *incident); 273 LogIncidentDataType(DISCARDED, *incident);
274 } 274 }
275 } 275 }
276 276
277 bool IncidentReportingService::ProfileContext::HasIncidents() const { 277 bool IncidentReportingService::ProfileContext::HasIncidents() const {
278 return !incidents.empty() || !incidents_to_clear.empty(); 278 return !incidents.empty() || !incidents_to_clear.empty();
279 } 279 }
280 280
281 IncidentReportingService::UploadContext::UploadContext( 281 IncidentReportingService::UploadContext::UploadContext(
282 scoped_ptr<ClientIncidentReport> report) 282 scoped_ptr<ClientIncidentReport> report)
283 : report(report.Pass()) { 283 : report(std::move(report)) {}
284 }
285 284
286 IncidentReportingService::UploadContext::~UploadContext() { 285 IncidentReportingService::UploadContext::~UploadContext() {
287 } 286 }
288 287
289 // static 288 // static
290 bool IncidentReportingService::IsEnabledForProfile(Profile* profile) { 289 bool IncidentReportingService::IsEnabledForProfile(Profile* profile) {
291 if (profile->IsOffTheRecord()) 290 if (profile->IsOffTheRecord())
292 return false; 291 return false;
293 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) 292 if (!profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled))
294 return false; 293 return false;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 BeginEnvironmentCollection(); 495 BeginEnvironmentCollection();
497 // Take another stab at finding the most recent download if a report is being 496 // Take another stab at finding the most recent download if a report is being
498 // assembled and one hasn't been found yet (the LastDownloadFinder operates 497 // assembled and one hasn't been found yet (the LastDownloadFinder operates
499 // only on profiles that have been added to the ProfileManager). 498 // only on profiles that have been added to the ProfileManager).
500 BeginDownloadCollection(); 499 BeginDownloadCollection();
501 } 500 }
502 501
503 scoped_ptr<LastDownloadFinder> IncidentReportingService::CreateDownloadFinder( 502 scoped_ptr<LastDownloadFinder> IncidentReportingService::CreateDownloadFinder(
504 const LastDownloadFinder::LastDownloadCallback& callback) { 503 const LastDownloadFinder::LastDownloadCallback& callback) {
505 return LastDownloadFinder::Create( 504 return LastDownloadFinder::Create(
506 base::Bind(&DownloadMetadataManager::GetDownloadDetails, 505 base::Bind(&DownloadMetadataManager::GetDownloadDetails,
507 base::Unretained(&download_metadata_manager_)), 506 base::Unretained(&download_metadata_manager_)),
508 callback).Pass(); 507 callback);
509 } 508 }
510 509
511 scoped_ptr<IncidentReportUploader> IncidentReportingService::StartReportUpload( 510 scoped_ptr<IncidentReportUploader> IncidentReportingService::StartReportUpload(
512 const IncidentReportUploader::OnResultCallback& callback, 511 const IncidentReportUploader::OnResultCallback& callback,
513 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 512 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
514 const ClientIncidentReport& report) { 513 const ClientIncidentReport& report) {
515 return IncidentReportUploaderImpl::UploadReport( 514 return IncidentReportUploaderImpl::UploadReport(
516 callback, request_context_getter, report).Pass(); 515 callback, request_context_getter, report);
517 } 516 }
518 517
519 bool IncidentReportingService::IsProcessingReport() const { 518 bool IncidentReportingService::IsProcessingReport() const {
520 return report_ != NULL; 519 return report_ != NULL;
521 } 520 }
522 521
523 IncidentReportingService::ProfileContext* 522 IncidentReportingService::ProfileContext*
524 IncidentReportingService::GetOrCreateProfileContext(Profile* profile) { 523 IncidentReportingService::GetOrCreateProfileContext(Profile* profile) {
525 ProfileContextCollection::iterator it = 524 ProfileContextCollection::iterator it =
526 profiles_.insert(ProfileContextCollection::value_type(profile, NULL)) 525 profiles_.insert(ProfileContextCollection::value_type(profile, NULL))
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 601
603 // Drop the incident immediately if the profile has already been added to the 602 // Drop the incident immediately if the profile has already been added to the
604 // manager and does not have incident reporting enabled. Preference evaluation 603 // manager and does not have incident reporting enabled. Preference evaluation
605 // is deferred until OnProfileAdded() otherwise. 604 // is deferred until OnProfileAdded() otherwise.
606 if (context->added && !IsEnabledForProfile(profile)) { 605 if (context->added && !IsEnabledForProfile(profile)) {
607 LogIncidentDataType(DROPPED, *incident); 606 LogIncidentDataType(DROPPED, *incident);
608 return; 607 return;
609 } 608 }
610 609
611 // Take ownership of the incident. 610 // Take ownership of the incident.
612 context->incidents.push_back(incident.Pass()); 611 context->incidents.push_back(std::move(incident));
613 612
614 // Remember when the first incident for this report arrived. 613 // Remember when the first incident for this report arrived.
615 if (first_incident_time_.is_null()) 614 if (first_incident_time_.is_null())
616 first_incident_time_ = base::Time::Now(); 615 first_incident_time_ = base::Time::Now();
617 // Log the time between the previous incident and this one. 616 // Log the time between the previous incident and this one.
618 if (!last_incident_time_.is_null()) { 617 if (!last_incident_time_.is_null()) {
619 UMA_HISTOGRAM_TIMES("SBIRS.InterIncidentTime", 618 UMA_HISTOGRAM_TIMES("SBIRS.InterIncidentTime",
620 base::TimeTicks::Now() - last_incident_time_); 619 base::TimeTicks::Now() - last_incident_time_);
621 } 620 }
622 last_incident_time_ = base::TimeTicks::Now(); 621 last_incident_time_ = base::TimeTicks::Now();
623 622
624 // Persist the incident data. 623 // Persist the incident data.
625 624
626 // Start assembling a new report if this is the first incident ever or the 625 // Start assembling a new report if this is the first incident ever or the
627 // first since the last upload. 626 // first since the last upload.
628 BeginReportProcessing(); 627 BeginReportProcessing();
629 } 628 }
630 629
631 void IncidentReportingService::ClearIncident(Profile* profile, 630 void IncidentReportingService::ClearIncident(Profile* profile,
632 scoped_ptr<Incident> incident) { 631 scoped_ptr<Incident> incident) {
633 ProfileContext* context = GetOrCreateProfileContext(profile); 632 ProfileContext* context = GetOrCreateProfileContext(profile);
634 context->incidents_to_clear.push_back(incident.Pass()); 633 context->incidents_to_clear.push_back(std::move(incident));
635 // Begin processing to handle cleared incidents following collation. 634 // Begin processing to handle cleared incidents following collation.
636 BeginReportProcessing(); 635 BeginReportProcessing();
637 } 636 }
638 637
639 void IncidentReportingService::BeginReportProcessing() { 638 void IncidentReportingService::BeginReportProcessing() {
640 DCHECK(thread_checker_.CalledOnValidThread()); 639 DCHECK(thread_checker_.CalledOnValidThread());
641 640
642 // Creates a new report if needed. 641 // Creates a new report if needed.
643 if (!report_) 642 if (!report_)
644 report_.reset(new ClientIncidentReport()); 643 report_.reset(new ClientIncidentReport());
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 void IncidentReportingService::ProcessIncidentsIfCollectionComplete() { 826 void IncidentReportingService::ProcessIncidentsIfCollectionComplete() {
828 DCHECK(report_); 827 DCHECK(report_);
829 // Bail out if there are still outstanding collection tasks. Completion of any 828 // Bail out if there are still outstanding collection tasks. Completion of any
830 // of these will start another upload attempt. 829 // of these will start another upload attempt.
831 if (WaitingForEnvironmentCollection() || WaitingToCollateIncidents() || 830 if (WaitingForEnvironmentCollection() || WaitingToCollateIncidents() ||
832 WaitingForMostRecentDownload()) { 831 WaitingForMostRecentDownload()) {
833 return; 832 return;
834 } 833 }
835 834
836 // Take ownership of the report and clear things for future reports. 835 // Take ownership of the report and clear things for future reports.
837 scoped_ptr<ClientIncidentReport> report(report_.Pass()); 836 scoped_ptr<ClientIncidentReport> report(std::move(report_));
838 first_incident_time_ = base::Time(); 837 first_incident_time_ = base::Time();
839 last_incident_time_ = base::TimeTicks(); 838 last_incident_time_ = base::TimeTicks();
840 839
841 ClientIncidentReport_EnvironmentData_Process* process = 840 ClientIncidentReport_EnvironmentData_Process* process =
842 report->mutable_environment()->mutable_process(); 841 report->mutable_environment()->mutable_process();
843 842
844 process->set_metrics_consent( 843 process->set_metrics_consent(
845 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()); 844 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled());
846 845
847 // Find the profile that benefits from the strongest protections. 846 // Find the profile that benefits from the strongest protections.
848 Profile* eligible_profile = FindEligibleProfile(); 847 Profile* eligible_profile = FindEligibleProfile();
849 process->set_extended_consent( 848 process->set_extended_consent(
850 eligible_profile ? eligible_profile->GetPrefs()->GetBoolean( 849 eligible_profile ? eligible_profile->GetPrefs()->GetBoolean(
851 prefs::kSafeBrowsingExtendedReportingEnabled) : 850 prefs::kSafeBrowsingExtendedReportingEnabled) :
852 false); 851 false);
853 852
854 process->set_field_trial_participant(enabled_by_field_trial_); 853 process->set_field_trial_participant(enabled_by_field_trial_);
855 854
856 // Associate process-wide incidents with the profile that benefits from the 855 // Associate process-wide incidents with the profile that benefits from the
857 // strongest safe browsing protections. If there is no such profile, drop the 856 // strongest safe browsing protections. If there is no such profile, drop the
858 // incidents. 857 // incidents.
859 ProfileContext* null_context = GetProfileContext(NULL); 858 ProfileContext* null_context = GetProfileContext(NULL);
860 if (null_context && null_context->HasIncidents()) { 859 if (null_context && null_context->HasIncidents()) {
861 if (eligible_profile) { 860 if (eligible_profile) {
862 ProfileContext* eligible_context = GetProfileContext(eligible_profile); 861 ProfileContext* eligible_context = GetProfileContext(eligible_profile);
863 // Move the incidents to the target context. 862 // Move the incidents to the target context.
864 for (auto& incident : null_context->incidents) { 863 for (auto& incident : null_context->incidents) {
865 eligible_context->incidents.push_back(incident.Pass()); 864 eligible_context->incidents.push_back(std::move(incident));
866 } 865 }
867 null_context->incidents.clear(); 866 null_context->incidents.clear();
868 for (auto& incident : null_context->incidents_to_clear) 867 for (auto& incident : null_context->incidents_to_clear)
869 eligible_context->incidents_to_clear.push_back(incident.Pass()); 868 eligible_context->incidents_to_clear.push_back(std::move(incident));
870 null_context->incidents_to_clear.clear(); 869 null_context->incidents_to_clear.clear();
871 } else { 870 } else {
872 for (const auto& incident : null_context->incidents) 871 for (const auto& incident : null_context->incidents)
873 LogIncidentDataType(DROPPED, *incident); 872 LogIncidentDataType(DROPPED, *incident);
874 null_context->incidents.clear(); 873 null_context->incidents.clear();
875 } 874 }
876 } 875 }
877 876
878 // Clear incidents data where needed. 877 // Clear incidents data where needed.
879 for (auto& profile_and_context : profiles_) { 878 for (auto& profile_and_context : profiles_) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 IncidentReportUploader::NUM_UPLOAD_RESULTS); 952 IncidentReportUploader::NUM_UPLOAD_RESULTS);
954 } 953 }
955 return; 954 return;
956 } 955 }
957 956
958 UMA_HISTOGRAM_COUNTS_100("SBIRS.IncidentCount", count); 957 UMA_HISTOGRAM_COUNTS_100("SBIRS.IncidentCount", count);
959 958
960 // Perform final synchronous collection tasks for the report. 959 // Perform final synchronous collection tasks for the report.
961 DoExtensionCollection(report->mutable_extension_data()); 960 DoExtensionCollection(report->mutable_extension_data());
962 961
963 scoped_ptr<UploadContext> context(new UploadContext(report.Pass())); 962 scoped_ptr<UploadContext> context(new UploadContext(std::move(report)));
964 context->profiles_to_state.swap(profiles_to_state); 963 context->profiles_to_state.swap(profiles_to_state);
965 if (!database_manager_.get()) { 964 if (!database_manager_.get()) {
966 // No database manager during testing. Take ownership of the context and 965 // No database manager during testing. Take ownership of the context and
967 // continue processing. 966 // continue processing.
968 UploadContext* temp_context = context.get(); 967 UploadContext* temp_context = context.get();
969 uploads_.push_back(context.Pass()); 968 uploads_.push_back(std::move(context));
970 IncidentReportingService::OnKillSwitchResult(temp_context, false); 969 IncidentReportingService::OnKillSwitchResult(temp_context, false);
971 } else { 970 } else {
972 if (content::BrowserThread::PostTaskAndReplyWithResult( 971 if (content::BrowserThread::PostTaskAndReplyWithResult(
973 content::BrowserThread::IO, 972 content::BrowserThread::IO,
974 FROM_HERE, 973 FROM_HERE,
975 base::Bind(&SafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn, 974 base::Bind(&SafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn,
976 database_manager_), 975 database_manager_),
977 base::Bind(&IncidentReportingService::OnKillSwitchResult, 976 base::Bind(&IncidentReportingService::OnKillSwitchResult,
978 weak_ptr_factory_.GetWeakPtr(), 977 weak_ptr_factory_.GetWeakPtr(),
979 context.get()))) { 978 context.get()))) {
980 uploads_.push_back(context.Pass()); 979 uploads_.push_back(std::move(context));
981 } // else should not happen. Let the context be deleted automatically. 980 } // else should not happen. Let the context be deleted automatically.
982 } 981 }
983 } 982 }
984 983
985 void IncidentReportingService::CancelAllReportUploads() { 984 void IncidentReportingService::CancelAllReportUploads() {
986 for (size_t i = 0; i < uploads_.size(); ++i) { 985 for (size_t i = 0; i < uploads_.size(); ++i) {
987 UMA_HISTOGRAM_ENUMERATION("SBIRS.UploadResult", 986 UMA_HISTOGRAM_ENUMERATION("SBIRS.UploadResult",
988 IncidentReportUploader::UPLOAD_CANCELLED, 987 IncidentReportUploader::UPLOAD_CANCELLED,
989 IncidentReportUploader::NUM_UPLOAD_RESULTS); 988 IncidentReportUploader::NUM_UPLOAD_RESULTS);
990 } 989 }
991 uploads_.clear(); 990 uploads_.clear();
992 } 991 }
993 992
994 void IncidentReportingService::OnKillSwitchResult(UploadContext* context, 993 void IncidentReportingService::OnKillSwitchResult(UploadContext* context,
995 bool is_killswitch_on) { 994 bool is_killswitch_on) {
996 DCHECK(thread_checker_.CalledOnValidThread()); 995 DCHECK(thread_checker_.CalledOnValidThread());
997 if (!is_killswitch_on) { 996 if (!is_killswitch_on) {
998 // Initiate the upload. 997 // Initiate the upload.
999 context->uploader = 998 context->uploader = StartReportUpload(
1000 StartReportUpload( 999 base::Bind(&IncidentReportingService::OnReportUploadResult,
1001 base::Bind(&IncidentReportingService::OnReportUploadResult, 1000 weak_ptr_factory_.GetWeakPtr(), context),
1002 weak_ptr_factory_.GetWeakPtr(), 1001 url_request_context_getter_, *context->report);
1003 context),
1004 url_request_context_getter_,
1005 *context->report).Pass();
1006 if (!context->uploader) { 1002 if (!context->uploader) {
1007 OnReportUploadResult(context, 1003 OnReportUploadResult(context,
1008 IncidentReportUploader::UPLOAD_INVALID_REQUEST, 1004 IncidentReportUploader::UPLOAD_INVALID_REQUEST,
1009 scoped_ptr<ClientIncidentResponse>()); 1005 scoped_ptr<ClientIncidentResponse>());
1010 } 1006 }
1011 } else { 1007 } else {
1012 OnReportUploadResult(context, 1008 OnReportUploadResult(context,
1013 IncidentReportUploader::UPLOAD_SUPPRESSED, 1009 IncidentReportUploader::UPLOAD_SUPPRESSED,
1014 scoped_ptr<ClientIncidentResponse>()); 1010 scoped_ptr<ClientIncidentResponse>());
1015 } 1011 }
(...skipping 18 matching lines...) Expand all
1034 UMA_HISTOGRAM_ENUMERATION( 1030 UMA_HISTOGRAM_ENUMERATION(
1035 "SBIRS.UploadResult", result, IncidentReportUploader::NUM_UPLOAD_RESULTS); 1031 "SBIRS.UploadResult", result, IncidentReportUploader::NUM_UPLOAD_RESULTS);
1036 1032
1037 // The upload is no longer outstanding, so take ownership of the context (from 1033 // The upload is no longer outstanding, so take ownership of the context (from
1038 // the collection of outstanding uploads) in this scope. 1034 // the collection of outstanding uploads) in this scope.
1039 auto it = std::find_if(uploads_.begin(), uploads_.end(), 1035 auto it = std::find_if(uploads_.begin(), uploads_.end(),
1040 [context] (const scoped_ptr<UploadContext>& value) { 1036 [context] (const scoped_ptr<UploadContext>& value) {
1041 return value.get() == context; 1037 return value.get() == context;
1042 }); 1038 });
1043 DCHECK(it != uploads_.end()); 1039 DCHECK(it != uploads_.end());
1044 scoped_ptr<UploadContext> upload(it->Pass()); 1040 scoped_ptr<UploadContext> upload(std::move(*it));
1045 uploads_.erase(it); 1041 uploads_.erase(it);
1046 1042
1047 if (result == IncidentReportUploader::UPLOAD_SUCCESS) 1043 if (result == IncidentReportUploader::UPLOAD_SUCCESS)
1048 HandleResponse(*upload); 1044 HandleResponse(*upload);
1049 // else retry? 1045 // else retry?
1050 } 1046 }
1051 1047
1052 void IncidentReportingService::OnClientDownloadRequest( 1048 void IncidentReportingService::OnClientDownloadRequest(
1053 content::DownloadItem* download, 1049 content::DownloadItem* download,
1054 const ClientDownloadRequest* request) { 1050 const ClientDownloadRequest* request) {
(...skipping 19 matching lines...) Expand all
1074 if (!profile->IsOffTheRecord()) 1070 if (!profile->IsOffTheRecord())
1075 OnProfileDestroyed(profile); 1071 OnProfileDestroyed(profile);
1076 break; 1072 break;
1077 } 1073 }
1078 default: 1074 default:
1079 break; 1075 break;
1080 } 1076 }
1081 } 1077 }
1082 1078
1083 } // namespace safe_browsing 1079 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698