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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h

Issue 2487493004: Support external task cancellation mechanisms in base::Callback::IsCancelled (Closed)
Patch Set: . Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H _ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H _
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H _ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H _
7 7
8 #include <deque>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
9 #include "platform/WebTaskRunner.h" 12 #include "platform/WebTaskRunner.h"
10 #include "wtf/PassRefPtr.h" 13 #include "wtf/PassRefPtr.h"
11 #include "wtf/RefPtr.h" 14 #include "wtf/RefPtr.h"
12 #include "base/memory/ref_counted.h"
13 15
14 namespace blink { 16 namespace blink {
15 namespace scheduler { 17 namespace scheduler {
16 18
17 // A dummy WebTaskRunner for tests. 19 // A dummy WebTaskRunner for tests.
18 class FakeWebTaskRunner : public WebTaskRunner { 20 class FakeWebTaskRunner : public WebTaskRunner {
19 public: 21 public:
20 FakeWebTaskRunner(); 22 FakeWebTaskRunner();
21 ~FakeWebTaskRunner() override; 23 ~FakeWebTaskRunner() override;
22 24
23 void setTime(double new_time); 25 void setTime(double new_time);
24 26
25 // WebTaskRunner implementation: 27 // WebTaskRunner implementation:
26 void postTask(const WebTraceLocation&, Task*) override; 28 void postTask(const WebTraceLocation&, Task*) override;
27 void postDelayedTask(const WebTraceLocation&, Task*, double) override; 29 void postDelayedTask(const WebTraceLocation&, Task*, double) override;
28 void postDelayedTask(const WebTraceLocation&, 30 void postDelayedTask(const WebTraceLocation&,
29 const base::Closure&, 31 const base::Closure&,
30 double) override; 32 double) override;
31 bool runsTasksOnCurrentThread() override; 33 bool runsTasksOnCurrentThread() override;
32 std::unique_ptr<WebTaskRunner> clone() override; 34 std::unique_ptr<WebTaskRunner> clone() override;
33 double virtualTimeSeconds() const override; 35 double virtualTimeSeconds() const override;
34 double monotonicallyIncreasingVirtualTimeSeconds() const override; 36 double monotonicallyIncreasingVirtualTimeSeconds() const override;
35 SingleThreadTaskRunner* toSingleThreadTaskRunner() override; 37 SingleThreadTaskRunner* toSingleThreadTaskRunner() override;
36 38
37 void runUntilIdle(); 39 void runUntilIdle();
40 std::deque<base::Closure> takePendingTasks();
38 41
39 private: 42 private:
40 class Data; 43 class Data;
41 class BaseTaskRunner; 44 class BaseTaskRunner;
42 RefPtr<Data> data_; 45 RefPtr<Data> data_;
43 scoped_refptr<BaseTaskRunner> base_task_runner_; 46 scoped_refptr<BaseTaskRunner> base_task_runner_;
44 47
45 FakeWebTaskRunner(PassRefPtr<Data> data, 48 FakeWebTaskRunner(PassRefPtr<Data> data,
46 scoped_refptr<BaseTaskRunner> base_task_runner); 49 scoped_refptr<BaseTaskRunner> base_task_runner);
47 50
48 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner); 51 DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner);
49 }; 52 };
50 53
51 } // namespace scheduler 54 } // namespace scheduler
52 } // namespace blink 55 } // namespace blink
53 56
54 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE R_H_ 57 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698