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

Side by Side Diff: cc/tiles/tile_manager_unittest.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 years, 8 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/tiles/image_controller_unittest.cc ('k') | chrome/browser/after_startup_task_utils.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 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility>
9
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/callback.h" 11 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
11 #include "base/run_loop.h" 13 #include "base/run_loop.h"
12 #include "base/test/test_simple_task_runner.h" 14 #include "base/test/test_simple_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
14 #include "cc/layers/recording_source.h" 16 #include "cc/layers/recording_source.h"
15 #include "cc/raster/raster_buffer.h" 17 #include "cc/raster/raster_buffer.h"
16 #include "cc/raster/raster_source.h" 18 #include "cc/raster/raster_source.h"
17 #include "cc/raster/synchronous_task_graph_runner.h" 19 #include "cc/raster/synchronous_task_graph_runner.h"
(...skipping 30 matching lines...) Expand all
48 using testing::StrictMock; 50 using testing::StrictMock;
49 51
50 namespace cc { 52 namespace cc {
51 namespace { 53 namespace {
52 54
53 // A version of simple task runner that lets the user control if all tasks 55 // A version of simple task runner that lets the user control if all tasks
54 // posted should run synchronously. 56 // posted should run synchronously.
55 class SynchronousSimpleTaskRunner : public base::TestSimpleTaskRunner { 57 class SynchronousSimpleTaskRunner : public base::TestSimpleTaskRunner {
56 public: 58 public:
57 bool PostDelayedTask(const tracked_objects::Location& from_here, 59 bool PostDelayedTask(const tracked_objects::Location& from_here,
58 const base::Closure& task, 60 base::Closure task,
59 base::TimeDelta delay) override { 61 base::TimeDelta delay) override {
60 TestSimpleTaskRunner::PostDelayedTask(from_here, task, delay); 62 TestSimpleTaskRunner::PostDelayedTask(from_here, std::move(task), delay);
61 if (run_tasks_synchronously_) 63 if (run_tasks_synchronously_)
62 RunUntilIdle(); 64 RunUntilIdle();
63 return true; 65 return true;
64 } 66 }
65 67
66 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 68 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
67 const base::Closure& task, 69 base::Closure task,
68 base::TimeDelta delay) override { 70 base::TimeDelta delay) override {
69 return PostDelayedTask(from_here, task, delay); 71 return PostDelayedTask(from_here, std::move(task), delay);
70 } 72 }
71 73
72 void set_run_tasks_synchronously(bool run_tasks_synchronously) { 74 void set_run_tasks_synchronously(bool run_tasks_synchronously) {
73 run_tasks_synchronously_ = run_tasks_synchronously; 75 run_tasks_synchronously_ = run_tasks_synchronously;
74 } 76 }
75 77
76 protected: 78 protected:
77 ~SynchronousSimpleTaskRunner() override = default; 79 ~SynchronousSimpleTaskRunner() override = default;
78 80
79 bool run_tasks_synchronously_ = false; 81 bool run_tasks_synchronously_ = false;
(...skipping 2296 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 // a part of raster tasks, the test should fail. 2378 // a part of raster tasks, the test should fail.
2377 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); 2379 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state());
2378 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); 2380 EXPECT_TRUE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting());
2379 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle(); 2381 static_cast<SynchronousTaskGraphRunner*>(task_graph_runner())->RunUntilIdle();
2380 base::RunLoop().RunUntilIdle(); 2382 base::RunLoop().RunUntilIdle();
2381 EXPECT_FALSE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting()); 2383 EXPECT_FALSE(host_impl()->tile_manager()->HasScheduledTileTasksForTesting());
2382 } 2384 }
2383 2385
2384 } // namespace 2386 } // namespace
2385 } // namespace cc 2387 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/image_controller_unittest.cc ('k') | chrome/browser/after_startup_task_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698