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

Unified Diff: cc/debug/micro_benchmark_controller.cc

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/debug/micro_benchmark_controller.h ('k') | cc/debug/micro_benchmark_controller_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/debug/micro_benchmark_controller.cc
diff --git a/cc/debug/micro_benchmark_controller.cc b/cc/debug/micro_benchmark_controller.cc
index a0dc306612fa77c0d65a0c45ce3adf488eaf64ed..5aace9ba0eb92d3670c90dc2e5400c56f76ec691 100644
--- a/cc/debug/micro_benchmark_controller.cc
+++ b/cc/debug/micro_benchmark_controller.cc
@@ -37,16 +37,6 @@ scoped_ptr<MicroBenchmark> CreateBenchmark(
return nullptr;
}
-class IsDonePredicate {
- public:
- typedef const MicroBenchmark* argument_type;
- typedef bool result_type;
-
- result_type operator()(argument_type benchmark) const {
- return benchmark->IsDone();
- }
-};
-
} // namespace
MicroBenchmarkController::MicroBenchmarkController(LayerTreeHost* host)
@@ -85,23 +75,22 @@ int MicroBenchmarkController::GetNextIdAndIncrement() {
bool MicroBenchmarkController::SendMessage(int id,
scoped_ptr<base::Value> value) {
- for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin();
- it != benchmarks_.end();
- ++it) {
- if ((*it)->id() == id)
- return (*it)->ProcessMessage(value.Pass());
- }
- return false;
+ auto it = std::find_if(benchmarks_.begin(), benchmarks_.end(),
+ [id](const scoped_ptr<MicroBenchmark>& benchmark) {
+ return benchmark->id() == id;
+ });
+ if (it == benchmarks_.end())
+ return false;
+ return (*it)->ProcessMessage(std::move(value));
}
void MicroBenchmarkController::ScheduleImplBenchmarks(
LayerTreeHostImpl* host_impl) {
- for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin();
- it != benchmarks_.end();
- ++it) {
+ for (const auto& benchmark : benchmarks_) {
scoped_ptr<MicroBenchmarkImpl> benchmark_impl;
- if (!(*it)->ProcessedForBenchmarkImpl()) {
- benchmark_impl = (*it)->GetBenchmarkImpl(main_controller_task_runner_);
+ if (!benchmark->ProcessedForBenchmarkImpl()) {
+ benchmark_impl =
+ benchmark->GetBenchmarkImpl(main_controller_task_runner_);
}
if (benchmark_impl.get())
@@ -110,11 +99,9 @@ void MicroBenchmarkController::ScheduleImplBenchmarks(
}
void MicroBenchmarkController::DidUpdateLayers() {
- for (ScopedPtrVector<MicroBenchmark>::iterator it = benchmarks_.begin();
- it != benchmarks_.end();
- ++it) {
- if (!(*it)->IsDone())
- (*it)->DidUpdateLayers(host_);
+ for (const auto& benchmark : benchmarks_) {
+ if (!benchmark->IsDone())
+ benchmark->DidUpdateLayers(host_);
}
CleanUpFinishedBenchmarks();
@@ -122,7 +109,10 @@ void MicroBenchmarkController::DidUpdateLayers() {
void MicroBenchmarkController::CleanUpFinishedBenchmarks() {
benchmarks_.erase(
- benchmarks_.partition(std::not1(IsDonePredicate())),
+ std::remove_if(benchmarks_.begin(), benchmarks_.end(),
+ [](const scoped_ptr<MicroBenchmark>& benchmark) {
+ return benchmark->IsDone();
+ }),
benchmarks_.end());
}
« no previous file with comments | « cc/debug/micro_benchmark_controller.h ('k') | cc/debug/micro_benchmark_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698