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

Unified Diff: content/test/test_blink_web_unit_test_support.cc

Issue 1156463004: Revert of 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 | « content/test/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_blink_web_unit_test_support.cc
diff --git a/content/test/test_blink_web_unit_test_support.cc b/content/test/test_blink_web_unit_test_support.cc
index 05a6b9bcce2fec1c48d896fbe7d74c177ba377f5..4dbce4054cc94fd8bab1e053d94d3134c25e252a 100644
--- a/content/test/test_blink_web_unit_test_support.cc
+++ b/content/test/test_blink_web_unit_test_support.cc
@@ -12,9 +12,8 @@
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
-#include "components/scheduler/renderer/renderer_scheduler_impl.h"
+#include "components/scheduler/renderer/renderer_scheduler.h"
#include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h"
-#include "components/scheduler/test/lazy_scheduler_message_loop_delegate_for_tests.h"
#include "content/test/mock_webclipboard_impl.h"
#include "content/test/web_gesture_curve_mock.h"
#include "content/test/web_layer_tree_view_impl_for_testing.h"
@@ -25,6 +24,7 @@
#include "storage/browser/database/vfs_backend.h"
#include "third_party/WebKit/public/platform/WebData.h"
#include "third_party/WebKit/public/platform/WebFileSystem.h"
+#include "third_party/WebKit/public/platform/WebScheduler.h"
#include "third_party/WebKit/public/platform/WebStorageArea.h"
#include "third_party/WebKit/public/platform/WebStorageNamespace.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -77,6 +77,35 @@
DISALLOW_COPY_AND_ASSIGN(DummyTaskRunner);
};
+class DummyWebThread : public blink::WebThread {
+ public:
+ DummyWebThread()
+ : thread_id_(base::PlatformThread::CurrentId()),
+ m_dummyScheduler(new blink::WebScheduler()) {}
+
+ virtual void postTask(const blink::WebTraceLocation&, Task*) { NOTREACHED(); }
+
+ virtual void postDelayedTask(const blink::WebTraceLocation&,
+ Task*,
+ long long delayMs) {
+ NOTREACHED();
+ }
+
+ virtual bool isCurrentThread() const {
+ return thread_id_ == base::PlatformThread::CurrentId();
+ }
+
+ virtual blink::WebScheduler* scheduler() const {
+ return m_dummyScheduler.get();
+ }
+
+ private:
+ base::PlatformThreadId thread_id_;
+ scoped_ptr<blink::WebScheduler> m_dummyScheduler;
+
+ DISALLOW_COPY_AND_ASSIGN(DummyWebThread);
+};
+
} // namespace
namespace content {
@@ -95,7 +124,11 @@
scoped_refptr<base::SingleThreadTaskRunner> dummy_task_runner;
scoped_ptr<base::ThreadTaskRunnerHandle> dummy_task_runner_handle;
- if (!base::MessageLoopProxy::current()) {
+ if (base::MessageLoopProxy::current()) {
+ renderer_scheduler_ = scheduler::RendererScheduler::Create();
+ web_thread_.reset(new scheduler::WebThreadImplForRendererScheduler(
+ renderer_scheduler_.get()));
+ } else {
// Dummy task runner is initialized here because the blink::initialize
// creates IsolateHolder which needs the current task runner handle. There
// should be no task posted to this task runner. The message loop is not
@@ -106,11 +139,8 @@
dummy_task_runner = make_scoped_refptr(new DummyTaskRunner());
dummy_task_runner_handle.reset(
new base::ThreadTaskRunnerHandle(dummy_task_runner));
- }
- renderer_scheduler_ = make_scoped_ptr(new scheduler::RendererSchedulerImpl(
- scheduler::LazySchedulerMessageLoopDelegateForTests::Create()));
- web_thread_.reset(new scheduler::WebThreadImplForRendererScheduler(
- renderer_scheduler_.get()));
+ web_thread_.reset(new DummyWebThread());
+ }
blink::initialize(this);
blink::setLayoutTestMode(true);
« no previous file with comments | « content/test/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698