OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "cc/layers/delegated_frame_resource_collection.h" | 9 #include "cc/layers/delegated_frame_resource_collection.h" |
10 #include "cc/resources/returned_resource.h" | 10 #include "cc/resources/returned_resource.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 virtual void TearDown() override { DestroyResourceCollection(); } | 26 virtual void TearDown() override { DestroyResourceCollection(); } |
27 | 27 |
28 void CreateResourceCollection() { | 28 void CreateResourceCollection() { |
29 DCHECK(!resource_collection_.get()); | 29 DCHECK(!resource_collection_.get()); |
30 resource_collection_ = new DelegatedFrameResourceCollection; | 30 resource_collection_ = new DelegatedFrameResourceCollection; |
31 resource_collection_->SetClient(this); | 31 resource_collection_->SetClient(this); |
32 } | 32 } |
33 | 33 |
34 void DestroyResourceCollection() { | 34 void DestroyResourceCollection() { |
35 if (resource_collection_.get()) { | 35 if (resource_collection_.get()) { |
36 resource_collection_->SetClient(NULL); | 36 resource_collection_->SetClient(nullptr); |
37 resource_collection_ = NULL; | 37 resource_collection_ = nullptr; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 TransferableResourceArray CreateResourceArray() { | 41 TransferableResourceArray CreateResourceArray() { |
42 TransferableResourceArray resources; | 42 TransferableResourceArray resources; |
43 TransferableResource resource; | 43 TransferableResource resource; |
44 resource.id = 444; | 44 resource.id = 444; |
45 resources.push_back(resource); | 45 resources.push_back(resource); |
46 return resources; | 46 return resources; |
47 } | 47 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 resource_collection_->LoseAllResources(); | 144 resource_collection_->LoseAllResources(); |
145 DestroyResourceCollection(); | 145 DestroyResourceCollection(); |
146 | 146 |
147 EXPECT_TRUE(ReturnAndResetResourcesAvailable()); | 147 EXPECT_TRUE(ReturnAndResetResourcesAvailable()); |
148 EXPECT_EQ(1u, returned_resources_.size()); | 148 EXPECT_EQ(1u, returned_resources_.size()); |
149 EXPECT_EQ(444u, returned_resources_[0].id); | 149 EXPECT_EQ(444u, returned_resources_[0].id); |
150 EXPECT_EQ(1, returned_resources_[0].count); | 150 EXPECT_EQ(1, returned_resources_[0].count); |
151 EXPECT_TRUE(returned_resources_[0].lost); | 151 EXPECT_TRUE(returned_resources_[0].lost); |
152 returned_resources_.clear(); | 152 returned_resources_.clear(); |
153 | 153 |
154 base::WaitableEvent* null_event = NULL; | 154 base::WaitableEvent* null_event = nullptr; |
155 thread.message_loop()->PostTask(FROM_HERE, | 155 thread.message_loop()->PostTask(FROM_HERE, |
156 base::Bind(&ReturnResourcesOnThread, | 156 base::Bind(&ReturnResourcesOnThread, |
157 return_callback, | 157 return_callback, |
158 returned_resources, | 158 returned_resources, |
159 null_event, | 159 null_event, |
160 main_thread_task_runner.get())); | 160 main_thread_task_runner.get())); |
161 | 161 |
162 thread.Stop(); | 162 thread.Stop(); |
163 } | 163 } |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 } // namespace cc | 166 } // namespace cc |
OLD | NEW |