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

Side by Side Diff: components/scheduler/renderer/lazy_scheduler_message_loop_delegate.h

Issue 1152623008: scheduler: Always create a real scheduler in unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows build fix. Created 5 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
6 #define COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
7
8 #include "base/message_loop/message_loop.h"
9 #include "components/scheduler/child/nestable_single_thread_task_runner.h"
10 #include "components/scheduler/scheduler_export.h"
11
12 namespace scheduler {
13
14 // This class connects the scheduler to a MessageLoop, but unlike
15 // SchedulerMessageLoopDelegate it allows the message loop to be created lazily
16 // after the scheduler has been brought up. This is needed in testing scenarios
17 // where Blink is initialized before a MessageLoop has been created.
18 //
19 // TODO(skyostil): Fix the relevant test suites and remove this class
20 // (crbug.com/495659).
21 class SCHEDULER_EXPORT LazySchedulerMessageLoopDelegate
rmcilroy 2015/06/02 16:53:07 Maybe we should call this LazySchedulerMessageLoop
Sami 2015/06/02 17:26:20 I thought about that but shied away because the in
22 : public NestableSingleThreadTaskRunner {
23 public:
24 static scoped_refptr<LazySchedulerMessageLoopDelegate> Create();
25
26 // NestableSingleThreadTaskRunner implementation
27 bool PostDelayedTask(const tracked_objects::Location& from_here,
28 const base::Closure& task,
29 base::TimeDelta delay) override;
30 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
31 const base::Closure& task,
32 base::TimeDelta delay) override;
33 bool RunsTasksOnCurrentThread() const override;
34 bool IsNested() const override;
35 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
36 void RemoveTaskObserver(
37 base::MessageLoop::TaskObserver* task_observer) override;
38
39 private:
40 LazySchedulerMessageLoopDelegate();
41 ~LazySchedulerMessageLoopDelegate() override;
42
43 bool HasMessageLoop() const;
44 base::MessageLoop* EnsureMessageLoop() const;
45
46 base::PlatformThreadId thread_id_;
47 // Task observers which have not yet been registered to a message loop. Not
48 // owned.
49 mutable base::hash_set<base::MessageLoop::TaskObserver*> pending_observers_;
50
51 DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegate);
52 };
53
54 } // namespace scheduler
55
56 #endif // COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698