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

Side by Side Diff: components/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.h

Issue 987193002: Redirect the MessageLoop's task runner to the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another API update. Created 5 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS _H_ 5 #ifndef COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS _H_
6 #define COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS _H_ 6 #define COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TESTS _H_
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "components/scheduler/child/nestable_single_thread_task_runner.h" 9 #include "components/scheduler/child/nestable_single_thread_task_runner.h"
10 10
11 namespace scheduler { 11 namespace scheduler {
12 12
13 // This class connects the scheduler to a MessageLoop, but unlike 13 // This class connects the scheduler to a MessageLoop, but unlike
14 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily 14 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily
15 // after the scheduler has been brought up. This is needed in testing scenarios 15 // after the scheduler has been brought up. This is needed in testing scenarios
16 // where Blink is initialized before a MessageLoop has been created. 16 // where Blink is initialized before a MessageLoop has been created.
17 // 17 //
18 // TODO(skyostil): Fix the relevant test suites and remove this class 18 // TODO(skyostil): Fix the relevant test suites and remove this class
19 // (crbug.com/495659). 19 // (crbug.com/495659).
20 class LazySchedulerMessageLoopDelegateForTests 20 class LazySchedulerMessageLoopDelegateForTests
21 : public NestableSingleThreadTaskRunner { 21 : public NestableSingleThreadTaskRunner {
22 public: 22 public:
23 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create(); 23 static scoped_refptr<LazySchedulerMessageLoopDelegateForTests> Create();
24 24
25 // NestableSingleThreadTaskRunner implementation 25 // NestableSingleThreadTaskRunner implementation
26 void SetDefaultTaskRunner(
27 scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
26 bool PostDelayedTask(const tracked_objects::Location& from_here, 28 bool PostDelayedTask(const tracked_objects::Location& from_here,
27 const base::Closure& task, 29 const base::Closure& task,
28 base::TimeDelta delay) override; 30 base::TimeDelta delay) override;
29 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 31 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task, 32 const base::Closure& task,
31 base::TimeDelta delay) override; 33 base::TimeDelta delay) override;
32 bool RunsTasksOnCurrentThread() const override; 34 bool RunsTasksOnCurrentThread() const override;
33 bool IsNested() const override; 35 bool IsNested() const override;
34 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 36 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
35 void RemoveTaskObserver( 37 void RemoveTaskObserver(
36 base::MessageLoop::TaskObserver* task_observer) override; 38 base::MessageLoop::TaskObserver* task_observer) override;
37 39
38 private: 40 private:
39 LazySchedulerMessageLoopDelegateForTests(); 41 LazySchedulerMessageLoopDelegateForTests();
40 ~LazySchedulerMessageLoopDelegateForTests() override; 42 ~LazySchedulerMessageLoopDelegateForTests() override;
41 43
42 bool HasMessageLoop() const; 44 bool HasMessageLoop() const;
43 base::MessageLoop* EnsureMessageLoop() const; 45 base::MessageLoop* EnsureMessageLoop() const;
44 46
45 mutable base::MessageLoop* message_loop_; 47 mutable base::MessageLoop* message_loop_;
46 base::PlatformThreadId thread_id_; 48 base::PlatformThreadId thread_id_;
47 49
48 // Task observers which have not yet been registered to a message loop. Not 50 // Task observers which have not yet been registered to a message loop. Not
49 // owned. 51 // owned.
50 mutable base::hash_set<base::MessageLoop::TaskObserver*> pending_observers_; 52 mutable base::hash_set<base::MessageLoop::TaskObserver*> pending_observers_;
51 53
54 // A task runner which hasn't yet been overridden in the message loop.
55 mutable scoped_refptr<base::SingleThreadTaskRunner> pending_task_runner_;
56
52 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests); 57 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegateForTests);
53 }; 58 };
54 59
55 } // namespace scheduler 60 } // namespace scheduler
56 61
57 #endif // COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TE STS_H_ 62 #endif // COMPONENTS_SCHEDULER_TEST_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_FOR_TE STS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698