| 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 "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 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 AddIncidentOnMainThread(service_, profile, std::move(incident)); | 222 AddIncidentOnMainThread(service_, profile, std::move(incident)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void IncidentReportingService::Receiver::AddIncidentForProcess( | 225 void IncidentReportingService::Receiver::AddIncidentForProcess( |
| 226 std::unique_ptr<Incident> incident) { | 226 std::unique_ptr<Incident> incident) { |
| 227 if (thread_runner_->BelongsToCurrentThread()) { | 227 if (thread_runner_->BelongsToCurrentThread()) { |
| 228 AddIncidentOnMainThread(service_, nullptr, std::move(incident)); | 228 AddIncidentOnMainThread(service_, nullptr, std::move(incident)); |
| 229 } else { | 229 } else { |
| 230 thread_runner_->PostTask( | 230 thread_runner_->PostTask( |
| 231 FROM_HERE, | 231 FROM_HERE, |
| 232 base::Bind(&IncidentReportingService::Receiver::AddIncidentOnMainThread, | 232 base::BindOnce( |
| 233 service_, nullptr, base::Passed(&incident))); | 233 &IncidentReportingService::Receiver::AddIncidentOnMainThread, |
| 234 service_, nullptr, base::Passed(&incident))); |
| 234 } | 235 } |
| 235 } | 236 } |
| 236 | 237 |
| 237 void IncidentReportingService::Receiver::ClearIncidentForProcess( | 238 void IncidentReportingService::Receiver::ClearIncidentForProcess( |
| 238 std::unique_ptr<Incident> incident) { | 239 std::unique_ptr<Incident> incident) { |
| 239 if (thread_runner_->BelongsToCurrentThread()) { | 240 if (thread_runner_->BelongsToCurrentThread()) { |
| 240 ClearIncidentOnMainThread(service_, nullptr, std::move(incident)); | 241 ClearIncidentOnMainThread(service_, nullptr, std::move(incident)); |
| 241 } else { | 242 } else { |
| 242 thread_runner_->PostTask( | 243 thread_runner_->PostTask( |
| 243 FROM_HERE, | 244 FROM_HERE, |
| 244 base::Bind( | 245 base::BindOnce( |
| 245 &IncidentReportingService::Receiver::ClearIncidentOnMainThread, | 246 &IncidentReportingService::Receiver::ClearIncidentOnMainThread, |
| 246 service_, nullptr, base::Passed(&incident))); | 247 service_, nullptr, base::Passed(&incident))); |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 | 250 |
| 250 bool IncidentReportingService::HasIncidentsToUpload() const { | 251 bool IncidentReportingService::HasIncidentsToUpload() const { |
| 251 for (const auto& profile_and_context : profiles_) { | 252 for (const auto& profile_and_context : profiles_) { |
| 252 if (!profile_and_context.second->incidents.empty()) | 253 if (!profile_and_context.second->incidents.empty()) |
| 253 return true; | 254 return true; |
| 254 } | 255 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 if (environment_collection_pending_ || report_->has_environment() || | 685 if (environment_collection_pending_ || report_->has_environment() || |
| 685 !HasIncidentsToUpload() || !FindEligibleProfile()) { | 686 !HasIncidentsToUpload() || !FindEligibleProfile()) { |
| 686 return; | 687 return; |
| 687 } | 688 } |
| 688 | 689 |
| 689 environment_collection_begin_ = base::TimeTicks::Now(); | 690 environment_collection_begin_ = base::TimeTicks::Now(); |
| 690 ClientIncidentReport_EnvironmentData* environment_data = | 691 ClientIncidentReport_EnvironmentData* environment_data = |
| 691 new ClientIncidentReport_EnvironmentData(); | 692 new ClientIncidentReport_EnvironmentData(); |
| 692 environment_collection_pending_ = | 693 environment_collection_pending_ = |
| 693 environment_collection_task_runner_->PostTaskAndReply( | 694 environment_collection_task_runner_->PostTaskAndReply( |
| 694 FROM_HERE, base::Bind(collect_environment_data_fn_, environment_data), | 695 FROM_HERE, |
| 695 base::Bind(&IncidentReportingService::OnEnvironmentDataCollected, | 696 base::BindOnce(collect_environment_data_fn_, environment_data), |
| 696 weak_ptr_factory_.GetWeakPtr(), | 697 base::BindOnce(&IncidentReportingService::OnEnvironmentDataCollected, |
| 697 base::Passed(base::WrapUnique(environment_data)))); | 698 weak_ptr_factory_.GetWeakPtr(), |
| 699 base::Passed(base::WrapUnique(environment_data)))); |
| 698 | 700 |
| 699 // Posting the task will fail if the runner has been shut down. This should | 701 // Posting the task will fail if the runner has been shut down. This should |
| 700 // never happen since the blocking pool is shut down after this service. | 702 // never happen since the blocking pool is shut down after this service. |
| 701 DCHECK(environment_collection_pending_); | 703 DCHECK(environment_collection_pending_); |
| 702 } | 704 } |
| 703 | 705 |
| 704 bool IncidentReportingService::WaitingForEnvironmentCollection() { | 706 bool IncidentReportingService::WaitingForEnvironmentCollection() { |
| 705 return environment_collection_pending_; | 707 return environment_collection_pending_; |
| 706 } | 708 } |
| 707 | 709 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (!profile->IsOffTheRecord()) | 1056 if (!profile->IsOffTheRecord()) |
| 1055 OnProfileDestroyed(profile); | 1057 OnProfileDestroyed(profile); |
| 1056 break; | 1058 break; |
| 1057 } | 1059 } |
| 1058 default: | 1060 default: |
| 1059 break; | 1061 break; |
| 1060 } | 1062 } |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 } // namespace safe_browsing | 1065 } // namespace safe_browsing |
| OLD | NEW |