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

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

Issue 2266443002: Optimize posting of WTF::Closure and improve scheduler test mocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cut back to just the WTF::Closure fix plus the scheduler test mock refactor. Created 4 years, 4 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
Index: third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h
diff --git a/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..e50c7071fb425b3dc5ffa9c32edbfa18b9b5e18a
--- /dev/null
+++ b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h
@@ -0,0 +1,41 @@
+// Copyright 2016 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H_
+#define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H_
+
+#include "base/macros.h"
+#include "public/platform/WebTaskRunner.h"
+
+namespace blink {
+namespace scheduler {
+
+// A dummy WebTaskRunner for tests.
+class FakeWebTaskRunner : public WebTaskRunner {
+ public:
+ FakeWebTaskRunner();
+ ~FakeWebTaskRunner() override;
+
+ void setTime(double new_time);
+
+ // WebTaskRunner implementation:
+ void postTask(const WebTraceLocation&, Task*) override;
+ void postDelayedTask(const WebTraceLocation&, Task*, double) override;
+ bool runsTasksOnCurrentThread() override;
+ std::unique_ptr<WebTaskRunner> clone() override;
+ double virtualTimeSeconds() const override;
+ double monotonicallyIncreasingVirtualTimeSeconds() const override;
+ SingleThreadTaskRunner* toSingleThreadTaskRunner() override;
+
+ private:
+ std::unique_ptr<Task> task_;
+ double time_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeWebTaskRunner);
+};
+
+} // namespace scheduler
+} // namespace blink
+
+#endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_TEST_FAKE_WEB_TASK_RUNNER_H_

Powered by Google App Engine
This is Rietveld 408576698