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

Unified 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: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/scheduler/renderer/lazy_scheduler_message_loop_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/lazy_scheduler_message_loop_delegate.h
diff --git a/components/scheduler/renderer/lazy_scheduler_message_loop_delegate.h b/components/scheduler/renderer/lazy_scheduler_message_loop_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..6c8a95dc99f1cc8434d1184a71bea14a32fa8b37
--- /dev/null
+++ b/components/scheduler/renderer/lazy_scheduler_message_loop_delegate.h
@@ -0,0 +1,56 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
+#define COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
+
+#include "base/message_loop/message_loop.h"
+#include "components/scheduler/child/nestable_single_thread_task_runner.h"
+#include "components/scheduler/scheduler_export.h"
+
+namespace scheduler {
+
+// This class connects the scheduler to a MessageLoop, but unlike
+// SchedulerMessageLoopDelegate it allows the message loop to be created lazily
+// after the scheduler has been brought up. This is needed in testing scenarios
+// where Blink is initialized before a MessageLoop has been created.
+//
+// TODO(skyostil): Fix the relevant test suites and remove this class.
+class SCHEDULER_EXPORT LazySchedulerMessageLoopDelegate
+ : public NestableSingleThreadTaskRunner {
+ public:
+ static scoped_refptr<LazySchedulerMessageLoopDelegate> Create();
+
+ // NestableSingleThreadTaskRunner implementation
+ bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) override;
+ bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) override;
+ bool RunsTasksOnCurrentThread() const override;
+ bool IsNested() const override;
+ void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
+ void RemoveTaskObserver(
+ base::MessageLoop::TaskObserver* task_observer) override;
+
+ protected:
alex clarke (OOO till 29th) 2015/06/02 16:01:45 Is this needed?
Sami 2015/06/02 16:08:38 Right, made the destructor private.
+ ~LazySchedulerMessageLoopDelegate() override;
+
+ private:
+ LazySchedulerMessageLoopDelegate();
alex clarke (OOO till 29th) 2015/06/02 16:01:45 nit: blank line after constructor?
Sami 2015/06/02 16:08:38 Done.
+ bool HasMessageLoop() const;
+ base::MessageLoop* EnsureMessageLoop() const;
+
+ base::PlatformThreadId thread_id_;
+ // Task observers which have not yet been registered to a message loop. Not
+ // owned.
+ mutable base::hash_set<base::MessageLoop::TaskObserver*> pending_observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(LazySchedulerMessageLoopDelegate);
+};
+
+} // namespace scheduler
+
+#endif // COMPONENTS_SCHEDULER_RENDERER_LAZY_SCHEDULER_MESSAGE_LOOP_DELEGATE_H_
« no previous file with comments | « no previous file | components/scheduler/renderer/lazy_scheduler_message_loop_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698