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

Unified Diff: third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h

Issue 2236833002: Pass per-frame task runners to Workers (when possible) [2nd try] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, lifecycle observer + TaskType 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/core/workers/ParentFrameTaskRunners.h
diff --git a/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h
new file mode 100644
index 0000000000000000000000000000000000000000..8e90b8cf7cd886bc56547412d8ddf4b9ae9128b6
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/ParentFrameTaskRunners.h
@@ -0,0 +1,55 @@
+// 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 ParentFrameTaskRunners_h
+#define ParentFrameTaskRunners_h
+
+#include "core/CoreExport.h"
+#include "core/dom/TaskRunnerHelper.h"
+#include "platform/heap/Handle.h"
+#include "wtf/Allocator.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/PtrUtil.h"
+#include <memory>
+
+namespace blink {
+
+class Document;
+class WebTaskRunner;
+
+// Represents a set of task runners of the parent (or associated) document's
+// frame. This could be accessed from worker thread(s) and must be initialized
+// on the parent context thread (i.e. MainThread) on construction time, rather
+// than being done lazily.
+class CORE_EXPORT ParentFrameTaskRunners final {
+ WTF_MAKE_NONCOPYABLE(ParentFrameTaskRunners);
+ USING_FAST_MALLOC(ParentFrameTaskRunners);
+public:
+ static std::unique_ptr<ParentFrameTaskRunners> create(Document* document)
+ {
+ return wrapUnique(new ParentFrameTaskRunners(document));
+ }
+
+ ~ParentFrameTaskRunners();
+
+ WebTaskRunner* get(TaskType);
+
+private:
+ class Observer;
+ explicit ParentFrameTaskRunners(Document*);
+
+ void contextDestroyed();
+
+ WebTaskRunner* m_unthrottledTaskRunner;
+ WebTaskRunner* m_timerTaskRunner;
+ WebTaskRunner* m_loadingTaskRunner;
+
+ // A ContextLifecycleObserver for resetting task runners when the
+ // parent context is detached.
+ Persistent<Observer> m_observer;
haraken 2016/08/11 14:57:43 It would be slightly better to put ParentFrameTask
kinuko 2016/08/11 23:21:37 Done.
+};
+
+} // namespace blink
+
+#endif // ParentFrameTaskRunners_h

Powered by Google App Engine
This is Rietveld 408576698