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

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

Issue 2290243002: Make blink::TimerBase own the WebTaskRunner for timer task (Closed)
Patch Set: use adoptRef Created 4 years, 3 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 | « third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
index 0798352018e2df58d5075e78aea71a1f1f37c306..eb0a7e11f41b30dd8ca9834a9b0baa08d24f9e8e 100644
--- a/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
+++ b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
@@ -4,23 +4,47 @@
#include "platform/scheduler/test/fake_web_task_runner.h"
+#include "base/logging.h"
+#include "wtf/RefCounted.h"
+
namespace blink {
namespace scheduler {
-FakeWebTaskRunner::FakeWebTaskRunner() : time_(0.0) {}
+class FakeWebTaskRunner::Data : public WTF::ThreadSafeRefCounted<Data> {
+ public:
+ Data() : time_(0.0) {}
+
+ std::unique_ptr<Task> task_;
+ double time_;
+
+ private:
+ ~Data() {}
+
+ friend ThreadSafeRefCounted<Data>;
+ DISALLOW_COPY_AND_ASSIGN(Data);
+};
+
+FakeWebTaskRunner::FakeWebTaskRunner() : data_(adoptRef(new Data)) {}
-FakeWebTaskRunner::~FakeWebTaskRunner() {}
+FakeWebTaskRunner::FakeWebTaskRunner(PassRefPtr<Data> data)
+ : data_(std::move(data)) {
+}
+
+FakeWebTaskRunner::~FakeWebTaskRunner() {
+}
void FakeWebTaskRunner::setTime(double new_time) {
- time_ = new_time;
+ data_->time_ = new_time;
}
-void FakeWebTaskRunner::postTask(const WebTraceLocation&, Task*) {}
+void FakeWebTaskRunner::postTask(const WebTraceLocation&, Task*) {
+ NOTREACHED();
+}
void FakeWebTaskRunner::postDelayedTask(const WebTraceLocation&,
Task* task,
double) {
- task_.reset(task);
+ data_->task_.reset(task);
}
bool FakeWebTaskRunner::runsTasksOnCurrentThread() {
@@ -28,18 +52,19 @@ bool FakeWebTaskRunner::runsTasksOnCurrentThread() {
}
std::unique_ptr<WebTaskRunner> FakeWebTaskRunner::clone() {
- return nullptr;
+ return WTF::wrapUnique(new FakeWebTaskRunner(data_));
}
double FakeWebTaskRunner::virtualTimeSeconds() const {
- return time_;
+ return data_->time_;
}
double FakeWebTaskRunner::monotonicallyIncreasingVirtualTimeSeconds() const {
- return time_;
+ return data_->time_;
}
SingleThreadTaskRunner* FakeWebTaskRunner::toSingleThreadTaskRunner() {
+ NOTREACHED();
return nullptr;
}
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698