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

Side by Side Diff: cc/test/fake_tile_manager.cc

Issue 2738613006: Remove non-leaky LazyInstances in cc. (Closed)
Patch Set: cc-remove-non-leaky-singletons: globals Created 3 years, 9 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/picture_layer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/fake_tile_manager.h" 5 #include "cc/test/fake_tile_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <limits> 11 #include <limits>
12 12
13 #include "base/lazy_instance.h"
14 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
15 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
16 #include "cc/raster/raster_buffer.h" 15 #include "cc/raster/raster_buffer.h"
17 #include "cc/raster/synchronous_task_graph_runner.h" 16 #include "cc/raster/synchronous_task_graph_runner.h"
17 #include "cc/test/fake_raster_buffer_provider.h"
18 #include "cc/test/fake_tile_task_manager.h" 18 #include "cc/test/fake_tile_task_manager.h"
19 #include "cc/trees/layer_tree_settings.h" 19 #include "cc/trees/layer_tree_settings.h"
20 20
21 namespace cc { 21 namespace cc {
22 22
23 namespace { 23 namespace {
24 24
25 base::LazyInstance<SynchronousTaskGraphRunner>::DestructorAtExit 25 SynchronousTaskGraphRunner* GetGlobalTaskGraphRunner() {
26 g_synchronous_task_graph_runner = LAZY_INSTANCE_INITIALIZER; 26 static auto* task_graph_runner = new SynchronousTaskGraphRunner;
27 return task_graph_runner;
28 }
27 29
28 base::LazyInstance<FakeRasterBufferProviderImpl>::DestructorAtExit 30 FakeRasterBufferProviderImpl* GetGlobalRasterBufferProvider() {
29 g_fake_raster_buffer_provider = LAZY_INSTANCE_INITIALIZER; 31 static auto* buffer_provider = new FakeRasterBufferProviderImpl;
32 return buffer_provider;
33 }
30 34
31 } // namespace 35 } // namespace
32 36
33 FakeTileManager::FakeTileManager(TileManagerClient* client, 37 FakeTileManager::FakeTileManager(TileManagerClient* client,
34 ResourcePool* resource_pool) 38 ResourcePool* resource_pool)
35 : TileManager(client, 39 : TileManager(client,
36 base::ThreadTaskRunnerHandle::Get().get(), 40 base::ThreadTaskRunnerHandle::Get().get(),
37 nullptr, 41 nullptr,
38 std::numeric_limits<size_t>::max(), 42 std::numeric_limits<size_t>::max(),
39 TileManagerSettings()), 43 TileManagerSettings()),
40 image_decode_cache_( 44 image_decode_cache_(
41 ResourceFormat::RGBA_8888, 45 ResourceFormat::RGBA_8888,
42 LayerTreeSettings().software_decoded_image_budget_bytes) { 46 LayerTreeSettings().software_decoded_image_budget_bytes) {
43 SetDecodedImageTracker(&decoded_image_tracker_); 47 SetDecodedImageTracker(&decoded_image_tracker_);
44 SetResources(resource_pool, &image_decode_cache_, 48 SetResources(resource_pool, &image_decode_cache_, GetGlobalTaskGraphRunner(),
45 g_synchronous_task_graph_runner.Pointer(), 49 GetGlobalRasterBufferProvider(),
46 g_fake_raster_buffer_provider.Pointer(),
47 std::numeric_limits<size_t>::max(), 50 std::numeric_limits<size_t>::max(),
48 false /* use_gpu_rasterization */); 51 false /* use_gpu_rasterization */);
49 SetTileTaskManagerForTesting(base::MakeUnique<FakeTileTaskManagerImpl>()); 52 SetTileTaskManagerForTesting(base::MakeUnique<FakeTileTaskManagerImpl>());
50 } 53 }
51 54
52 FakeTileManager::~FakeTileManager() {} 55 FakeTileManager::~FakeTileManager() {}
53 56
54 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { 57 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) {
55 return std::find(tiles_for_raster.begin(), 58 return std::find(tiles_for_raster.begin(),
56 tiles_for_raster.end(), 59 tiles_for_raster.end(),
57 tile) != tiles_for_raster.end(); 60 tile) != tiles_for_raster.end();
58 } 61 }
59 62
60 } // namespace cc 63 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698