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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 2652343003: Replace source pointer in cc::CopyOutputRequest with a base::UnguessableToken (Closed)
Patch Set: c Created 3 years, 10 months 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
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/output/copy_output_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 child.get())); \ 78 child.get())); \
79 EXPECT_FALSE(grand_child->subtree_property_changed()); \ 79 EXPECT_FALSE(grand_child->subtree_property_changed()); \
80 EXPECT_FALSE( \ 80 EXPECT_FALSE( \
81 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \ 81 grand_child->layer_tree_host()->LayerNeedsPushPropertiesForTesting( \
82 grand_child.get())); 82 grand_child.get()));
83 83
84 namespace cc { 84 namespace cc {
85 85
86 namespace { 86 namespace {
87 87
88 static auto kArbitrarySourceId1 =
89 base::UnguessableToken::Deserialize(0xdead, 0xbeef);
90 static auto kArbitrarySourceId2 =
91 base::UnguessableToken::Deserialize(0xdead, 0xbee0);
92
88 class MockLayerTreeHost : public LayerTreeHost { 93 class MockLayerTreeHost : public LayerTreeHost {
89 public: 94 public:
90 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client, 95 MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client,
91 LayerTreeHost::InitParams* params) 96 LayerTreeHost::InitParams* params)
92 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) { 97 : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
93 InitializeSingleThreaded(single_thread_client, 98 InitializeSingleThreaded(single_thread_client,
94 base::ThreadTaskRunnerHandle::Get()); 99 base::ThreadTaskRunnerHandle::Get());
95 } 100 }
96 101
97 MOCK_METHOD0(SetNeedsCommit, void()); 102 MOCK_METHOD0(SetNeedsCommit, void());
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 EXPECT_EQ(0, result_count); 1333 EXPECT_EQ(0, result_count);
1329 1334
1330 // When the layer is destroyed, expect both requests to be aborted. 1335 // When the layer is destroyed, expect both requests to be aborted.
1331 layer = nullptr; 1336 layer = nullptr;
1332 EXPECT_EQ(2, result_count); 1337 EXPECT_EQ(2, result_count);
1333 1338
1334 layer = Layer::Create(); 1339 layer = Layer::Create();
1335 result_count = 0; 1340 result_count = 0;
1336 1341
1337 // Create identical requests, but this time the source is being set. Expect 1342 // Create identical requests, but this time the source is being set. Expect
1338 // the first request from |this| source aborts immediately when the second 1343 // the first request using |kArbitrarySourceId1| aborts immediately when
1339 // request from |this| source is made. 1344 // the second request using |kArbitrarySourceId1| is made.
1340 int did_receive_first_result_from_this_source = 0; 1345 int did_receive_first_result_from_this_source = 0;
1341 request = CopyOutputRequest::CreateRequest(base::Bind( 1346 request = CopyOutputRequest::CreateRequest(base::Bind(
1342 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source)); 1347 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source));
1343 request->set_source(this); 1348 request->set_source(kArbitrarySourceId1);
1344 layer->RequestCopyOfOutput(std::move(request)); 1349 layer->RequestCopyOfOutput(std::move(request));
1345 EXPECT_EQ(0, did_receive_first_result_from_this_source); 1350 EXPECT_EQ(0, did_receive_first_result_from_this_source);
1346 // Make a request from a different source. 1351 // Make a request from a different source.
1347 int did_receive_result_from_different_source = 0; 1352 int did_receive_result_from_different_source = 0;
1348 request = CopyOutputRequest::CreateRequest(base::Bind( 1353 request = CopyOutputRequest::CreateRequest(base::Bind(
1349 &ReceiveCopyOutputResult, &did_receive_result_from_different_source)); 1354 &ReceiveCopyOutputResult, &did_receive_result_from_different_source));
1350 request->set_source(reinterpret_cast<void*>(0xdeadbee0)); 1355 request->set_source(kArbitrarySourceId2);
1351 layer->RequestCopyOfOutput(std::move(request)); 1356 layer->RequestCopyOfOutput(std::move(request));
1352 EXPECT_EQ(0, did_receive_result_from_different_source); 1357 EXPECT_EQ(0, did_receive_result_from_different_source);
1353 // Make a request without specifying the source. 1358 // Make a request without specifying the source.
1354 int did_receive_result_from_anonymous_source = 0; 1359 int did_receive_result_from_anonymous_source = 0;
1355 request = CopyOutputRequest::CreateRequest(base::Bind( 1360 request = CopyOutputRequest::CreateRequest(base::Bind(
1356 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source)); 1361 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source));
1357 layer->RequestCopyOfOutput(std::move(request)); 1362 layer->RequestCopyOfOutput(std::move(request));
1358 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1363 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1359 // Make the second request from |this| source. 1364 // Make the second request from |kArbitrarySourceId1|.
1360 int did_receive_second_result_from_this_source = 0; 1365 int did_receive_second_result_from_this_source = 0;
1361 request = CopyOutputRequest::CreateRequest(base::Bind( 1366 request = CopyOutputRequest::CreateRequest(base::Bind(
1362 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source)); 1367 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source));
1363 request->set_source(this); 1368 request->set_source(kArbitrarySourceId1);
1364 layer->RequestCopyOfOutput( 1369 layer->RequestCopyOfOutput(
1365 std::move(request)); // First request to be aborted. 1370 std::move(request)); // First request to be aborted.
1366 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1371 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1367 EXPECT_EQ(0, did_receive_result_from_different_source); 1372 EXPECT_EQ(0, did_receive_result_from_different_source);
1368 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1373 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1369 EXPECT_EQ(0, did_receive_second_result_from_this_source); 1374 EXPECT_EQ(0, did_receive_second_result_from_this_source);
1370 1375
1371 // When the layer is destroyed, the other three requests should be aborted. 1376 // When the layer is destroyed, the other three requests should be aborted.
1372 layer = nullptr; 1377 layer = nullptr;
1373 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1378 EXPECT_EQ(1, did_receive_first_result_from_this_source);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 1421 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
1417 1422
1418 test_layer->PushPropertiesTo(impl_layer.get()); 1423 test_layer->PushPropertiesTo(impl_layer.get());
1419 1424
1420 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 1425 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
1421 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 1426 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
1422 } 1427 }
1423 1428
1424 } // namespace 1429 } // namespace
1425 } // namespace cc 1430 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/output/copy_output_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698