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

Side by Side Diff: cc/debug/micro_benchmark_controller_impl.cc

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just the vector 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/debug/micro_benchmark_controller_impl.h" 5 #include "cc/debug/micro_benchmark_controller_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "cc/trees/layer_tree_host_impl.h" 11 #include "cc/trees/layer_tree_host_impl.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 namespace {
16
17 class IsDonePredicate {
18 public:
19 typedef const MicroBenchmarkImpl* argument_type;
20 typedef bool result_type;
21
22 result_type operator()(argument_type benchmark) const {
23 return benchmark->IsDone();
24 }
25 };
26
27 } // namespace
28
29 MicroBenchmarkControllerImpl::MicroBenchmarkControllerImpl( 15 MicroBenchmarkControllerImpl::MicroBenchmarkControllerImpl(
30 LayerTreeHostImpl* host) 16 LayerTreeHostImpl* host)
31 : host_(host) { 17 : host_(host) {
32 DCHECK(host_); 18 DCHECK(host_);
33 } 19 }
34 20
35 MicroBenchmarkControllerImpl::~MicroBenchmarkControllerImpl() {} 21 MicroBenchmarkControllerImpl::~MicroBenchmarkControllerImpl() {}
36 22
37 void MicroBenchmarkControllerImpl::ScheduleRun( 23 void MicroBenchmarkControllerImpl::ScheduleRun(
38 scoped_ptr<MicroBenchmarkImpl> benchmark) { 24 scoped_ptr<MicroBenchmarkImpl> benchmark) {
39 benchmarks_.push_back(benchmark.Pass()); 25 benchmarks_.push_back(benchmark.Pass());
40 } 26 }
41 27
42 void MicroBenchmarkControllerImpl::DidCompleteCommit() { 28 void MicroBenchmarkControllerImpl::DidCompleteCommit() {
43 for (ScopedPtrVector<MicroBenchmarkImpl>::iterator it = benchmarks_.begin(); 29 for (std::vector<scoped_ptr<MicroBenchmarkImpl>>::iterator it =
danakj 2015/11/17 01:12:17 auto, ranged-based
vmpstr 2015/11/17 23:26:23 Done.
44 it != benchmarks_.end(); 30 benchmarks_.begin();
45 ++it) { 31 it != benchmarks_.end(); ++it) {
46 DCHECK(!(*it)->IsDone()); 32 DCHECK(!(*it)->IsDone());
47 (*it)->DidCompleteCommit(host_); 33 (*it)->DidCompleteCommit(host_);
48 } 34 }
49 35
50 CleanUpFinishedBenchmarks(); 36 CleanUpFinishedBenchmarks();
51 } 37 }
52 38
53 void MicroBenchmarkControllerImpl::CleanUpFinishedBenchmarks() { 39 void MicroBenchmarkControllerImpl::CleanUpFinishedBenchmarks() {
54 benchmarks_.erase( 40 benchmarks_.erase(
55 benchmarks_.partition(std::not1(IsDonePredicate())), 41 std::remove_if(benchmarks_.begin(), benchmarks_.end(),
42 [](const scoped_ptr<MicroBenchmarkImpl>& benchmark) {
43 return benchmark->IsDone();
danakj 2015/11/17 01:12:17 did you mean the inverse?
vmpstr 2015/11/17 23:26:23 Nope :)
44 }),
56 benchmarks_.end()); 45 benchmarks_.end());
57 } 46 }
58 47
59 } // namespace cc 48 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698