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

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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \ 77 child->GetLayerTree()->LayerNeedsPushPropertiesForTesting(child.get())); \
78 EXPECT_FALSE(grand_child->subtree_property_changed()); \ 78 EXPECT_FALSE(grand_child->subtree_property_changed()); \
79 EXPECT_FALSE( \ 79 EXPECT_FALSE( \
80 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \ 80 grand_child->GetLayerTree()->LayerNeedsPushPropertiesForTesting( \
81 grand_child.get())); 81 grand_child.get()));
82 82
83 namespace cc { 83 namespace cc {
84 84
85 namespace { 85 namespace {
86 86
87 static auto kArbitrarySourceId1 =
88 base::UnguessableToken::Deserialize(0xdead, 0xbeef);
89 static auto kArbitrarySourceId2 =
90 base::UnguessableToken::Deserialize(0xdead, 0xbee0);
vmpstr 2017/01/27 19:41:25 I think you mean 0xdead 0xf00d :P (jk)
91
87 class MockLayerTree : public LayerTree { 92 class MockLayerTree : public LayerTree {
88 public: 93 public:
89 MockLayerTree(LayerTreeHostInProcess::InitParams* params, 94 MockLayerTree(LayerTreeHostInProcess::InitParams* params,
90 LayerTreeHost* layer_tree_host) 95 LayerTreeHost* layer_tree_host)
91 : LayerTree(params->mutator_host, layer_tree_host) {} 96 : LayerTree(params->mutator_host, layer_tree_host) {}
92 ~MockLayerTree() override {} 97 ~MockLayerTree() override {}
93 98
94 MOCK_METHOD0(SetNeedsFullTreeSync, void()); 99 MOCK_METHOD0(SetNeedsFullTreeSync, void());
95 }; 100 };
96 101
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 EXPECT_EQ(0, result_count); 1344 EXPECT_EQ(0, result_count);
1340 1345
1341 // When the layer is destroyed, expect both requests to be aborted. 1346 // When the layer is destroyed, expect both requests to be aborted.
1342 layer = nullptr; 1347 layer = nullptr;
1343 EXPECT_EQ(2, result_count); 1348 EXPECT_EQ(2, result_count);
1344 1349
1345 layer = Layer::Create(); 1350 layer = Layer::Create();
1346 result_count = 0; 1351 result_count = 0;
1347 1352
1348 // Create identical requests, but this time the source is being set. Expect 1353 // Create identical requests, but this time the source is being set. Expect
1349 // the first request from |this| source aborts immediately when the second 1354 // the first request using |kArbitrarySourceId1| aborts immediately when
1350 // request from |this| source is made. 1355 // the second request using |kArbitrarySourceId1| is made.
1351 int did_receive_first_result_from_this_source = 0; 1356 int did_receive_first_result_from_this_source = 0;
1352 request = CopyOutputRequest::CreateRequest(base::Bind( 1357 request = CopyOutputRequest::CreateRequest(base::Bind(
1353 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source)); 1358 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source));
1354 request->set_source(this); 1359 request->set_source(kArbitrarySourceId1);
1355 layer->RequestCopyOfOutput(std::move(request)); 1360 layer->RequestCopyOfOutput(std::move(request));
1356 EXPECT_EQ(0, did_receive_first_result_from_this_source); 1361 EXPECT_EQ(0, did_receive_first_result_from_this_source);
1357 // Make a request from a different source. 1362 // Make a request from a different source.
1358 int did_receive_result_from_different_source = 0; 1363 int did_receive_result_from_different_source = 0;
1359 request = CopyOutputRequest::CreateRequest(base::Bind( 1364 request = CopyOutputRequest::CreateRequest(base::Bind(
1360 &ReceiveCopyOutputResult, &did_receive_result_from_different_source)); 1365 &ReceiveCopyOutputResult, &did_receive_result_from_different_source));
1361 request->set_source(reinterpret_cast<void*>(0xdeadbee0)); 1366 request->set_source(kArbitrarySourceId2);
1362 layer->RequestCopyOfOutput(std::move(request)); 1367 layer->RequestCopyOfOutput(std::move(request));
1363 EXPECT_EQ(0, did_receive_result_from_different_source); 1368 EXPECT_EQ(0, did_receive_result_from_different_source);
1364 // Make a request without specifying the source. 1369 // Make a request without specifying the source.
1365 int did_receive_result_from_anonymous_source = 0; 1370 int did_receive_result_from_anonymous_source = 0;
1366 request = CopyOutputRequest::CreateRequest(base::Bind( 1371 request = CopyOutputRequest::CreateRequest(base::Bind(
1367 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source)); 1372 &ReceiveCopyOutputResult, &did_receive_result_from_anonymous_source));
1368 layer->RequestCopyOfOutput(std::move(request)); 1373 layer->RequestCopyOfOutput(std::move(request));
1369 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1374 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1370 // Make the second request from |this| source. 1375 // Make the second request from |kArbitrarySourceId1|.
1371 int did_receive_second_result_from_this_source = 0; 1376 int did_receive_second_result_from_this_source = 0;
1372 request = CopyOutputRequest::CreateRequest(base::Bind( 1377 request = CopyOutputRequest::CreateRequest(base::Bind(
1373 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source)); 1378 &ReceiveCopyOutputResult, &did_receive_second_result_from_this_source));
1374 request->set_source(this); 1379 request->set_source(kArbitrarySourceId1);
1375 layer->RequestCopyOfOutput( 1380 layer->RequestCopyOfOutput(
1376 std::move(request)); // First request to be aborted. 1381 std::move(request)); // First request to be aborted.
1377 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1382 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1378 EXPECT_EQ(0, did_receive_result_from_different_source); 1383 EXPECT_EQ(0, did_receive_result_from_different_source);
1379 EXPECT_EQ(0, did_receive_result_from_anonymous_source); 1384 EXPECT_EQ(0, did_receive_result_from_anonymous_source);
1380 EXPECT_EQ(0, did_receive_second_result_from_this_source); 1385 EXPECT_EQ(0, did_receive_second_result_from_this_source);
1381 1386
1382 // When the layer is destroyed, the other three requests should be aborted. 1387 // When the layer is destroyed, the other three requests should be aborted.
1383 layer = nullptr; 1388 layer = nullptr;
1384 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1389 EXPECT_EQ(1, did_receive_first_result_from_this_source);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 1431 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
1427 1432
1428 test_layer->PushPropertiesTo(impl_layer.get()); 1433 test_layer->PushPropertiesTo(impl_layer.get());
1429 1434
1430 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); 1435 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id());
1431 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 1436 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
1432 } 1437 }
1433 1438
1434 } // namespace 1439 } // namespace
1435 } // namespace cc 1440 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698