diff options
author | danakj <danakj@chromium.org> | 2014-09-26 19:39:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-27 02:39:41 +0000 |
commit | 7bb3dbede19d87f0338797756ffd738adc6bca08 (patch) | |
tree | ecd66a8fe850e5c57833a673fb39c41dbe27ffeb /cc/debug | |
parent | a60566701028a7344d17826076780eeb84b63052 (diff) | |
download | chromium_src-7bb3dbede19d87f0338797756ffd738adc6bca08.zip chromium_src-7bb3dbede19d87f0338797756ffd738adc6bca08.tar.gz chromium_src-7bb3dbede19d87f0338797756ffd738adc6bca08.tar.bz2 |
cc: Remove use of PassAs() and constructor-casting with scoped_ptr.
Say you have class A and subclass B.
Previously it was required to PassAs() a scoped_ptr<B> into a
scoped_ptr<A>. This is no longer needed, so just use Pass(). For newly
created scoped_ptrs, you can just use make_scoped_ptr always now.
And when you want to return or assign an empty scoped_ptr(), you can
now use nullptr directly.
Also adds PRESUBMIT checks for:
- return scoped<T>(foo). This should be return make_scoped_ptr(foo).
- bar = scoped<T>(foo). This should be return bar = make_scoped_ptr(foo).
- return scoped<T>(). This should be return nullptr.
- bar = scoped<T>(). This should be return bar = nullptr.
This also replaces p.reset() with p = nullptr; But it does not add a
PRESUBMIT check for that because there are things other than scoped_ptr
with a reset() function.
R=enne@chromium.org
Review URL: https://codereview.chromium.org/609663003
Cr-Commit-Position: refs/heads/master@{#297096}
Diffstat (limited to 'cc/debug')
-rw-r--r-- | cc/debug/micro_benchmark_controller.cc | 13 | ||||
-rw-r--r-- | cc/debug/micro_benchmark_controller_unittest.cc | 24 | ||||
-rw-r--r-- | cc/debug/picture_record_benchmark.cc | 2 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark.cc | 4 | ||||
-rw-r--r-- | cc/debug/rasterize_and_record_benchmark_impl.cc | 2 | ||||
-rw-r--r-- | cc/debug/unittest_only_benchmark.cc | 2 |
6 files changed, 22 insertions, 25 deletions
diff --git a/cc/debug/micro_benchmark_controller.cc b/cc/debug/micro_benchmark_controller.cc index 8b20bdf..bf98100 100644 --- a/cc/debug/micro_benchmark_controller.cc +++ b/cc/debug/micro_benchmark_controller.cc @@ -28,19 +28,16 @@ scoped_ptr<MicroBenchmark> CreateBenchmark( scoped_ptr<base::Value> value, const MicroBenchmark::DoneCallback& callback) { if (name == "invalidation_benchmark") { - return scoped_ptr<MicroBenchmark>( - new InvalidationBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new InvalidationBenchmark(value.Pass(), callback)); } else if (name == "picture_record_benchmark") { - return scoped_ptr<MicroBenchmark>( - new PictureRecordBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new PictureRecordBenchmark(value.Pass(), callback)); } else if (name == "rasterize_and_record_benchmark") { - return scoped_ptr<MicroBenchmark>( + return make_scoped_ptr( new RasterizeAndRecordBenchmark(value.Pass(), callback)); } else if (name == "unittest_only_benchmark") { - return scoped_ptr<MicroBenchmark>( - new UnittestOnlyBenchmark(value.Pass(), callback)); + return make_scoped_ptr(new UnittestOnlyBenchmark(value.Pass(), callback)); } - return scoped_ptr<MicroBenchmark>(); + return nullptr; } class IsDonePredicate { diff --git a/cc/debug/micro_benchmark_controller_unittest.cc b/cc/debug/micro_benchmark_controller_unittest.cc index 50021da..1f2bfd8 100644 --- a/cc/debug/micro_benchmark_controller_unittest.cc +++ b/cc/debug/micro_benchmark_controller_unittest.cc @@ -33,9 +33,9 @@ class MicroBenchmarkControllerTest : public testing::Test { } virtual void TearDown() OVERRIDE { - layer_tree_host_impl_.reset(); - layer_tree_host_.reset(); - impl_proxy_.reset(); + layer_tree_host_impl_ = nullptr; + layer_tree_host_ = nullptr; + impl_proxy_ = nullptr; } FakeLayerTreeHostClient layer_tree_host_client_; @@ -126,7 +126,7 @@ TEST_F(MicroBenchmarkControllerTest, BenchmarkImplRan) { // Schedule a main thread benchmark. int id = layer_tree_host_->ScheduleMicroBenchmark( "unittest_only_benchmark", - settings.PassAs<base::Value>(), + settings.Pass(), base::Bind(&IncrementCallCount, base::Unretained(&run_count))); EXPECT_GT(id, 0); @@ -147,8 +147,8 @@ TEST_F(MicroBenchmarkControllerTest, SendMessage) { // Send valid message to invalid benchmark (id = 0) scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue); message->SetBoolean("can_handle", true); - bool message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - 0, message.PassAs<base::Value>()); + bool message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(0, message.Pass()); EXPECT_FALSE(message_handled); // Schedule a benchmark @@ -160,17 +160,17 @@ TEST_F(MicroBenchmarkControllerTest, SendMessage) { EXPECT_GT(id, 0); // Send valid message to valid benchmark - message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); + message = make_scoped_ptr(new base::DictionaryValue); message->SetBoolean("can_handle", true); - message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - id, message.PassAs<base::Value>()); + message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass()); EXPECT_TRUE(message_handled); // Send invalid message to valid benchmark - message = scoped_ptr<base::DictionaryValue>(new base::DictionaryValue); + message = make_scoped_ptr(new base::DictionaryValue); message->SetBoolean("can_handle", false); - message_handled = layer_tree_host_->SendMessageToMicroBenchmark( - id, message.PassAs<base::Value>()); + message_handled = + layer_tree_host_->SendMessageToMicroBenchmark(id, message.Pass()); EXPECT_FALSE(message_handled); } diff --git a/cc/debug/picture_record_benchmark.cc b/cc/debug/picture_record_benchmark.cc index e6a5a65..2bda59d 100644 --- a/cc/debug/picture_record_benchmark.cc +++ b/cc/debug/picture_record_benchmark.cc @@ -80,7 +80,7 @@ void PictureRecordBenchmark::DidUpdateLayers(LayerTreeHost* host) { results->Append(result.release()); } - NotifyDone(results.PassAs<base::Value>()); + NotifyDone(results.Pass()); } void PictureRecordBenchmark::Run(Layer* layer) { diff --git a/cc/debug/rasterize_and_record_benchmark.cc b/cc/debug/rasterize_and_record_benchmark.cc index c2a47d0..9d1bfe6 100644 --- a/cc/debug/rasterize_and_record_benchmark.cc +++ b/cc/debug/rasterize_and_record_benchmark.cc @@ -80,12 +80,12 @@ void RasterizeAndRecordBenchmark::RecordRasterResults( results_->MergeDictionary(results); - NotifyDone(results_.PassAs<base::Value>()); + NotifyDone(results_.Pass()); } scoped_ptr<MicroBenchmarkImpl> RasterizeAndRecordBenchmark::CreateBenchmarkImpl( scoped_refptr<base::MessageLoopProxy> origin_loop) { - return scoped_ptr<MicroBenchmarkImpl>(new RasterizeAndRecordBenchmarkImpl( + return make_scoped_ptr(new RasterizeAndRecordBenchmarkImpl( origin_loop, settings_.get(), base::Bind(&RasterizeAndRecordBenchmark::RecordRasterResults, diff --git a/cc/debug/rasterize_and_record_benchmark_impl.cc b/cc/debug/rasterize_and_record_benchmark_impl.cc index d0a4726..dbf74a42 100644 --- a/cc/debug/rasterize_and_record_benchmark_impl.cc +++ b/cc/debug/rasterize_and_record_benchmark_impl.cc @@ -184,7 +184,7 @@ void RasterizeAndRecordBenchmarkImpl::DidCompleteCommit( result->SetInteger("total_picture_layers_off_screen", rasterize_results_.total_picture_layers_off_screen); - NotifyDone(result.PassAs<base::Value>()); + NotifyDone(result.Pass()); } void RasterizeAndRecordBenchmarkImpl::Run(LayerImpl* layer) { diff --git a/cc/debug/unittest_only_benchmark.cc b/cc/debug/unittest_only_benchmark.cc index 0f0694a..e8146ad 100644 --- a/cc/debug/unittest_only_benchmark.cc +++ b/cc/debug/unittest_only_benchmark.cc @@ -57,7 +57,7 @@ scoped_ptr<MicroBenchmarkImpl> UnittestOnlyBenchmark::CreateBenchmarkImpl( if (!create_impl_benchmark_) return make_scoped_ptr<MicroBenchmarkImpl>(NULL); - return scoped_ptr<MicroBenchmarkImpl>(new UnittestOnlyBenchmarkImpl( + return make_scoped_ptr(new UnittestOnlyBenchmarkImpl( origin_loop, NULL, base::Bind(&UnittestOnlyBenchmark::RecordImplResults, |