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

Unified Diff: third_party/WebKit/Source/core/fetch/Resource.cpp

Issue 2506553002: Scheduler: Deprecate CancellableTaskFactory in favor of WebTaskRunner::postCancellableTask (Closed)
Patch Set: Created 4 years, 1 month 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/core/fetch/Resource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp
index 723beaef078e02bae7e48b631f91cd3c31c8ab38..c816d14f28e60b9264f290318b89ea48863804d5 100644
--- a/third_party/WebKit/Source/core/fetch/Resource.cpp
+++ b/third_party/WebKit/Source/core/fetch/Resource.cpp
@@ -37,6 +37,7 @@
#include "platform/InstanceCounters.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/SharedBuffer.h"
+#include "platform/WebTaskRunner.h"
#include "platform/network/HTTPParsers.h"
#include "platform/tracing/TraceEvent.h"
#include "platform/weborigin/KURL.h"
@@ -253,7 +254,7 @@ class Resource::ResourceCallback final {
ResourceCallback();
void runTask();
- std::unique_ptr<CancellableTaskFactory> m_callbackTaskFactory;
+ TaskHandle m_taskHandle;
HashSet<Persistent<Resource>> m_resourcesWithPendingClients;
};
@@ -262,26 +263,26 @@ Resource::ResourceCallback& Resource::ResourceCallback::callbackHandler() {
return callbackHandler;
}
-Resource::ResourceCallback::ResourceCallback()
- : m_callbackTaskFactory(
- CancellableTaskFactory::create(this, &ResourceCallback::runTask)) {}
+Resource::ResourceCallback::ResourceCallback() {}
void Resource::ResourceCallback::schedule(Resource* resource) {
- if (!m_callbackTaskFactory->isPending()) {
- Platform::current()
- ->currentThread()
- ->scheduler()
- ->loadingTaskRunner()
- ->postTask(BLINK_FROM_HERE, m_callbackTaskFactory->cancelAndCreate());
+ if (!m_taskHandle.isActive()) {
+ m_taskHandle =
+ Platform::current()
+ ->currentThread()
+ ->scheduler()
+ ->loadingTaskRunner()
+ ->postCancellableTask(
+ BLINK_FROM_HERE,
+ WTF::bind(&ResourceCallback::runTask, WTF::unretained(this)));
yhirano 2016/11/15 05:40:07 Please write a comment explaining why this unretai
nhiroki 2016/11/15 06:16:42 Done.
}
m_resourcesWithPendingClients.add(resource);
}
void Resource::ResourceCallback::cancel(Resource* resource) {
m_resourcesWithPendingClients.remove(resource);
- if (m_callbackTaskFactory->isPending() &&
- m_resourcesWithPendingClients.isEmpty())
- m_callbackTaskFactory->cancel();
+ if (m_taskHandle.isActive() && m_resourcesWithPendingClients.isEmpty())
+ m_taskHandle.cancel();
}
bool Resource::ResourceCallback::isScheduled(Resource* resource) const {
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698